* [Bug] git rev-parse --git-common-dir executed from a sub dir of the main worktree is wrong
@ 2016-03-28 19:43 Mike Rappazzo
2016-03-28 19:57 ` Junio C Hamano
0 siblings, 1 reply; 2+ messages in thread
From: Mike Rappazzo @ 2016-03-28 19:43 UTC (permalink / raw)
To: Git List; +Cc: Junio C Hamano, Nguyễn Thái Ngọc
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 &&
+ 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. I would be willing to code this change, but I didn't
want to start anything that may be considered backwards-incompatible.
This seems related to
[1]http://thread.gmane.org/gmane.comp.version-control.git/286038
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Bug] git rev-parse --git-common-dir executed from a sub dir of the main worktree is wrong
2016-03-28 19:43 [Bug] git rev-parse --git-common-dir executed from a sub dir of the main worktree is wrong Mike Rappazzo
@ 2016-03-28 19:57 ` Junio C Hamano
0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2016-03-28 19:57 UTC (permalink / raw)
To: Mike Rappazzo; +Cc: Git List, Nguyễn Thái Ngọc
Mike Rappazzo <rappazzo@gmail.com> 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.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-03-28 19:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-28 19:43 [Bug] git rev-parse --git-common-dir executed from a sub dir of the main worktree is wrong Mike Rappazzo
2016-03-28 19:57 ` Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).