Re: [PATCH v6 6/6] config: "git config --get-urlmatch" parses section.<url>.key

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH v6 6/6] config: "git config --get-urlmatch" parses section.<url>.key

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:58:17

Jeff King [off-list ref] writes:
quoted hunk
That being said, git-config _should_ be lowercasing to match the normal
--get code path. I think the fix (squashable on top of 6/6 + my earlier
patch) is just:
diff --git a/builtin/config.c b/builtin/config.c
index c35c5be..9328a90 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -589,7 +589,9 @@ int cmd_config(int argc, const char **argv, const char *prefix)
 	}
 	else if (actions == ACTION_GET_URLMATCH) {
 		check_argc(argc, 2, 2);
-		return get_urlmatch(argv[0], argv[1]);
+		if (git_config_parse_key(argv[0], &key, NULL))
+			return CONFIG_INVALID_KEY;
+		return get_urlmatch(key, argv[1]);
 	}
 	else if (actions == ACTION_UNSET) {
 		check_argc(argc, 1, 2);
If we drop the "list every key in section.*" mode, the above should
be sufficient, I think.

I do not know how useful it would be to be for a scripted Porcelain
to be able to ask

    $ git config --get-urlmatch http https://weak.example.com/path/to/git.git

and get all the "http.*" variables that will apply to the given URL.

Re: [PATCH v6 6/6] config: "git config --get-urlmatch" parses section.<url>.key

From: Jeff King <hidden>
Date: 2016-06-15 22:58:17

On Thu, Aug 01, 2013 at 10:25:13AM -0700, Junio C Hamano wrote:
quoted
diff --git a/builtin/config.c b/builtin/config.c
index c35c5be..9328a90 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -589,7 +589,9 @@ int cmd_config(int argc, const char **argv, const char *prefix)
 	}
 	else if (actions == ACTION_GET_URLMATCH) {
 		check_argc(argc, 2, 2);
-		return get_urlmatch(argv[0], argv[1]);
+		if (git_config_parse_key(argv[0], &key, NULL))
+			return CONFIG_INVALID_KEY;
+		return get_urlmatch(key, argv[1]);
 	}
 	else if (actions == ACTION_UNSET) {
 		check_argc(argc, 1, 2);
If we drop the "list every key in section.*" mode, the above should
be sufficient, I think.
Ah, right, forgot about that again.
I do not know how useful it would be to be for a scripted Porcelain
to be able to ask

    $ git config --get-urlmatch http https://weak.example.com/path/to/git.git

and get all the "http.*" variables that will apply to the given URL.
I do not think it is all that useful, but I don't think it hurts too
much to have it (and it would be a hard operation to do otherwise). The
implementation you posted that downcases as we memdup the key makes
sense to me.

The key thing is that it is done only by git-config, as we would not
want to pay the allocation cost for every config key we look at during a
git_config() run, but I think your implementation is fine in that
respect.

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help