git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* more concerns about '--git-dir'
@ 2014-05-23 18:41 Pasha Bolokhov
  2014-05-23 19:23 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Pasha Bolokhov @ 2014-05-23 18:41 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: Duy Nguyen, Git Mailing List

        Hi,

        Since at it, I have discovered a couple more minor things with
this rarely-used option. I'm however a bit wary of stepping on
somebody's nerve with this sort of picking things.. :)

        Nevertheless,

1) an apparent missing "normalize_path(git_dir)", when GIT_DIR is an
absolute path:

don't even need to name the repository anything different, but run this command:

$ cd ~/tmp/
$ git init
$ git --git-dir=$HOME/tmp/../tmp/./././.git --work-tree=$HOME/tmp/../tmp/ status

You won't notice anything different in the output of course, but the
environment will be odd:
    GIT_DIR=../tmp/./././.git
    GIT_WORK_TREE=$HOME/tmp
Notice how the work-tree has been normalized and git-dir hasn't. It's
kinda hard to imagine when this can lead to an error, but never know.
Would there be objections to fixing this?


2) "git --git-dir=meta status" complains:

$ git --git-dir=meta init
$ git --git-dir=meta status

yells that work-tree isn't setup and denies to run. I'm sure most
people are aware of this. Yet, the "git-config" man page says that if
--git-dir or GIT_DIR is given then work-tree is assumed to be the
current directory. The difference with the actual behaviour is
explained by the fact that when the repository is not named anything
that ends with ".git" then it is considered a bare repository (if no
--work-tree is given), and the work-tree doesn't get setup and thus
the complaint. It maybe a safety precaution, so that Git doesn't
assume that it's at the top of work-tree while it may be actually
somewhere in the middle. But how is it different if the user runs "git
--git-dir=/opt/sparc/src/.git add sccs.c" while still sitting in the
middle of the tree? I can't judge myself which behaviour would be
right here, and ask for an opinion


    thanks
Pasha

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: more concerns about '--git-dir'
  2014-05-23 18:41 more concerns about '--git-dir' Pasha Bolokhov
@ 2014-05-23 19:23 ` Junio C Hamano
  2014-05-23 23:02   ` Pasha Bolokhov
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2014-05-23 19:23 UTC (permalink / raw)
  To: Pasha Bolokhov; +Cc: Jonathan Nieder, Duy Nguyen, Git Mailing List

Pasha Bolokhov <pasha.bolokhov@gmail.com> writes:

> 1) an apparent missing "normalize_path(git_dir)", when GIT_DIR is an
> absolute path:
>
> don't even need to name the repository anything different, but run this command:
>
> $ cd ~/tmp/
> $ git init
> $ git --git-dir=$HOME/tmp/../tmp/./././.git --work-tree=$HOME/tmp/../tmp/ status
>
> You won't notice anything different in the output of course, but the
> environment will be odd:
>     GIT_DIR=../tmp/./././.git
>     GIT_WORK_TREE=$HOME/tmp
> Notice how the work-tree has been normalized and git-dir hasn't. It's
> kinda hard to imagine when this can lead to an error, but never know.

I think this one is in the "if it hurts, don't do it then"
territory.

> Would there be objections to fixing this?

As long as it can be cleanly done without penalizing sane usage, I
do not think there will be.

> 2) "git --git-dir=meta status" complains:
>
> $ git --git-dir=meta init
> $ git --git-dir=meta status
>
> yells that work-tree isn't setup and denies to run.

Is that because meta/config does not say where the worktree is?

Again, this smells like "if it hurts, don't do it then", even more
so than the previous one.  Does it help if you add --git-work-tree
to the command line, too?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: more concerns about '--git-dir'
  2014-05-23 19:23 ` Junio C Hamano
@ 2014-05-23 23:02   ` Pasha Bolokhov
  0 siblings, 0 replies; 3+ messages in thread
From: Pasha Bolokhov @ 2014-05-23 23:02 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Jonathan Nieder, Duy Nguyen, Git Mailing List

>> You won't notice anything different in the output of course, but the
>> environment will be odd:
>>     GIT_DIR=../tmp/./././.git
>>     GIT_WORK_TREE=$HOME/tmp
>> Notice how the work-tree has been normalized and git-dir hasn't. It's
>> kinda hard to imagine when this can lead to an error, but never know.
>
> I think this one is in the "if it hurts, don't do it then"
> territory.
I just find it inconsistent: one variable is always straightened
("normalized"), while the other one is or is not, depending on
circumstances

>> 2) "git --git-dir=meta status" complains:
>>
>> $ git --git-dir=meta init
>> $ git --git-dir=meta status
>>
>> yells that work-tree isn't setup and denies to run.
>
> Is that because meta/config does not say where the worktree is?
>
> Again, this smells like "if it hurts, don't do it then", even more
> so than the previous one.  Does it help if you add --git-work-tree
> to the command line, too?
I agree this one is on the edge, so wasn't sure. I don't specify
worktree at all, anywhere. And expect Git to guess it to be the
current directory. It does so only if GIT_DIR, whatever it is, ends
with "/.git". What's the logic? When the reader skims through the "man
git-config" page, they'll think that work-tree defaults to "." if no
value was provided. But it's only true if "core.bare" is set to false

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-05-23 23:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-23 18:41 more concerns about '--git-dir' Pasha Bolokhov
2014-05-23 19:23 ` Junio C Hamano
2014-05-23 23:02   ` Pasha Bolokhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).