Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [Bug] git rev-parse --git-common-dir executed from a sub dir of the main worktree is wrong

From: Junio C Hamano <hidden>
Date: 2016-06-15 23:09:04

Mike Rappazzo [off-list ref] writes:
I found a case where it seems that the result of `git rev-parse
--git-common-dir` is incorrect.  If you execute the command from
within a subdirectory in the main worktree, it returns the path from
the root of the worktree to the current dir + "/.git".  (As a
refresher, running this command from the root of the worktree returns
".git").

I wrote a quick test to demonstrate the problem:


+test_expect_success 'git-common-dir inside sub-dir' '
+   (
+ mkdir -p path/to/child &&
+ cd path/to/child &&
+ echo "$(git rev-parse --show-toplevel)/.git" >expected &&
... or

    "$(git rev-parse --show-cdup).git >expect

i.e. to use relative path, just like the case where you start from
the top.
+ git rev-parse --git-common-dir >actual &&
+ test_cmp expected actual
+ )
+'
+

I suggest that we change the result of this call to _always_ return an
absolute path.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help