{"thread":{"id":"36743","subject":"more concerns about '--git-dir'","startedAt":"2014-05-23T18:41:15Z","lastAt":"2014-05-23T23:02:15Z","messageCount":3,"participants":["Pasha Bolokhov","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"242591","messageId":"CAKpPgvf_UfgtOkotPz+aF4=UqQTOmk0O8tXg4Cm3zjzFimUoHw@mail.gmail.com","threadId":"36743","inReplyTo":null,"subject":"more concerns about '--git-dir'","fromName":"Pasha Bolokhov","fromEmail":"pasha.bolokhov@gmail.com","sentAt":"2014-05-23T18:41:15Z","receivedAt":"2014-05-23T18:41:15Z","isPatch":false,"sender":{"key":"pasha.bolokhov@gmail.com","avatar":null},"body":"        Hi,\n\n        Since at it, I have discovered a couple more minor things with\nthis rarely-used option. I'm however a bit wary of stepping on\nsomebody's nerve with this sort of picking things.. :)\n\n        Nevertheless,\n\n1) an apparent missing \"normalize_path(git_dir)\", when GIT_DIR is an\nabsolute path:\n\ndon't even need to name the repository anything different, but run this command:\n\n$ cd ~/tmp/\n$ git init\n$ git --git-dir=$HOME/tmp/../tmp/./././.git --work-tree=$HOME/tmp/../tmp/ status\n\nYou won't notice anything different in the output of course, but the\nenvironment will be odd:\n    GIT_DIR=../tmp/./././.git\n    GIT_WORK_TREE=$HOME/tmp\nNotice how the work-tree has been normalized and git-dir hasn't. It's\nkinda hard to imagine when this can lead to an error, but never know.\nWould there be objections to fixing this?\n\n\n2) \"git --git-dir=meta status\" complains:\n\n$ git --git-dir=meta init\n$ git --git-dir=meta status\n\nyells that work-tree isn't setup and denies to run. I'm sure most\npeople are aware of this. Yet, the \"git-config\" man page says that if\n--git-dir or GIT_DIR is given then work-tree is assumed to be the\ncurrent directory. The difference with the actual behaviour is\nexplained by the fact that when the repository is not named anything\nthat ends with \".git\" then it is considered a bare repository (if no\n--work-tree is given), and the work-tree doesn't get setup and thus\nthe complaint. It maybe a safety precaution, so that Git doesn't\nassume that it's at the top of work-tree while it may be actually\nsomewhere in the middle. But how is it different if the user runs \"git\n--git-dir=/opt/sparc/src/.git add sccs.c\" while still sitting in the\nmiddle of the tree? I can't judge myself which behaviour would be\nright here, and ask for an opinion\n\n\n    thanks\nPasha\n"},{"id":"242596","messageId":"xmqq1tvkjo4c.fsf@gitster.dls.corp.google.com","threadId":"36743","inReplyTo":"CAKpPgvf_UfgtOkotPz+aF4=UqQTOmk0O8tXg4Cm3zjzFimUoHw@mail.gmail.com","subject":"Re: more concerns about '--git-dir'","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-05-23T19:23:15Z","receivedAt":"2014-05-23T19:23:15Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pasha Bolokhov <pasha.bolokhov@gmail.com> writes:\n\n> 1) an apparent missing \"normalize_path(git_dir)\", when GIT_DIR is an\n> absolute path:\n>\n> don't even need to name the repository anything different, but run this command:\n>\n> $ cd ~/tmp/\n> $ git init\n> $ git --git-dir=$HOME/tmp/../tmp/./././.git --work-tree=$HOME/tmp/../tmp/ status\n>\n> You won't notice anything different in the output of course, but the\n> environment will be odd:\n>     GIT_DIR=../tmp/./././.git\n>     GIT_WORK_TREE=$HOME/tmp\n> Notice how the work-tree has been normalized and git-dir hasn't. It's\n> kinda hard to imagine when this can lead to an error, but never know.\n\nI think this one is in the \"if it hurts, don't do it then\"\nterritory.\n\n> Would there be objections to fixing this?\n\nAs long as it can be cleanly done without penalizing sane usage, I\ndo not think there will be.\n\n> 2) \"git --git-dir=meta status\" complains:\n>\n> $ git --git-dir=meta init\n> $ git --git-dir=meta status\n>\n> yells that work-tree isn't setup and denies to run.\n\nIs that because meta/config does not say where the worktree is?\n\nAgain, this smells like \"if it hurts, don't do it then\", even more\nso than the previous one.  Does it help if you add --git-work-tree\nto the command line, too?\n"},{"id":"242626","messageId":"CAKpPgvcwVuvOqAE-SvECsCfPHMJr0qBaqz9DCOXQSAZj1903jQ@mail.gmail.com","threadId":"36743","inReplyTo":"xmqq1tvkjo4c.fsf@gitster.dls.corp.google.com","subject":"Re: more concerns about '--git-dir'","fromName":"Pasha Bolokhov","fromEmail":"pasha.bolokhov@gmail.com","sentAt":"2014-05-23T23:02:15Z","receivedAt":"2014-05-23T23:02:15Z","isPatch":false,"sender":{"key":"pasha.bolokhov@gmail.com","avatar":null},"body":">> You won't notice anything different in the output of course, but the\n>> environment will be odd:\n>>     GIT_DIR=../tmp/./././.git\n>>     GIT_WORK_TREE=$HOME/tmp\n>> Notice how the work-tree has been normalized and git-dir hasn't. It's\n>> kinda hard to imagine when this can lead to an error, but never know.\n>\n> I think this one is in the \"if it hurts, don't do it then\"\n> territory.\nI just find it inconsistent: one variable is always straightened\n(\"normalized\"), while the other one is or is not, depending on\ncircumstances\n\n>> 2) \"git --git-dir=meta status\" complains:\n>>\n>> $ git --git-dir=meta init\n>> $ git --git-dir=meta status\n>>\n>> yells that work-tree isn't setup and denies to run.\n>\n> Is that because meta/config does not say where the worktree is?\n>\n> Again, this smells like \"if it hurts, don't do it then\", even more\n> so than the previous one.  Does it help if you add --git-work-tree\n> to the command line, too?\nI agree this one is on the edge, so wasn't sure. I don't specify\nworktree at all, anywhere. And expect Git to guess it to be the\ncurrent directory. It does so only if GIT_DIR, whatever it is, ends\nwith \"/.git\". What's the logic? When the reader skims through the \"man\ngit-config\" page, they'll think that work-tree defaults to \".\" if no\nvalue was provided. But it's only true if \"core.bare\" is set to false\n"}]}