threads / discuss / 46880

What means "git config bla ~/"?

Subject: What means "git config bla ~/"?

## tl;dr

6 messages between Oct 2, 2017 and Oct 4, 2017.

replies: 5people: 5as markdown or json

rpjday@crashcourse.ca· Oct 2, 2017, 10:13 UTC · lore
   i'm sure i'm about to embarrass myself but, in "man git-config",  
OPTIONS, one reads:
   --path
   git-config will expand leading ~ to the value of $HOME, and ~user  
to the   home directory for the specified user. This option has no  
effect when setting the value (but you can use git config bla ~/ from  
the command line to let your shell do the expansion).
   what's with that "git config bla ~/"? is this some config keyword  
or something?
rday
René Scharfe· Oct 2, 2017, 14:06 UTC · re: rpjday@crashcourse.ca · lore

Re: What means "git config bla ~/"?

[When I try to reply to rpjday@crashcourse.ca then my SMTP server
 says "Requested action not taken: mailbox unavailable
 invalid DNS MX or A/AAAA resource record.", so I'm replying only
 to the list.]
Am 02.10.2017 um 12:13 schrieb rpjday@crashcourse.ca:
Show 12 quoted lines
> i'm sure i'm about to embarrass myself but, in "man git-config",
> OPTIONS, one reads:
> 
> --path
> 
> git-config will expand leading ~ to the value of $HOME, and ~user to
> the   home directory for the specified user. This option has no
> effect when setting the value (but you can use git config bla ~/ from
> the command line to let your shell do the expansion).
> 
> what's with that "git config bla ~/"? is this some config keyword or
> something?

"bla" represents any configuration option that you want to change. It is not literally a keyword recognized by git config. You could replace it with "foo", if that helps.

The comment in parentheses reminds readers that shells like bash do tilde expansion for command line arguments. Consider the following command:

	$ git config format.outputDirectory ~/patches

Your shell rewrites "~/patches" to "/home/rpjday/patches" (or similar, depending on your user name and home directory) before actually executing git config. So even though git config doesn't expand ~ in option values you'll still get a result like this afterwards:

	$ git config format.outputDirectory
	/home/rpjday/patches
René
Jonathan Nieder· Oct 2, 2017, 17:13 UTC · re: rpjday@crashcourse.ca · lore

Re: What means "git config bla ~/"?

Hi,
rpjday@crashcourse.ca wrote:
Show 12 quoted lines
> i'm sure i'm about to embarrass myself but, in "man git-config",
> OPTIONS, one reads:
>
>   --path
>
> git-config will expand leading ~ to the value of $HOME, and ~user
> to the   home directory for the specified user. This option has no
> effect when setting the value (but you can use git config bla ~/
> from the command line to let your shell do the expansion).
>
> what's with that "git config bla ~/"? is this some config keyword
> or something?

No need to be embarrased. Here "bla" is a placeholder. That is, for example, I can run

	git config --global include.path ~/.config/git/more-config
or
	git config --global include.path $HOME/.config/git/more-config
to cause
	[include]
		path = /home/me/.config/git/more-config

to be added to my global configuration. The expansion of ~ or $HOME is performed by my shell, not Git. For comparison, if I had run

	git config --global include.path '~/.config/git/more-config'
then that would cause
	[include]
		path = ~/.config/git/more-config

to be added to my global configuration, but it would still have the same effect at run time, since Git is also able to expand ~ to my home directory.

The wording comes from
	commit 1349484e341a3ec2ba02a86c8fbd97ea9dc8c756
	Author: Matthieu Moy <Matthieu.Moy@imag.fr>
	Date:   Wed Dec 30 17:51:53 2009 +0100
	    builtin-config: add --path option doing ~ and ~user expansion.

I agree with you that it is less clear than it could be. Ideas for clarifying it?

Thanks, Jonathan

Junio C Hamano· Oct 3, 2017, 00:08 UTC · re: Jonathan Nieder · lore

Re: What means "git config bla ~/"?

Jonathan Nieder <jrnieder@gmail.com> writes:
Show 6 quoted lines
>> what's with that "git config bla ~/"? is this some config keyword
>> or something?
> ...
>
> I agree with you that it is less clear than it could be.  Ideas for
> clarifying it?
Yeah, if it were
	git config section.var ~/some/thing

that would be far clearer than "bla" that what we see is a mere placeholder.

Another obvious option is to remove the parenthetical comment.

Or "(but you can give values without quoting and let your shell expand it)", without a confusing sample command that proved not to help very much.

Matthieu Moy· Oct 3, 2017, 11:45 UTC · re: Junio C Hamano · lore

Re: What means "git config bla ~/"?

"Junio C Hamano" <gitster@pobox.com> writes:
Show 15 quoted lines
> Jonathan Nieder <jrnieder@gmail.com> writes:
> 
>>> what's with that "git config bla ~/"? is this some config keyword
>>> or something?
>> ...
>>
>> I agree with you that it is less clear than it could be.  Ideas for
>> clarifying it?
> 
> Yeah, if it were
> 
>	git config section.var ~/some/thing
> 
> that would be far clearer than "bla" that what we see is a mere
> placeholder.
Agreed.
Show 5 quoted lines
> Another obvious option is to remove the parenthetical comment.
> 
> Or "(but you can give values without quoting and let your shell
> expand it)", without a confusing sample command that proved not to
> help very much.
I prefer your "section.var" proposal above. I think people who really understand shell quoting do not need the explanations, and others probably need the example.
While we're there, the formatting is also wrong ('' quoting, while we normally use `` quoting for shell commands).
Sounds like a nice microproject for my students :-). A patch should follow soon.
-- 
Matthieu Moy
https://matthieu-moy.fr/
Junio C Hamano· Oct 4, 2017, 04:01 UTC · re: Matthieu Moy · lore

Re: What means "git config bla ~/"?

Matthieu Moy <git@matthieu-moy.fr> writes:
Show 15 quoted lines
> "Junio C Hamano" <gitster@pobox.com> writes:
>
>> Jonathan Nieder <jrnieder@gmail.com> writes:
>> 
>>>> what's with that "git config bla ~/"? is this some config keyword
>>>> or something?
>>> ...
>>	git config section.var ~/some/thing
>> ...
>
> I prefer your "section.var" proposal above. I think people who really understand shell quoting do not need the explanations, and others probably need the example.
>
> While we're there, the formatting is also wrong ('' quoting, while we normally use `` quoting for shell commands).
>
> Sounds like a nice microproject for my students :-). A patch should follow soon.
OK, thanks.  Lest we forget, this is #leftoverbits for now.

← back to recent threads