git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 28, 2016, 19:57 UTC
Message-ID
<xmqqk2kmxtmn.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<CANoM8SU4ZWA=f1TSmNbHDBut7ox6cCVoi3K37GEmjHvygw1odg@mail.gmail.com>
Mike Rappazzo <rappazzo@gmail.com> writes:
Show 15 quoted lines
> 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.

Show 8 quoted lines
> + 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.
Previous: Mike Rappazzo
Message 2 of 2 in “[Bug] git rev-parse --git-common-dir executed from a sub dir of the main worktree is wrong”
  1. Mike RappazzoMar 28, 2016
  2. Junio C HamanoMar 28, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.