public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Olamide Caleb Bello <belkid98@gmail•com>
To: git@vger•kernel.org
Cc: toon@iotcl•com, phillip.wood123@gmail•com, gitster@pobox•com,
	christian.couder@gmail•com, usmanakinyemi202@gmail•com,
	kaartic.sivaraam@gmail•com, me@ttaylorr•com,
	karthik.188@gmail•com, Olamide Caleb Bello <belkid98@gmail•com>
Subject: [Outreachy PATCH v4 3/3] environment: move "branch.autoSetupMerge" into `struct repo_config_values`
Date: Sat, 24 Jan 2026 12:55:06 +0100	[thread overview]
Message-ID: <c74973d6e97745451ef54616a3d35d0e2a67cf8a.1769252118.git.belkid98@gmail.com> (raw)
In-Reply-To: <cover.1769252118.git.belkid98@gmail.com>

The config value `brach.autoSetupMerge` is parsed in
`git_default_branch_config()` and stored in the global variable
`git_branch_track`. This global variable can be overwritten
by another repository when multiple Git repos run in the the same process.

Move this value into `struct repo_config_values` in the_repository to
retain current behaviours and move towards libifying Git.
Since the variable is no longer a global variable, it has been renamed to
`branch_track` in the struct `repo_config_values`.

Suggested-by: Phillip Wood <phillip.wood123@gmail•com>
Mentored-by: Christian Couder <christian.couder@gmail•com>
Mentored-by: Usman Akinyemi <usmanakinyemi202@gmail•com>
Signed-off-by: Olamide Caleb Bello <belkid98@gmail•com>
---
 branch.h                    |  2 --
 builtin/branch.c            |  2 +-
 builtin/checkout.c          |  2 +-
 builtin/push.c              |  2 +-
 builtin/submodule--helper.c |  2 +-
 environment.c               | 12 +++++++-----
 environment.h               |  4 ++++
 7 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/branch.h b/branch.h
index ec2f35fda4..3dc6e2a0ff 100644
--- a/branch.h
+++ b/branch.h
@@ -15,8 +15,6 @@ enum branch_track {
 	BRANCH_TRACK_SIMPLE,
 };
 
-extern enum branch_track git_branch_track;
-
 /* Functions for acting on the information about branches. */
 
 /**
diff --git a/builtin/branch.c b/builtin/branch.c
index c577b5d20f..7d27951a7e 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -795,7 +795,7 @@ int cmd_branch(int argc,
 	if (!sorting_options.nr)
 		string_list_append(&sorting_options, "refname");
 
-	track = git_branch_track;
+	track = the_repository->config_values.branch_track;
 
 	head = refs_resolve_refdup(get_main_ref_store(the_repository), "HEAD",
 				   0, &head_oid, NULL);
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 261699e2f5..ba6fea9aee 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -1631,7 +1631,7 @@ static int checkout_branch(struct checkout_opts *opts,
 		if (opts->track != BRANCH_TRACK_UNSPECIFIED)
 			die(_("'%s' cannot be used with '%s'"), "--detach", "-t");
 	} else if (opts->track == BRANCH_TRACK_UNSPECIFIED)
-		opts->track = git_branch_track;
+		opts->track = the_repository->config_values.branch_track;
 
 	if (new_branch_info->name && !new_branch_info->commit)
 		die(_("Cannot switch branch to a non-commit '%s'"),
diff --git a/builtin/push.c b/builtin/push.c
index 5b6cebbb85..7be20a1035 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -162,7 +162,7 @@ static NORETURN void die_push_simple(struct branch *branch,
 		advice_pushdefault_maybe = _("\n"
 				 "To choose either option permanently, "
 				 "see push.default in 'git help config'.\n");
-	if (git_branch_track != BRANCH_TRACK_SIMPLE)
+	if (the_repository->config_values.branch_track != BRANCH_TRACK_SIMPLE)
 		advice_automergesimple_maybe = _("\n"
 				 "To avoid automatically configuring "
 				 "an upstream branch when its name\n"
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index d537ab087a..f2b6f027d7 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -3128,7 +3128,7 @@ static int module_create_branch(int argc, const char **argv, const char *prefix,
 	};
 
 	repo_config(the_repository, git_default_config, NULL);
-	track = git_branch_track;
+	track = the_repository->config_values.branch_track;
 	argc = parse_options(argc, argv, prefix, options, usage, 0);
 
 	if (argc != 3)
diff --git a/environment.c b/environment.c
index 269cac6d6e..de8721657e 100644
--- a/environment.c
+++ b/environment.c
@@ -66,7 +66,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 branch_track git_branch_track = BRANCH_TRACK_REMOTE;
 enum rebase_setup_type autorebase = AUTOREBASE_NEVER;
 enum push_default_type push_default = PUSH_DEFAULT_UNSPECIFIED;
 #ifndef OBJECT_CREATION_MODE
@@ -607,18 +606,20 @@ static int git_default_i18n_config(const char *var, const char *value)
 
 static int git_default_branch_config(const char *var, const char *value)
 {
+	struct repo_config_values *cfg = &the_repository->config_values;
+
 	if (!strcmp(var, "branch.autosetupmerge")) {
 		if (value && !strcmp(value, "always")) {
-			git_branch_track = BRANCH_TRACK_ALWAYS;
+			cfg->branch_track = BRANCH_TRACK_ALWAYS;
 			return 0;
 		} else if (value && !strcmp(value, "inherit")) {
-			git_branch_track = BRANCH_TRACK_INHERIT;
+			cfg->branch_track = BRANCH_TRACK_INHERIT;
 			return 0;
 		} else if (value && !strcmp(value, "simple")) {
-			git_branch_track = BRANCH_TRACK_SIMPLE;
+			cfg->branch_track = BRANCH_TRACK_SIMPLE;
 			return 0;
 		}
-		git_branch_track = git_config_bool(var, value);
+		cfg->branch_track = git_config_bool(var, value);
 		return 0;
 	}
 	if (!strcmp(var, "branch.autosetuprebase")) {
@@ -761,4 +762,5 @@ void repo_config_values_init(struct repo_config_values *cfg)
 {
 	cfg->attributes_file = NULL;
 	cfg->apply_sparse_checkout = 0;
+	cfg->branch_track = BRANCH_TRACK_REMOTE;
 }
diff --git a/environment.h b/environment.h
index ddce69c6ba..27161d56ab 100644
--- a/environment.h
+++ b/environment.h
@@ -2,6 +2,7 @@
 #define ENVIRONMENT_H
 
 #include "repo-settings.h"
+#include "branch.h"
 
 /* Double-check local_repo_env below if you add to this list. */
 #define GIT_DIR_ENVIRONMENT "GIT_DIR"
