All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Boeckel <mathstuf@gmail.com>
To: git@vger.kernel.org
Cc: "Ben Boeckel" <mathstuf@gmail.com>, "Jeff King" <peff@peff.net>,
	"Junio C Hamano" <gitster@pobox.com>,
	"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH v1 1/6] branch: move `git_default_branch_config` to `branch.c`
Date: Fri, 30 Jul 2021 22:42:16 -0400	[thread overview]
Message-ID: <20210731024221.2113906-2-mathstuf@gmail.com> (raw)
In-Reply-To: <20210731024221.2113906-1-mathstuf@gmail.com>

This allows branch-specific variables to be tracked locally in
`branch.c` instead of globally in `environment.c`.

Signed-off-by: Ben Boeckel <mathstuf@gmail.com>
---
 branch.c      | 32 ++++++++++++++++++++++++++++++++
 branch.h      |  5 +++++
 cache.h       |  1 -
 config.c      | 30 ------------------------------
 environment.c |  1 -
 5 files changed, 37 insertions(+), 32 deletions(-)

diff --git a/branch.c b/branch.c
index 7a88a4861e..1ef52db89d 100644
--- a/branch.c
+++ b/branch.c
@@ -9,6 +9,38 @@
 #include "commit.h"
 #include "worktree.h"
 
+static enum rebase_setup_type autorebase = AUTOREBASE_NEVER;
+
+int git_default_branch_config(const char *var, const char *value)
+{
+	if (!strcmp(var, "branch.autosetupmerge")) {
+		if (value && !strcasecmp(value, "always")) {
+			git_branch_track = BRANCH_TRACK_ALWAYS;
+			return 0;
+		}
+		git_branch_track = git_config_bool(var, value);
+		return 0;
+	}
+	if (!strcmp(var, "branch.autosetuprebase")) {
+		if (!value)
+			return config_error_nonbool(var);
+		else if (!strcmp(value, "never"))
+			autorebase = AUTOREBASE_NEVER;
+		else if (!strcmp(value, "local"))
+			autorebase = AUTOREBASE_LOCAL;
+		else if (!strcmp(value, "remote"))
+			autorebase = AUTOREBASE_REMOTE;
+		else if (!strcmp(value, "always"))
+			autorebase = AUTOREBASE_ALWAYS;
+		else
+			return error(_("malformed value for %s"), var);
+		return 0;
+	}
+
+	/* Add other config variables here and to Documentation/config.txt. */
+	return 0;
+}
+
 struct tracking {
 	struct refspec_item spec;
 	char *src;
diff --git a/branch.h b/branch.h
index df0be61506..801ff25f92 100644
--- a/branch.h
+++ b/branch.h
@@ -17,6 +17,11 @@ extern enum branch_track git_branch_track;
 
 /* Functions for acting on the information about branches. */
 
+/*
+ * Parses branch-related configuration options.
+ */
+int git_default_branch_config(const char *var, const char *value);
+
 /*
  * Creates a new branch, where:
  *
diff --git a/cache.h b/cache.h
index ba04ff8bd3..6ea1ea5854 100644
--- a/cache.h
+++ b/cache.h
@@ -1030,7 +1030,6 @@ enum push_default_type {
 	PUSH_DEFAULT_UNSPECIFIED
 };
 
-extern enum rebase_setup_type autorebase;
 extern enum push_default_type push_default;
 
 enum object_creation_mode {
diff --git a/config.c b/config.c
index f33abeab85..840be51710 100644
--- a/config.c
+++ b/config.c
@@ -1574,36 +1574,6 @@ static int git_default_i18n_config(const char *var, const char *value)
 	return 0;
 }
 
-static int git_default_branch_config(const char *var, const char *value)
-{
-	if (!strcmp(var, "branch.autosetupmerge")) {
-		if (value && !strcasecmp(value, "always")) {
-			git_branch_track = BRANCH_TRACK_ALWAYS;
-			return 0;
-		}
-		git_branch_track = git_config_bool(var, value);
-		return 0;
-	}
-	if (!strcmp(var, "branch.autosetuprebase")) {
-		if (!value)
-			return config_error_nonbool(var);
-		else if (!strcmp(value, "never"))
-			autorebase = AUTOREBASE_NEVER;
-		else if (!strcmp(value, "local"))
-			autorebase = AUTOREBASE_LOCAL;
-		else if (!strcmp(value, "remote"))
-			autorebase = AUTOREBASE_REMOTE;
-		else if (!strcmp(value, "always"))
-			autorebase = AUTOREBASE_ALWAYS;
-		else
-			return error(_("malformed value for %s"), var);
-		return 0;
-	}
-
-	/* Add other config variables here and to Documentation/config.txt. */
-	return 0;
-}
-
 static int git_default_push_config(const char *var, const char *value)
 {
 	if (!strcmp(var, "push.default")) {
diff --git a/environment.c b/environment.c
index 2f27008424..5d45152731 100644
--- a/environment.c
+++ b/environment.c
@@ -60,7 +60,6 @@ int global_conv_flags_eol = CONV_EOL_RNDTRP_WARN;
 char *check_roundtrip_encoding = "SHIFT-JIS";
 unsigned whitespace_rule_cfg = WS_DEFAULT_RULE;
 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
 #define OBJECT_CREATION_MODE OBJECT_CREATION_USES_HARDLINKS
-- 
2.31.1


  reply	other threads:[~2021-07-31  2:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-31  2:42 [PATCH v1 0/6] globals: clean up some global usages Ben Boeckel
2021-07-31  2:42 ` Ben Boeckel [this message]
2021-07-31  2:42 ` [PATCH v1 2/6] mailmap: move `git_default_mailmap_config` to `mailmap.c` Ben Boeckel
2021-07-31  2:42 ` [PATCH v1 3/6] apply: move `apply_default_*whitespace` to `apply.c` Ben Boeckel
2021-07-31  2:42 ` [PATCH v1 4/6] config: remove `core_compression_level` Ben Boeckel
2021-07-31  2:42 ` [PATCH v1 5/6] refs/debug: declare file-local variable to be static Ben Boeckel
2021-07-31  2:42 ` [PATCH v1 6/6] globals: remove explicit `0` initialization from globals Ben Boeckel

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=20210731024221.2113906-2-mathstuf@gmail.com \
    --to=mathstuf@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=pclouds@gmail.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.