Subject: [bug#77186] [PATCH 11/13] services: gitolite-git-configuration: Add default-branch field.

From: Tomas Volf <[email-masked]>
Date: Sat, 22 Mar 2025 18:00:31 +0100

* gnu/services/version-control.scm (<gitolite-git-configuration>): Add
default-branch field.
(gitolite-git-configuration-compiler): Handle it during configuration file
generation.
* doc/guix.texi (Version Control Services): Document it.

Change-Id: Iceb02f60b8ef26138961aefef4e56ca83df0e19f
---
 doc/guix.texi                    |  4 ++++
 gnu/services/version-control.scm | 19 +++++++++++++------
 2 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index e584b072e1..3332813a02 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -41185,6 +41185,10 @@ Version Control Services
 @item @code{email} (default: @code{"guix@@localhost"})
 Email used for commits (e.g. during setting up the admin repository).
 
+@item @code{default-branch} (default: @code{#f})
+If true, set the @code{init.defaultBranch} option to that value.  Common
+values are @code{"master"} and @code{"main"}.
+
 @end table
 @end deftp
 
diff --git a/gnu/services/version-control.scm b/gnu/services/version-control.scm
index 68297dee19..712f0b1756 100644
--- a/gnu/services/version-control.scm
+++ b/gnu/services/version-control.scm
@@ -71,6 +71,7 @@ (define-module (gnu services version-control)
             gitolite-git-configuration?
             gitolite-git-configuration-name
             gitolite-git-configuration-email
+            gitolite-git-configuration-default-branch
 
             gitolite-service-type
 
@@ -329,19 +330,25 @@ (define-gexp-compiler (gitolite-rc-file-compiler
 (define-record-type* <gitolite-git-configuration>
   gitolite-git-configuration make-gitolite-git-configuration
   gitolite-git-configuration?
-  (name gitolite-git-configuration-name
-        (default "GNU Guix"))
-  (email gitolite-git-configuration-email
-         (default "guix@localhost")))
+  (name           gitolite-git-configuration-name
+                  (default "GNU Guix"))
+  (email          gitolite-git-configuration-email
+                  (default "guix@localhost"))
+  (default-branch gitolite-git-configuration-default-branch
+                  (default #f)))
 
 (define-gexp-compiler (gitolite-git-configuration-compiler
                        (config <gitolite-git-configuration>) system target)
   (match-record config <gitolite-git-configuration>
-                (name email)
+                (name email default-branch)
     (apply text-file* "gitconfig"
            `("[user]\n"
              "name  = " ,name  "\n"
-             "email = " ,email "\n"))))
+             "email = " ,email "\n"
+             ,@(if default-branch
+                   `("[init]\n"
+                     "defaultBranch = " ,default-branch "\n")
+                   '())))))
 
 (define-record-type* <gitolite-configuration>
   gitolite-configuration make-gitolite-configuration
-- 
2.48.1