git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Matthew Rogers via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Matthew Rogers <mattr94@gmail.com>, Matthew Rogers <mattr94@gmail.com>
Subject: [PATCH v7 05/10] config: split repo scope to local and worktree
Date: Mon, 10 Feb 2020 00:30:54 +0000	[thread overview]
Message-ID: <1af0237b8e76f0fd84ccac1e29d0cdc326303d7e.1581294660.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.478.v7.git.1581294660.gitgitgadget@gmail.com>

From: Matthew Rogers <mattr94@gmail.com>

Previously when iterating through git config variables, worktree config
and local config were both considered "CONFIG_SCOPE_REPO".  This was
never a problem before as no one had needed to differentiate between the
two cases, but future functionality may care whether or not the config
options come from a worktree or from the repository's actual local
config file.  For example, the planned feature to add a '--show-scope'
to config to allow a user to see which scope listed config options come
from would confuse users if it just printed 'repo' rather than 'local'
or 'worktree' as the documentation would lead them to expect.  As well
as the additional benefit of making the implementation look more like
how the documentation describes the interface.

To accomplish this we split out what was previously considered repo
scope to be local and worktree.

The clients of 'current_config_scope()' who cared about
CONFIG_SCOPE_REPO are also modified to similarly care about
CONFIG_SCOPE_WORKTREE and CONFIG_SCOPE_LOCAL to preserve previous behavior.

Signed-off-by: Matthew Rogers <mattr94@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 config.c              | 13 ++++++-------
 config.h              |  3 ++-
 remote.c              |  3 ++-
 t/t1308-config-set.sh |  2 +-
 upload-pack.c         |  3 ++-
 5 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/config.c b/config.c
index 83bb98d65e..7422bdebb1 100644
--- a/config.c
+++ b/config.c
@@ -1724,15 +1724,12 @@ static int do_git_config_sequence(const struct config_options *opts,
 	if (user_config && !access_or_die(user_config, R_OK, ACCESS_EACCES_OK))
 		ret += git_config_from_file(fn, user_config, data);
 
-	current_parsing_scope = CONFIG_SCOPE_REPO;
+	current_parsing_scope = CONFIG_SCOPE_LOCAL;
 	if (!opts->ignore_repo && repo_config &&
 	    !access_or_die(repo_config, R_OK, 0))
 		ret += git_config_from_file(fn, repo_config, data);
 
-	/*
-	 * Note: this should have a new scope, CONFIG_SCOPE_WORKTREE.
-	 * But let's not complicate things before it's actually needed.
-	 */
+	current_parsing_scope = CONFIG_SCOPE_WORKTREE;
 	if (!opts->ignore_worktree && repository_format_worktree_config) {
 		char *path = git_pathdup("config.worktree");
 		if (!access_or_die(path, R_OK, 0))
@@ -3304,8 +3301,10 @@ const char *config_scope_name(enum config_scope scope)
 		return "system";
 	case CONFIG_SCOPE_GLOBAL:
 		return "global";
-	case CONFIG_SCOPE_REPO:
-		return "repo";
+	case CONFIG_SCOPE_LOCAL:
+		return "local";
+	case CONFIG_SCOPE_WORKTREE:
+		return "worktree";
 	case CONFIG_SCOPE_CMDLINE:
 		return "command line";
 	default:
diff --git a/config.h b/config.h
index dcb8c274d4..d3ed41ef8e 100644
--- a/config.h
+++ b/config.h
@@ -299,7 +299,8 @@ enum config_scope {
 	CONFIG_SCOPE_UNKNOWN = 0,
 	CONFIG_SCOPE_SYSTEM,
 	CONFIG_SCOPE_GLOBAL,
-	CONFIG_SCOPE_REPO,
+	CONFIG_SCOPE_LOCAL,
+	CONFIG_SCOPE_WORKTREE,
 	CONFIG_SCOPE_CMDLINE,
 };
 const char *config_scope_name(enum config_scope scope);
diff --git a/remote.c b/remote.c
index 5c4666b53a..593ce297ed 100644
--- a/remote.c
+++ b/remote.c
@@ -369,7 +369,8 @@ static int handle_config(const char *key, const char *value, void *cb)
 	}
 	remote = make_remote(name, namelen);
 	remote->origin = REMOTE_CONFIG;
-	if (current_config_scope() == CONFIG_SCOPE_REPO)
+	if (current_config_scope() == CONFIG_SCOPE_LOCAL ||
+	current_config_scope() == CONFIG_SCOPE_WORKTREE)
 		remote->configured_in_repo = 1;
 	if (!strcmp(subkey, "mirror"))
 		remote->mirror = git_config_bool(key, value);
diff --git a/t/t1308-config-set.sh b/t/t1308-config-set.sh
index 5f3e71a160..728a2b87ce 100755
--- a/t/t1308-config-set.sh
+++ b/t/t1308-config-set.sh
@@ -259,7 +259,7 @@ test_expect_success 'iteration shows correct origins' '
 	value=from-repo
 	origin=file
 	name=.git/config
-	scope=repo
+	scope=local
 
 	key=foo.bar
 	value=from-cmdline
diff --git a/upload-pack.c b/upload-pack.c
index a00d7ece6b..c53249cac1 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -1073,7 +1073,8 @@ static int upload_pack_config(const char *var, const char *value, void *unused)
 		precomposed_unicode = git_config_bool(var, value);
 	}
 
