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.