git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Jeff King <peff@peff.net>
Date
Aug 1, 2013, 17:30 UTC
Message-ID
<20130801173010.GB16562@sigill.intra.peff.net>
In-Reply-To
<7vob9hs4qu.fsf@alter.siamese.dyndns.org>
On Thu, Aug 01, 2013 at 10:25:13AM -0700, Junio C Hamano wrote:
Show 18 quoted lines
> > 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.
Show 6 quoted lines
> 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
Previous: Junio C HamanoNext: Kyle J. McKay
Message 19 of 23 in “http.<url>.<key> and friends”
  1. 0/6 http.<url>.<key> and friendsJunio C Hamano, Jul 31, 2013
  2. 1/6 http.c: fix parsing of http.sslCertPasswordProtected variableJunio C Hamano, Jul 31, 2013
  3. 2/6 config: add helper to normalize and match URLsJunio C Hamano, Jul 31, 2013
  4. Kyle J. McKayJul 31, 2013
  5. 0/2 http.<url>.<key> and friendsKyle J. McKay, Jul 31, 2013
  6. 2/4 config: add helper to normalize and match URLsKyle J. McKay, Jul 31, 2013
  7. 4/4 config: parse http.<url>.<variable> using urlmatchKyle J. McKay, Jul 31, 2013
  8. Junio C HamanoJul 31, 2013
  9. 4/6 config: parse http.<url>.<variable> using urlmatchKyle J. McKay, Jul 31, 2013
  10. 3/6 config: add generic callback wrapper to parse section.<url>.keyJunio C Hamano, Jul 31, 2013
  11. 4/6 config: parse http.<url>.<variable> using urlmatchJunio C Hamano, Jul 31, 2013
  12. Kyle J. McKayJul 31, 2013
  13. 5/6 builtin/config: refactor collect_config()Junio C Hamano, Jul 31, 2013
  14. 6/6 config: "git config --get-urlmatch" parses section.<url>.keyJunio C Hamano, Jul 31, 2013
  15. Jeff KingJul 31, 2013
  16. Kyle J. McKayJul 31, 2013
  17. Jeff KingJul 31, 2013
  18. Junio C HamanoAug 1, 2013
  19. Jeff KingAug 1, 2013
  20. 4/6 config: parse http.<url>.<variable> using urlmatchKyle J. McKay, Aug 5, 2013
  21. Junio C HamanoAug 5, 2013
  22. Kyle J. McKayAug 5, 2013
  23. Junio C HamanoJul 31, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.