Re: GIT_DIR in aliases [Re: Spurious GIT_DIR set when in a worktree [was Re: Nested submodule status bug]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Feb 27, 2020 at 04:50:57PM +0100, Damien Robert wrote:

> So one might argue that the behaviour I observed is not a bug, but it is
> still surprising for me (as a user), and maybe this could be stated more
> clearly in the docs?
> 
> Furthermore there is a question of consistency. GIT_DIR will not always be set
> before running a shell alias. Looking at `setup_discovered_git_dir`, it will
> be set if we are in a bare dir, or core.worktree / WORK_TREE is set, or if
> we have a gitfile.

We were discussing the same issue recently with regards to hooks. See:

  https://lore.kernel.org/git/20200130102933.GE840531@xxxxxxxxxxxxxxxxxxxxxxx/

and the responses. I think we could do better, but at the cost of
breaking a relatively obscure git-clone feature.

> The annoying side effect is that I cannot use as an alias a command that
> iterate over submodules and run git commands inside them, because in this
> alias GIT_DIR will be set sometimes, and sometimes not (a quick fix would be to
> unset GIT_DIR in my alias).

Yes, the recommended thing is to make sure GIT_DIR is unset if you're
going to chdir around and expect auto-discovery of the repository to
work.

Note there are other variables you might want to unset, too, if you're
switching repositories. Doing:

  unset $(git rev-parse --local-env-vars)

would cover the full list.

-Peff



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux