threads / patch / 36924

patchdoc git: multivar configuration parameters append to existing values

Subject: [PATCH] doc git: multivar configuration parameters append to existing values

## tl;dr

8 messages between Jun 16, 2014 and Jun 17, 2014. Diffs are folded; open one to read it.

replies: 7people: 4as markdown or json

Philip Oakley· Jun 16, 2014, 12:49 UTC · lore

When the '-c' option is used to pass alternate URLs or similar multivar parameters to git commands the effect is not what the user expected [1,2].

Clarify that multivar configuration parameters do not supercede previous values. Suggest an alternative style parameter.

[1] http://article.gmane.org/gmane.comp.version-control.git/250427 [2] http://article.gmane.org/gmane.comp.version-control.git/251529

Signed-off-by: Philip Oakley <philipoakley@iee.org>
---
 Documentation/git.txt | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
Show changes to Documentation/git.txt +4 −1
diff --git a/Documentation/git.txt b/Documentation/git.txt
index 3bd68b0..bedbd76 100644
--- a/Documentation/git.txt
+++ b/Documentation/git.txt
@@ -440,7 +440,10 @@ example the following invocations are equivalent:
 
 -c <name>=<value>::
 	Pass a configuration parameter to the command. The value
-	given will override values from configuration files.
+	given will override single valued variables from configuration
+	files, and append to multivar variables. Previous multivar values
+	remain in effect. Use "insteadOf" style config variables when an
+	over-ride is needed.
 	The <name> is expected in the same format as listed by
 	'git config' (subkeys separated by dots).
 
-- 
1.9.4.msysgit.0
Tanay Abhra· Jun 16, 2014, 18:35 UTC · re: Philip Oakley · lore

Re: [PATCH] doc git: multivar configuration parameters append to existing values

On 06/16/2014 05:49 AM, Philip Oakley wrote:
>  	Pass a configuration parameter to the command. The value
> -	given will override values from configuration files.
> +	given will override single valued variables from configuration
> +	files, and append to multivar variables. Previous multivar values
Nit: Forgive me if I am wrong, but `, and` is used for joining two independent
clauses. It would be better to drop the comma.
Show 6 quoted lines
> +	remain in effect. Use "insteadOf" style config variables when an
> +	over-ride is needed.
>  	The <name> is expected in the same format as listed by
>  	'git config' (subkeys separated by dots).
>  
> 

'insteadOf' is a very specific approach for a general suggestion because it is only used in url.*.insteadof in the whole codebase. Also, it has a variation described in urls.txt as "pushinsteadof". So, if a problem such as mentioned above arises in a different scenario 'insteadOf' cannot be used in it.

Philip Oakley· Jun 16, 2014, 19:42 UTC · re: Tanay Abhra · lore

Re: [PATCH] doc git: multivar configuration parameters append to existing values

From: "Tanay Abhra" <tanayabh@gmail.com>
Show 10 quoted lines
> On 06/16/2014 05:49 AM, Philip Oakley wrote:
>
>>  Pass a configuration parameter to the command. The value
>> - given will override values from configuration files.
>> + given will override single valued variables from configuration
>> + files, and append to multivar variables. Previous multivar values
>
> Nit: Forgive me if I am wrong, but `, and` is used for joining two 
> independent
> clauses. It would be better to drop the comma.

I just wrote it in my local style ;-) I was sort of treating them as independent, but see Junio's comments in a similar vein.

Show 15 quoted lines
>
>> + remain in effect. Use "insteadOf" style config variables when an
>> + over-ride is needed.
>>  The <name> is expected in the same format as listed by
>>  'git config' (subkeys separated by dots).
>>
>>
>
> 'insteadOf' is a very specific approach for a general suggestion 
> because it is only
> used in url.*.insteadof in the whole codebase. Also, it has a 
> variation described in
> urls.txt as "pushinsteadof". So, if a problem such as mentioned above 
> arises in
> a different scenario 'insteadOf' cannot be used in it.

I was using it as a suggestion for the user's 'go look for an alternative' step (i.e. that there may be an alternative!)

-- Philip

Junio C Hamano· Jun 16, 2014, 18:43 UTC · re: Philip Oakley · lore

Re: [PATCH] doc git: multivar configuration parameters append to existing values

Philip Oakley <philipoakley@iee.org> writes:
Show 30 quoted lines
> When the '-c' option is used to pass alternate URLs or similar
> multivar parameters to git commands the effect is not what the user
> expected [1,2].
>
> Clarify that multivar configuration parameters do not supercede
> previous values. Suggest an alternative style parameter.
>
> [1] http://article.gmane.org/gmane.comp.version-control.git/250427
> [2] http://article.gmane.org/gmane.comp.version-control.git/251529
>
> Signed-off-by: Philip Oakley <philipoakley@iee.org>
> ---
>  Documentation/git.txt | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/git.txt b/Documentation/git.txt
> index 3bd68b0..bedbd76 100644
> --- a/Documentation/git.txt
> +++ b/Documentation/git.txt
> @@ -440,7 +440,10 @@ example the following invocations are equivalent:
>  
>  -c <name>=<value>::
>  	Pass a configuration parameter to the command. The value
> -	given will override values from configuration files.
> +	given will override single valued variables from configuration
> +	files, and append to multivar variables. Previous multivar values
> +	remain in effect. Use "insteadOf" style config variables when an
> +	over-ride is needed.
>  	The <name> is expected in the same format as listed by
>  	'git config' (subkeys separated by dots).

I have two doubts, while appreciating the overall direction to clarify things very much.

 * "single overrides, multiple appends" is not a wrong explanation
   per-se, but sounds like an arbitrary rule that forces people to
   memorize.  I wonder if it makes it less burdensome for readers if
   we just said "Git acts as if the given configuration is specified
   at the very end of the configuration files"---once the reader
   understands that Git reads all configuration varilables of the
   same name and the code paths that *use* one of them pick the one
   defined the last, it is easy to realize that "single overrides"
   is merely a natural consequence of the appending nature of "-c".
 * The last sentence added, i.e. "insteadof"-style, will not be
   understood by any reader other than those who tried to use "-c"
   on remote.*.url variables and does not belong here.  A better
   way/place to give that information is needed.
Philip Oakley· Jun 16, 2014, 19:38 UTC · re: Junio C Hamano · lore

Re: [PATCH] doc git: multivar configuration parameters append to existing values

From: "Junio C Hamano" <gitster@pobox.com>
Show 40 quoted lines
> Philip Oakley <philipoakley@iee.org> writes:
>
>> When the '-c' option is used to pass alternate URLs or similar
>> multivar parameters to git commands the effect is not what the user
>> expected [1,2].
>>
>> Clarify that multivar configuration parameters do not supercede
>> previous values. Suggest an alternative style parameter.
>>
>> [1] http://article.gmane.org/gmane.comp.version-control.git/250427
>> [2] http://article.gmane.org/gmane.comp.version-control.git/251529
>>
>> Signed-off-by: Philip Oakley <philipoakley@iee.org>
>> ---
>>  Documentation/git.txt | 5 ++++-
>>  1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/Documentation/git.txt b/Documentation/git.txt
>> index 3bd68b0..bedbd76 100644
>> --- a/Documentation/git.txt
>> +++ b/Documentation/git.txt
>> @@ -440,7 +440,10 @@ example the following invocations are 
>> equivalent:
>>
>>  -c <name>=<value>::
>>  Pass a configuration parameter to the command. The value
>> - given will override values from configuration files.
>> + given will override single valued variables from configuration
>> + files, and append to multivar variables. Previous multivar values
>> + remain in effect. Use "insteadOf" style config variables when an
>> + over-ride is needed.
>>  The <name> is expected in the same format as listed by
>>  'git config' (subkeys separated by dots).
>
> I have two doubts, while appreciating the overall direction to
> clarify things very much.
>
> * "single overrides, multiple appends" is not a wrong explanation
>   per-se, but sounds like an arbitrary rule that forces people to
>   memorize.

At the time it felt like the most compact method of informing the reader.

>                  I wonder if it makes it less burdensome for readers 
> if
>   we just said "Git acts as if the given configuration is specified
>   at the very end of the configuration files"
I'd started with something like that..
Show 5 quoted lines
>                                                                   ---once 
> the reader
>   understands that Git reads all configuration varilables of the
>   same name and the code paths that *use* one of them pick the one
>   defined the last,

It's this step that's a concern. We shouldn't be forcing the reader to implicitly grok that, especially as we don't actually say it elsewhere (in the regular documentation).

>                              it is easy to realize that "single 
> overrides"
>   is merely a natural consequence of the appending nature of "-c".
Perhaps I should just say that [say it that way].
Show 5 quoted lines
>
> * The last sentence added, i.e. "insteadof"-style, will not be
>   understood by any reader other than those who tried to use "-c"
>   on remote.*.url variables and does not belong here.  A better
>   way/place to give that information is needed.

