{"thread":{"id":"41846","subject":"[Bug] git rev-parse --git-common-dir executed from a sub dir of the main worktree is wrong","startedAt":"2016-03-28T19:43:59Z","lastAt":"2016-03-28T19:57:52Z","messageCount":2,"participants":["Mike Rappazzo","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"281983","messageId":"CANoM8SU4ZWA=f1TSmNbHDBut7ox6cCVoi3K37GEmjHvygw1odg@mail.gmail.com","threadId":"41846","inReplyTo":null,"subject":"[Bug] git rev-parse --git-common-dir executed from a sub dir of the main worktree is wrong","fromName":"Mike Rappazzo","fromEmail":"rappazzo@gmail.com","sentAt":"2016-03-28T19:43:59Z","receivedAt":"2016-03-28T19:43:59Z","isPatch":false,"sender":{"key":"rappazzo@gmail.com","avatar":"https://avatars.githubusercontent.com/u/525287?v=4"},"body":"I found a case where it seems that the result of `git rev-parse\n--git-common-dir` is incorrect.  If you execute the command from\nwithin a subdirectory in the main worktree, it returns the path from\nthe root of the worktree to the current dir + \"/.git\".  (As a\nrefresher, running this command from the root of the worktree returns\n\".git\").\n\nI wrote a quick test to demonstrate the problem:\n\n\n+test_expect_success 'git-common-dir inside sub-dir' '\n+   (\n+ mkdir -p path/to/child &&\n+ cd path/to/child &&\n+ echo \"$(git rev-parse --show-toplevel)/.git\" >expected &&\n+ git rev-parse --git-common-dir >actual &&\n+ test_cmp expected actual\n+ )\n+'\n+\n\nI suggest that we change the result of this call to _always_ return an\nabsolute path.  I would be willing to code this change, but I didn't\nwant to start anything that may be considered backwards-incompatible.\n\nThis seems related to\n[1]http://thread.gmane.org/gmane.comp.version-control.git/286038\n"},{"id":"281984","messageId":"xmqqk2kmxtmn.fsf@gitster.mtv.corp.google.com","threadId":"41846","inReplyTo":"CANoM8SU4ZWA=f1TSmNbHDBut7ox6cCVoi3K37GEmjHvygw1odg@mail.gmail.com","subject":"Re: [Bug] git rev-parse --git-common-dir executed from a sub dir of the main worktree is wrong","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-03-28T19:57:52Z","receivedAt":"2016-03-28T19:57:52Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Mike Rappazzo <rappazzo@gmail.com> writes:\n\n> I found a case where it seems that the result of `git rev-parse\n> --git-common-dir` is incorrect.  If you execute the command from\n> within a subdirectory in the main worktree, it returns the path from\n> the root of the worktree to the current dir + \"/.git\".  (As a\n> refresher, running this command from the root of the worktree returns\n> \".git\").\n>\n> I wrote a quick test to demonstrate the problem:\n>\n>\n> +test_expect_success 'git-common-dir inside sub-dir' '\n> +   (\n> + mkdir -p path/to/child &&\n> + cd path/to/child &&\n> + echo \"$(git rev-parse --show-toplevel)/.git\" >expected &&\n\n... or\n\n    \"$(git rev-parse --show-cdup).git >expect\n\ni.e. to use relative path, just like the case where you start from\nthe top.\n\n> + git rev-parse --git-common-dir >actual &&\n> + test_cmp expected actual\n> + )\n> +'\n> +\n>\n> I suggest that we change the result of this call to _always_ return an\n> absolute path.\n"}]}