-	if (current_config_scope() != CONFIG_SCOPE_REPO) {
+	if (current_config_scope() != CONFIG_SCOPE_LOCAL &&
+	current_config_scope() != CONFIG_SCOPE_WORKTREE) {
 		if (!strcmp("uploadpack.packobjectshook", var))
 			return git_config_string(&pack_objects_hook, var, value);
 	}
-- 
gitgitgadget


  parent reply	other threads:[~2020-02-10  0:31 UTC|newest]

Thread overview: 98+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-18  1:11 [PATCH 0/1] config: allow user to know scope of config options Matthew Rogers via GitGitGadget
2019-12-18  1:11 ` [PATCH 1/1] " Matthew Rogers via GitGitGadget
2019-12-18 19:46   ` Junio C Hamano
2019-12-19  5:05     ` Jeff King
2019-12-19 17:51       ` Junio C Hamano
2019-12-18 22:45   ` Philip Oakley
2019-12-19  0:12     ` mattr94
2019-12-19 17:56       ` Junio C Hamano
2019-12-20 22:58         ` Matt Rogers
2019-12-21  2:37           ` Junio C Hamano
2019-12-21  3:08             ` Matt Rogers
2019-12-21 23:47               ` Junio C Hamano
2020-01-09 10:16 ` [PATCH v2 0/4] " Matthew Rogers via GitGitGadget
2020-01-09 10:16   ` [PATCH v2 1/4] config: fix typo in variable name Matthew Rogers via GitGitGadget
2020-01-09 19:07     ` Junio C Hamano
2020-01-09 23:22       ` Matt Rogers
2020-01-10 11:55     ` Jeff King
2020-01-09 10:16   ` [PATCH v2 2/4] config: fix config scope enum Matthew Rogers via GitGitGadget
2020-01-09 19:06     ` Junio C Hamano
2020-01-09 23:29       ` Matt Rogers
2020-01-09 10:16   ` [PATCH v2 3/4] config: clarify meaning of command line scoping Matthew Rogers via GitGitGadget
2020-01-09 19:13     ` Junio C Hamano
2020-01-09 23:41       ` Matt Rogers
2020-01-09 10:16   ` [PATCH v2 4/4] config: add '--show-scope' to print the scope of a config value Matthew Rogers via GitGitGadget
2020-01-09 19:50     ` Junio C Hamano
2020-01-09 23:47       ` Matt Rogers
2020-01-17 15:31   ` [PATCH v3 0/4] config: allow user to know scope of config options Matthew Rogers via GitGitGadget
2020-01-17 15:31     ` [PATCH v3 1/4] config: fix typo in variable name Matthew Rogers via GitGitGadget
2020-01-17 15:31     ` [PATCH v3 2/4] config: refine config scope enum Matthew Rogers via GitGitGadget
2020-01-17 20:44       ` Junio C Hamano
2020-01-18 15:27         ` Matt Rogers
2020-01-18 18:09           ` Junio C Hamano
2020-01-17 15:31     ` [PATCH v3 3/4] config: clarify meaning of command line scoping Matthew Rogers via GitGitGadget
2020-01-17 21:00       ` Junio C Hamano
2020-01-18 15:33         ` Matt Rogers
2020-01-17 15:31     ` [PATCH v3 4/4] config: add '--show-scope' to print the scope of a config value Matthew Rogers via GitGitGadget
2020-01-17 21:21       ` Junio C Hamano
2020-01-17 21:26         ` Bert Wesarg
2020-01-18 15:42         ` Matt Rogers
2020-01-24  0:21     ` [PATCH v4 0/6] config: allow user to know scope of config options Matthew Rogers via GitGitGadget
2020-01-24  0:21       ` [PATCH v4 1/6] config: fix typo in variable name Matthew Rogers via GitGitGadget
2020-01-24  0:21       ` [PATCH v4 2/6] t1300: fix over-indented HERE-DOCs Matthew Rogers via GitGitGadget
2020-01-24 18:43         ` Junio C Hamano
2020-01-24  0:21       ` [PATCH v4 3/6] t1300: create custom config file without special characters Matthew Rogers via GitGitGadget
2020-01-24 18:45         ` Junio C Hamano
2020-01-24  0:21       ` [PATCH v4 4/6] config: split repo scope to local and worktree Matthew Rogers via GitGitGadget
2020-01-24 18:49         ` Junio C Hamano
2020-01-24 19:09         ` Junio C Hamano
2020-01-24  0:21       ` [PATCH v4 5/6] config: clarify meaning of command line scoping Matthew Rogers via GitGitGadget
2020-01-24  0:21       ` [PATCH v4 6/6] config: add '--show-scope' to print the scope of a config value Matthew Rogers via GitGitGadget
2020-01-24 19:18         ` Junio C Hamano
2020-01-24 20:22         ` Junio C Hamano
2020-01-24 20:49           ` Matt Rogers
2020-01-25  0:10             ` Junio C Hamano
2020-01-24 19:22       ` [PATCH v4 0/6] config: allow user to know scope of config options Junio C Hamano
2020-01-25  0:39       ` [PATCH v5 " Matthew Rogers via GitGitGadget
2020-01-25  0:39         ` [PATCH v5 1/6] config: fix typo in variable name Matthew Rogers via GitGitGadget
2020-01-25  0:39         ` [PATCH v5 2/6] t1300: fix over-indented HERE-DOCs Matthew Rogers via GitGitGadget
2020-01-25  0:39         ` [PATCH v5 3/6] t1300: create custom config file without special characters Matthew Rogers via GitGitGadget
2020-01-25  0:39         ` [PATCH v5 4/6] config: split repo scope to local and worktree Matthew Rogers via GitGitGadget
2020-01-27 23:09           ` Junio C Hamano
2020-01-25  0:39         ` [PATCH v5 5/6] config: clarify meaning of command line scoping Matthew Rogers via GitGitGadget
2020-01-25  0:39         ` [PATCH v5 6/6] config: add '--show-scope' to print the scope of a config value Matthew Rogers via GitGitGadget
2020-01-27 23:12           ` Junio C Hamano
2020-01-28  1:31             ` Matt Rogers
2020-01-29  3:34         ` [PATCH v6 0/6] config: allow user to know scope of config options Matthew Rogers via GitGitGadget
2020-01-29  3:34           ` [PATCH v6 1/6] config: fix typo in variable name Matthew Rogers via GitGitGadget
2020-01-29  3:34           ` [PATCH v6 2/6] t1300: fix over-indented HERE-DOCs Matthew Rogers via GitGitGadget
2020-01-29  3:34           ` [PATCH v6 3/6] t1300: create custom config file without special characters Matthew Rogers via GitGitGadget
2020-01-29  3:34           ` [PATCH v6 4/6] config: split repo scope to local and worktree Matthew Rogers via GitGitGadget
2020-01-29  3:34           ` [PATCH v6 5/6] config: clarify meaning of command line scoping Matthew Rogers via GitGitGadget
2020-01-29  3:34           ` [PATCH v6 6/6] config: add '--show-scope' to print the scope of a config value Matthew Rogers via GitGitGadget
2020-01-29  9:08             ` Bert Wesarg
2020-01-29 23:03               ` Matt Rogers
2020-02-05 19:01                 ` Junio C Hamano
2020-01-29  5:29           ` [PATCH v6 0/6] config: allow user to know scope of config options Junio C Hamano
2020-02-10  0:30           ` [PATCH v7 00/10] " Matthew Rogers via GitGitGadget
2020-02-10  0:30             ` [PATCH v7 01/10] config: fix typo in variable name Matthew Rogers via GitGitGadget
2020-02-10  0:30             ` [PATCH v7 02/10] t1300: fix over-indented HERE-DOCs Matthew Rogers via GitGitGadget
2020-02-10  0:30             ` [PATCH v7 03/10] t1300: create custom config file without special characters Matthew Rogers via GitGitGadget
2020-02-10  0:30             ` [PATCH v7 04/10] config: make scope_name non-static and rename it Matthew Rogers via GitGitGadget
2020-02-10 18:02               ` Junio C Hamano
2020-02-10 21:25                 ` Junio C Hamano
2020-02-11  0:30                 ` Matt Rogers
2020-02-11  1:58                   ` Emily Shaffer
2020-02-11  6:10                   ` Junio C Hamano
2020-02-11 12:37                     ` Matt Rogers
2020-02-10  0:30             ` Matthew Rogers via GitGitGadget [this message]
2020-02-10 18:07               ` [PATCH v7 05/10] config: split repo scope to local and worktree Junio C Hamano
2020-02-10  0:30             ` [PATCH v7 06/10] config: clarify meaning of command line scoping Matthew Rogers via GitGitGadget
2020-02-10 18:10               ` Junio C Hamano
2020-02-10  0:30             ` [PATCH v7 07/10] config: preserve scope in do_git_config_sequence Matthew Rogers via GitGitGadget
2020-02-10 18:11               ` Junio C Hamano
2020-02-10  0:30             ` [PATCH v7 08/10] config: teach git_config_source to remember its scope Matthew Rogers via GitGitGadget
2020-02-10 18:14               ` Junio C Hamano
2020-02-10  0:30             ` [PATCH v7 09/10] submodule-config: add subomdule config scope Matthew Rogers via GitGitGadget
2020-02-10 18:15               ` Junio C Hamano
2020-02-10  0:30             ` [PATCH v7 10/10] config: add '--show-scope' to print the scope of a config value Matthew Rogers via GitGitGadget

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=1af0237b8e76f0fd84ccac1e29d0cdc326303d7e.1581294660.git.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=mattr94@gmail.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).