I just wanted to indicate that some multivars do have get-out [override] config parameters, though we aren't consistent about their names yet, while giving a clue as to a typical name style.

It would also be good to get feedback from Robert and Ævar on whether the text would actually be informative to them, as they took the time to report the original 'conceptual breakage'.

Philip 
Junio C Hamano· Jun 16, 2014, 21:10 UTC · re: Philip Oakley · lore

Re: [PATCH] doc git: multivar configuration parameters append to existing values

"Philip Oakley" <philipoakley@iee.org> writes:
Show 8 quoted lines
>>                                                                   ---once 
>> the reader
>>   understands that Git reads all configuration varilables of the
>>   same name and the code paths that *use* one of them pick the one
>>   defined the last,
> It's this step that's a concern. We shouldn't be forcing the reader to 
> implicitly grok that, especially as we don't actually say it elsewhere 
> (in the regular documentation).

I think that is what I was driving at. If we do not tell the reader that, perhaps we should and everything else will fall as natural consequence of that understanding.

Show 8 quoted lines
>> * The last sentence added, i.e. "insteadof"-style, will not be
>>   understood by any reader other than those who tried to use "-c"
>>   on remote.*.url variables and does not belong here.  A better
>>   way/place to give that information is needed.
>
> I just wanted to indicate that some multivars do have get-out [override] 
> config parameters, though we aren't consistent about their names yet, 
> while giving a clue as to a typical name style.

I think those who tried "-c remote.*.url" would be helped better by having a see-also in the documentation on "remote.*.url" that refers them to "insteadOf" noting that "remote.*.url" is a multi-value variable and appending different definition will not make "the last one wins". After all "-c" is merely *one* way to append.

The next person who gets confused may say "I added remote.origin.url at the end of my $repo/.git/config expecting that the value to be used"; the answer would be the same "the variable is multi-valued; adding a new value is not the right way to futz with it. You either need to replace, or if you do not want to replace, use insteadOf".

That is the second reason why the mention of insteadOf does not belong to the description of "-c var=value".

Perhaps something like this as a starting point?
 Documentation/config.txt | 11 +++++++++++
 1 file changed, 11 insertions(+)
Show changes to Documentation/config.txt +11 −0
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 1d718bd..357cc02 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -2108,6 +2108,13 @@ remote.pushdefault::
 remote.<name>.url::
 	The URL of a remote repository.  See linkgit:git-fetch[1] or
 	linkgit:git-push[1].
++
+Note that this variable is multi-valued (e.g. "git push there" with
+multiple `remote.there.url` will push to all the named repositories),
+and does not follow the "last-one-survives" rule.  When you want to
+temporarily redirect a push to somewhere else, see `url.<base>.insteadOf`;
+you cannot use "git -c remote.<name>.url=<temporary URL> push", because
+you will be pushing to both the configured place and the temporary place.
 
 remote.<name>.pushurl::
 	The push URL of a remote repository.  See linkgit:git-push[1].
@@ -2419,6 +2426,10 @@ url.<base>.insteadOf::
 	the best alternative for the particular user, even for a
 	never-before-seen repository on the site.  When more than one
 	insteadOf strings match a given URL, the longest match is used.
++
+When you want to redirect a push to `$URL` (e.g. `site.xz:myrepo`) 
+temporarily to somewhere else (e.g. `othersite.xz:myrepo`), you can
+use "git -c url.othersite.xz:myrepo.insteadOf=site.xz:myrepo push ..."
 
 url.<base>.pushInsteadOf::
 	Any URL that starts with this value will not be pushed to;
Philip Oakley· Jun 17, 2014, 22:03 UTC · re: Junio C Hamano · lore

Re: [PATCH] doc git: multivar configuration parameters append to existing values

From: "Junio C Hamano" <gitster@pobox.com>
Show 44 quoted lines
> "Philip Oakley" <philipoakley@iee.org> writes:
>
>>>                                                                   ---once
>>> the reader
>>>   understands that Git reads all configuration varilables of the
>>>   same name and the code paths that *use* one of them pick the one
>>>   defined the last,
>> It's this step that's a concern. We shouldn't be forcing the reader
>> to
>> implicitly grok that, especially as we don't actually say it
>> elsewhere
>> (in the regular documentation).
>
> I think that is what I was driving at.  If we do not tell the reader
> that, perhaps we should and everything else will fall as natural
> consequence of that understanding.
>
>>> * The last sentence added, i.e. "insteadof"-style, will not be
>>>   understood by any reader other than those who tried to use "-c"
>>>   on remote.*.url variables and does not belong here.  A better
>>>   way/place to give that information is needed.
>>
>> I just wanted to indicate that some multivars do have get-out
>> [override]
>> config parameters, though we aren't consistent about their names yet,
>> while giving a clue as to a typical name style.
>
> I think those who tried "-c remote.*.url" would be helped better by
> having a see-also in the documentation on "remote.*.url" that refers
> them to "insteadOf" noting that "remote.*.url" is a multi-value
> variable and appending different definition will not make "the last
> one wins".  After all "-c" is merely *one* way to append.
>
> The next person who gets confused may say "I added remote.origin.url
> at the end of my $repo/.git/config expecting that the value to be
> used"; the answer would be the same "the variable is multi-valued;
> adding a new value is not the right way to futz with it.  You either
> need to replace, or if you do not want to replace, use insteadOf".
>
> That is the second reason why the mention of insteadOf does not
> belong to the description of "-c var=value".
>
> Perhaps something like this as a starting point?
>

Yes, that's a good start, but we still need the correction to the git(1) '-c' option text.

It'll be a few days before I can get back to this.
Show 38 quoted lines
> Documentation/config.txt | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/Documentation/config.txt b/Documentation/config.txt
> index 1d718bd..357cc02 100644
> --- a/Documentation/config.txt
> +++ b/Documentation/config.txt
> @@ -2108,6 +2108,13 @@ remote.pushdefault::
> remote.<name>.url::
>  The URL of a remote repository.  See linkgit:git-fetch[1] or
>  linkgit:git-push[1].
> ++
> +Note that this variable is multi-valued (e.g. "git push there" with
> +multiple `remote.there.url` will push to all the named repositories),
> +and does not follow the "last-one-survives" rule.  When you want to
> +temporarily redirect a push to somewhere else, see
> `url.<base>.insteadOf`;
> +you cannot use "git -c remote.<name>.url=<temporary URL> push",
> because
> +you will be pushing to both the configured place and the temporary
> place.
>
> remote.<name>.pushurl::
>  The push URL of a remote repository.  See linkgit:git-push[1].
> @@ -2419,6 +2426,10 @@ url.<base>.insteadOf::
>  the best alternative for the particular user, even for a
>  never-before-seen repository on the site.  When more than one
>  insteadOf strings match a given URL, the longest match is used.
> ++
> +When you want to redirect a push to `$URL` (e.g. `site.xz:myrepo`)
> +temporarily to somewhere else (e.g. `othersite.xz:myrepo`), you can
> +use "git -c url.othersite.xz:myrepo.insteadOf=site.xz:myrepo push
> ..."
>
> url.<base>.pushInsteadOf::
>  Any URL that starts with this value will not be pushed to;
>
>

-- Philip

Jeff King· Jun 16, 2014, 19:48 UTC · re: Junio C Hamano · lore

Re: [PATCH] doc git: multivar configuration parameters append to existing values

On Mon, Jun 16, 2014 at 11:43:32AM -0700, Junio C Hamano wrote:
Show 12 quoted lines
> I have two doubts, while appreciating the overall direction to
> clarify things very much.
> 
>  * "single overrides, multiple appends" is not a wrong explanation
>    per-se, but sounds like an arbitrary rule that forces people to
>    memorize.  I wonder if it makes it less burdensome for readers if
>    we just said "Git acts as if the given configuration is specified
>    at the very end of the configuration files"---once the reader
>    understands that Git reads all configuration varilables of the
>    same name and the code paths that *use* one of them pick the one
>    defined the last, it is easy to realize that "single overrides"
>    is merely a natural consequence of the appending nature of "-c".

Yeah, I think the problem is really not one of "-c" in particular. If you did:

  git config --system remote.magic.url some-default

to provide a universal alias for the "magic" remote, you could not override it via ~/.gitconfig or .git/config, for the same reasons.

I think we need a better discussion of multivar versus "normal" overridable variables in config.txt, and then "-c" can make a note that this is a potential issue, and refer readers to the right section.

I also think it would be nice to have a syntax to "reset" multivars to their initial state (both from config files and from "-c"). Their inability to be overridden is one of the reasons we have so few of them.

>  * The last sentence added, i.e. "insteadof"-style, will not be
>    understood by any reader other than those who tried to use "-c"
>    on remote.*.url variables and does not belong here.  A better
>    way/place to give that information is needed.

Agreed. I think that could go in the discussion I mentioned above (as "some variables have other mechanisms to accomplish the same thing, like..."). But if we learned a mechanism for resetting multivars, such workarounds would not be needed at all.

-Peff

← back to recent threads