]> git.ipfire.org Git - thirdparty/git.git/commitdiff
environment: move autorebase into repo_config_values
authorTian Yuchen <cat@malon.dev>
Tue, 14 Jul 2026 03:25:23 +0000 (11:25 +0800)
committerJunio C Hamano <gitster@pobox.com>
Tue, 14 Jul 2026 14:30:23 +0000 (07:30 -0700)
The global variable 'autorebase' dictates whether a newly created
branch should be configured to automatically rebase by default.
Move it into 'struct repo_config_values' to continue the
libification effort.

The 'enum rebase_setup_type' definition is moved higher up in
'environment.h' so that it is visible to the repository-specific
structure. The default state AUTOREBASE_NEVER is now correctly
initialized in 'repo_config_values_init()'.

Configuration parsing in 'git_default_branch_config()' is updated to
write directly to the repository's configuration instance.

Mentored-by: Christian Couder <christian.couder@gmail.com>
Mentored-by: Ayush Chandekar <ayu.chandekar@gmail.com>
Mentored-by: Olamide Caleb Bello <belkid98@gmail.com>
Signed-off-by: Tian Yuchen <cat@malon.dev>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
branch.c
environment.c
environment.h

index 243db7d0fc02266b9ec79cd8cb90f620c0ce1970..e1c1f8c89dbc56d2781d3c7f592a6e663a17f820 100644 (file)
--- a/branch.c
+++ b/branch.c
@@ -61,7 +61,7 @@ static int find_tracked_branch(struct remote *remote, void *priv)
 
 static int should_setup_rebase(const char *origin)
 {
-       switch (autorebase) {
+       switch (repo_config_values(the_repository)->autorebase) {
        case AUTOREBASE_NEVER:
                return 0;
        case AUTOREBASE_LOCAL:
index 66c1ac1ab8c0ee3856e127c8ab547723cc888141..c0bf7577b7ad4016e78983571873578f99716d04 100644 (file)
@@ -57,7 +57,6 @@ enum auto_crlf auto_crlf = AUTO_CRLF_FALSE;
 enum eol core_eol = EOL_UNSET;
 int global_conv_flags_eol = CONV_EOL_RNDTRP_WARN;
 char *check_roundtrip_encoding;
-enum rebase_setup_type autorebase = AUTOREBASE_NEVER;
 #ifndef OBJECT_CREATION_MODE
 #define OBJECT_CREATION_MODE OBJECT_CREATION_USES_HARDLINKS
 #endif
@@ -601,13 +600,13 @@ static int git_default_branch_config(const char *var, const char *value)
                if (!value)
                        return config_error_nonbool(var);
                else if (!strcmp(value, "never"))
-                       autorebase = AUTOREBASE_NEVER;
+                       cfg->autorebase = AUTOREBASE_NEVER;
                else if (!strcmp(value, "local"))
-                       autorebase = AUTOREBASE_LOCAL;
+                       cfg->autorebase = AUTOREBASE_LOCAL;
                else if (!strcmp(value, "remote"))
-                       autorebase = AUTOREBASE_REMOTE;
+                       cfg->autorebase = AUTOREBASE_REMOTE;
                else if (!strcmp(value, "always"))
-                       autorebase = AUTOREBASE_ALWAYS;
+                       cfg->autorebase = AUTOREBASE_ALWAYS;
                else
                        return error(_("malformed value for %s"), var);
                return 0;
@@ -728,6 +727,7 @@ void repo_config_values_init(struct repo_config_values *cfg)
        cfg->apply_default_whitespace = NULL;
        cfg->apply_default_ignorewhitespace = NULL;
        cfg->push_default = PUSH_DEFAULT_UNSPECIFIED;
+       cfg->autorebase = AUTOREBASE_NEVER;
        cfg->apply_sparse_checkout = 0;
        cfg->branch_track = BRANCH_TRACK_REMOTE;
        cfg->trust_ctime = 1;
index 17a3a628d2d299b26b264dbb1d29927273f9870d..46b2f0d861089eaf494f26ce151a62f8488d0cce 100644 (file)
@@ -102,6 +102,13 @@ enum push_default_type {
        PUSH_DEFAULT_UNSPECIFIED
 };
 
+enum rebase_setup_type {
+       AUTOREBASE_NEVER = 0,
+       AUTOREBASE_LOCAL,
+       AUTOREBASE_REMOTE,
+       AUTOREBASE_ALWAYS
+};
+
 struct repo_config_values {
        /* section "core" config values */
        char *attributes_file;
@@ -112,6 +119,7 @@ struct repo_config_values {
        char *apply_default_whitespace;
        char *apply_default_ignorewhitespace;
        enum push_default_type push_default;
+       enum rebase_setup_type autorebase;
        int apply_sparse_checkout;
        int trust_ctime;
        int check_stat;
@@ -205,14 +213,6 @@ extern unsigned long pack_size_limit_cfg;
 extern int protect_hfs;
 extern int protect_ntfs;
 
-enum rebase_setup_type {
-       AUTOREBASE_NEVER = 0,
-       AUTOREBASE_LOCAL,
-       AUTOREBASE_REMOTE,
-       AUTOREBASE_ALWAYS
-};
-extern enum rebase_setup_type autorebase;
-
 enum object_creation_mode {
        OBJECT_CREATION_USES_HARDLINKS = 0,
        OBJECT_CREATION_USES_RENAMES = 1