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

Re: Enhancement request: git-push: Allow (configurable) default push-option

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 11, 2017, 11:13 UTC
Message-ID
<xmqq4lr6lyyb.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<CAK7vU=22W9mYdSnw_LP2uWYyKZuTzF0JgTVWCX+nMhUnLjQ_Cw@mail.gmail.com>
Marius Paliga <marius.paliga@gmail.com> writes:
Show 5 quoted lines
> +    default_push_options = git_config_get_value_multi("push.optiondefault");
> +    if (default_push_options)
> +        for_each_string_list_item(item, default_push_options)
> +            if (!string_list_has_string(&push_options, item->string))
> +                string_list_append(&push_options, item->string);

One thing that is often overlooked is how to allow users to override a multi-value configuration variable that gets some values from lower priority configuration files (e.g. ~/.gitconfig) with repository specific settings in .git/config, and the way we typically do so is to define "When a variable definition with an empty string is given, it is a signal to clear everything accumulated so far." E.g. if your ~/.gitconfig has

	[push]
		defaultPushOption = foo
		defaultPushOption = bar
and then you write in your .git/config something like
	[push]
		defaultPushOption =
		defaultPushOption = baz

The configuration mechanism reads from lower priority files and then proceeds to read higher priority files, so the parser would read them in this order:

	push.defaultPushOption = foo
	push.defaultPushOption = bar
	push.defaultPushOption = 
	push.defaultPushOption = baz

and then it would build a list ('foo'), then ('foo', 'bar'), and clears it upon seeing an empty, and compute the final result as ('baz').

You may want to do something like that in this code.
        
Previous: Stefan BellerNext: Junio C Hamano
Message 7 of 24 in “Enhancement request: git-push: Allow (configurable) default push-option”
  1. Marius PaligaOct 3, 2017
  2. Stefan BellerOct 3, 2017
  3. Marius PaligaOct 4, 2017
  4. Marius PaligaOct 11, 2017
  5. Marius PaligaOct 11, 2017
  6. Stefan BellerOct 11, 2017
  7. Junio C HamanoOct 11, 2017
  8. Junio C HamanoOct 11, 2017
  9. Marius PaligaOct 12, 2017
  10. Marius PaligaOct 12, 2017
  11. Stefan BellerOct 12, 2017
  12. Junio C HamanoOct 13, 2017
  13. Junio C HamanoOct 13, 2017
  14. Marius PaligaOct 13, 2017
  15. Thais D. Braz, Oct 11, 2017
  16. [Outreachy] New git config variable to specify string that will be automatically passed as --push-optionThais D. Braz, Oct 11, 2017
  17. Junio C HamanoOct 12, 2017
  18. Christian CouderOct 12, 2017
  19. Junio C HamanoOct 12, 2017
  20. patch replyThais Diniz, Oct 17, 2017
  21. Junio C HamanoOct 17, 2017
  22. Marius PaligaOct 17, 2017
  23. thais brazOct 17, 2017
  24. [Outreachy] New git config variable to specify string that will be automatically passed as --push-optionThais D. Braz, Oct 11, 2017

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.