@@ -88,6 +89,9 @@ struct repo_config_values {
 	/* section "core" config values */
 	char *attributes_file;
 	int apply_sparse_checkout;
+
+	/* section "branch" config values */
+	enum branch_track branch_track;
 };
 
 /*
-- 
2.34.1


  parent reply	other threads:[~2026-01-24 11:55 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-12 12:59 [Outreachy PATCH RFC 0/3] store git_default_config() parsed values in new config struct Olamide Caleb Bello
2026-01-12 12:59 ` [Outreachy PATCH RFC 1/3] environment: stop storing `core.attributesFile` globally Olamide Caleb Bello
2026-01-12 14:29   ` Phillip Wood
2026-01-12 15:05     ` Bello Olamide
2026-01-12 12:59 ` [Outreachy PATCH RFC 2/3] environment: stop using core.sparseCheckout globally Olamide Caleb Bello
2026-01-12 12:59 ` [Outreachy PATCH RFC 3/3] environment: move "branch.autoSetupMerge" into `struct config_values` Olamide Caleb Bello
2026-01-13 16:43 ` [Outreachy PATCH v2 0/3] store git_default_config() parsed values in new config struct Olamide Caleb Bello
2026-01-13 16:44   ` [Outreachy PATCH v2 1/3] environment: stop storing `core.attributesFile` globally Olamide Caleb Bello
2026-01-13 19:26     ` Junio C Hamano
2026-01-14  6:59       ` Bello Olamide
2026-01-13 16:44   ` [Outreachy PATCH v2 2/3] environment: environment: stop using core.sparseCheckout globally Olamide Caleb Bello
2026-01-13 19:38     ` Junio C Hamano
2026-01-14  7:16       ` Bello Olamide
2026-01-13 16:44   ` [Outreachy PATCH v2 3/3] environment: move "branch.autoSetupMerge" into `struct repo_config_values` Olamide Caleb Bello
2026-01-13 19:53     ` Junio C Hamano
2026-01-14  7:40       ` Bello Olamide
2026-01-15 22:17   ` [Outreachy PATCH v2 0/3] store git_default_config() parsed values in new config struct Bello Olamide
2026-01-17 20:59   ` [Outreachy PATCH v3 0/3] store repo specific config values in new `struct repo_config_values` Olamide Caleb Bello
2026-01-17 20:59     ` [Outreachy PATCH v3 1/3] environment: stop storing `core.attributesFile` globally Olamide Caleb Bello
2026-01-22 12:13       ` Toon Claes
2026-01-22 15:08         ` Bello Olamide
2026-01-22 14:40       ` Phillip Wood
2026-01-22 15:11         ` Bello Olamide
2026-01-17 20:59     ` [Outreachy PATCH v3 2/3] environment: environment: stop using core.sparseCheckout globally Olamide Caleb Bello
2026-01-22 12:13       ` Toon Claes
2026-01-22 15:17         ` Bello Olamide
2026-01-22 14:41       ` Phillip Wood
2026-01-22 15:29         ` Bello Olamide
2026-01-23 10:43           ` Phillip Wood
2026-01-23 13:24             ` Bello Olamide
2026-01-17 20:59     ` [Outreachy PATCH v3 3/3] environment: move "branch.autoSetupMerge" into `struct repo_config_values` Olamide Caleb Bello
2026-01-22 14:41       ` Phillip Wood
2026-01-22 15:29         ` Bello Olamide
2026-01-20 15:19     ` [Outreachy PATCH v3 0/3] store repo specific config values in new " Bello Olamide
2026-01-24 11:55     ` [Outreachy PATCH v4 " Olamide Caleb Bello
2026-01-24 11:55       ` [Outreachy PATCH v4 1/3] environment: stop storing `core.attributesFile` globally Olamide Caleb Bello
2026-01-24 11:55       ` [Outreachy PATCH v4 2/3] environment: stop using core.sparseCheckout globally Olamide Caleb Bello
2026-01-24 11:55       ` Olamide Caleb Bello [this message]
2026-01-24 12:21       ` [Outreachy PATCH v5 0/3] store repo specific config values in new `struct repo_config_values` Olamide Caleb Bello
2026-01-24 12:21         ` [Outreachy PATCH v5 1/3] environment: stop storing `core.attributesFile` globally Olamide Caleb Bello
2026-01-29 18:01           ` Junio C Hamano
2026-01-24 12:21         ` [Outreachy PATCH v5 2/3] environment: stop using core.sparseCheckout globally Olamide Caleb Bello
2026-01-29 18:12           ` Junio C Hamano
2026-01-24 12:21         ` [Outreachy PATCH v5 3/3] environment: move "branch.autoSetupMerge" into `struct repo_config_values` Olamide Caleb Bello
2026-01-29 18:37           ` Junio C Hamano
2026-01-30 16:20             ` Junio C Hamano
2026-01-30 20:15               ` Junio C Hamano
2026-01-29  8:29         ` [Outreachy PATCH v5 0/3] store repo specific config values in new " Bello Olamide
2026-02-03 15:42         ` [Outreachy PATCH v6 " Olamide Caleb Bello
2026-02-03 15:42           ` [Outreachy PATCH v6 1/3] environment: stop storing `core.attributesFile` globally Olamide Caleb Bello
2026-02-04 16:39             ` Phillip Wood
2026-02-09  8:47               ` Bello Olamide
2026-02-07  1:14             ` Junio C Hamano
2026-02-08 11:14               ` Phillip Wood
2026-02-09  8:54                 ` Bello Olamide
2026-02-10  8:40                 ` Bello Olamide
2026-02-03 15:42           ` [Outreachy PATCH v6 2/3] environment: stop using core.sparseCheckout globally Olamide Caleb Bello
2026-02-04 16:55             ` Phillip Wood
2026-02-03 15:42           ` [Outreachy PATCH v6 3/3] environment: move "branch.autoSetupMerge" into `struct repo_config_values` Olamide Caleb Bello
2026-02-04 16:57           ` [Outreachy PATCH v6 0/3] store repo specific config values in new " Phillip Wood
2026-02-16 16:38         ` [Outreachy PATCH v7 " Olamide Caleb Bello
2026-02-16 16:38           ` [Outreachy PATCH v7 1/3] environment: stop storing `core.attributesFile` globally Olamide Caleb Bello
2026-02-16 16:38           ` [Outreachy PATCH v7 2/3] environment: stop using core.sparseCheckout globally Olamide Caleb Bello
2026-02-26 12:57             ` Christian Couder
2026-02-26 15:23               ` Junio C Hamano
2026-02-26 16:24                 ` Bello Olamide
2026-02-16 16:38           ` [Outreachy PATCH v7 3/3] environment: move "branch.autoSetupMerge" into `struct repo_config_values` Olamide Caleb Bello
2026-02-17 20:08           ` [Outreachy PATCH v7 0/3] store repo specific config values in new " Junio C Hamano
2026-02-18 11:27             ` Bello Olamide
2026-02-26 13:03             ` Christian Couder
2026-02-26 15:19               ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c74973d6e97745451ef54616a3d35d0e2a67cf8a.1769252118.git.belkid98@gmail.com \
    --to=belkid98@gmail$(echo .)com \
    --cc=christian.couder@gmail$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=gitster@pobox$(echo .)com \
    --cc=kaartic.sivaraam@gmail$(echo .)com \
    --cc=karthik.188@gmail$(echo .)com \
    --cc=me@ttaylorr$(echo .)com \
    --cc=phillip.wood123@gmail$(echo .)com \
    --cc=toon@iotcl$(echo .)com \
    --cc=usmanakinyemi202@gmail$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox