All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael J Gruber <git@drmicha.warpmail.net>
To: Jeff King <peff@peff.net>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: GIT_DIR vs. --git-dir
Date: Mon, 24 Sep 2012 16:54:58 +0200	[thread overview]
Message-ID: <50607442.3040906@drmicha.warpmail.net> (raw)
In-Reply-To: <20120924144929.GA10349@sigill.intra.peff.net>

Jeff King venit, vidit, dixit 24.09.2012 16:49:
> On Mon, Sep 24, 2012 at 09:19:27AM +0200, Michael J Gruber wrote:
> 
>> [mjg@localhost ~]$ GIT_DIR=~/.githome git rev-parse --show-toplevel
>> /home/mjg
>>
>> [mjg@localhost ~]$ git --git-dir=~/.githome rev-parse --show-toplevel
>> fatal: Not a git repository: '~/.githome'
>>
>> Huh? Ok, so most users probably would not try further and blame git, but:
>>
>> [mjg@localhost ~]$ git --git-dir=/home/mjg/.githome rev-parse
>> --show-toplevel
>> /home/mjg
>>
>> (All this is with core.worktree set to /home/mjg.)
>>
>> So, while I do understand that we don't expand '~' in any of these cases
>> and it's only a matter of bash tilde expansion kicking in or not, we
>> might want to do something about it. (--git-dir=$HOME/.githome gets
>> expanded, as well, and --git-dir=.githome works from the appropriate cwd
>> only).
> 
> Bash is even weirder than you might think. Try this:
> 
>   $ echo ~/foo
>   /home/peff/foo
> 
>   $ echo arg=~/foo
>   arg=/home/peff/foo
> 
>   $ echo --arg=~/foo
>   --arg=~/foo
> 
> That is, it expands on the right-hand side of an "=" (which, from my
> reading of the bash manual, means it considers it a word split), but
> refuses to expand after an "=" that is part of a long option.
> 
> The first one is definitely correct. It would be convenient for your use
> case to expand the third one, and it logically follows from the second
> one. However, dash does not expand the second one. I'm not sure if this
> is a bug in bash, or simply a grey area where the two shells do not
> agree.
> 
> But it makes me wonder if the world would be better served by a bash
> option to always enable tilde expansion after an "=". That would solve
> your issue, and it would make the same feature work for every other git
> long option, as well as for other programs.

Yes, in some sense this is working around a bash "feature". I don't
really care too much personally.

Note that we also have "git -c "config.var=value" which, again "works"
because we expand config vars.

So, technically there are no surprises if you know the shell's expansion
rules. But still...

Michael

  reply	other threads:[~2012-09-24 14:55 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-24  7:19 GIT_DIR vs. --git-dir Michael J Gruber
2012-09-24  7:41 ` Nguyen Thai Ngoc Duy
2012-09-24  7:57   ` Michael J Gruber
2012-09-24  9:53     ` Nguyen Thai Ngoc Duy
2012-09-24 12:56       ` Michael J Gruber
2012-09-24 12:57         ` [RFC/PATCH] git: expand user path in --git-dir Michael J Gruber
2012-09-24 14:52           ` Jeff King
2012-09-24 14:57             ` Michael J Gruber
2012-09-24 17:30           ` Junio C Hamano
2012-09-25  5:33           ` Jan Engelhardt
2012-09-25  7:27             ` Michael J Gruber
2012-09-24 13:37         ` GIT_DIR vs. --git-dir Andreas Schwab
2012-09-24 14:36   ` Junio C Hamano
2012-09-24 14:51     ` Michael J Gruber
2012-09-24 14:49 ` Jeff King
2012-09-24 14:54   ` Michael J Gruber [this message]
2012-09-24 15:42   ` Andreas Schwab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50607442.3040906@drmicha.warpmail.net \
    --to=git@drmicha.warpmail.net \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.