Web lists-archives.com

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

Marius Paliga <marius.paliga@xxxxxxxxx> writes:

> +    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

		defaultPushOption = foo
		defaultPushOption = bar

and then you write in your .git/config something like

		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

You may want to do something like that in this code.