handle_alias() inside .git dir

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

 



It seems that using any aliases while inside a .git dir will end up setting the work tree to the current dir, even though it's clearly not a work tree. This means that having an alias like `git config alias.st = status` and running `git st` inside a .git dir will proceed to spit out a listing that claims that every file in the project is missing rather than displaying an error about not being in a work tree like `git status` will show.

This happens because setup_git_directory_gently() ends up setting GIT_DIR_ENVIRONMENT to "." if it detects that we are in the .git directory, and then a subsequent call to setup_git_directory() calls setup_git_directory_gently() again, which sees the GIT_DIR_ENVIRONMENT and ends up calling set_work_tree(). The comment to set_work_tree() says it's only called if GIT_DIR is set and calls what it does "old behavior". I assume it exists for some sort of backwards compatibility, but in quick testing simply commenting out line 266 of setup.c (the call to set_work_tree) makes `git st` work as expected. I'm not sure if this will have any adverse effect on anything else. Does anybody know if this will cause problems?

Another option that seems like it should work is checking if we're a bare repo, and if not then setting the work tree to our parent dir, assuming any relevant config values or env variables aren't set that would point elsewhere. I would try and implement this but after looking at it for a few minutes, I fear 4AM is not the best of times to try and figure out how this code works.

-Kevin Ballard

--
Kevin Ballard
http://kevin.sb.org
kevin@xxxxxx
http://www.tildesoft.com


<<attachment: smime.p7s>>


[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