From: Jonathan Nieder Date: Sat, 30 Oct 2010 07:09:42 GMT Subject: Re: [PATCH 35/42] rev-parse: prints --git-dir relative to user's cwd Message-ID: <20101030070942.GC30613@burratino> In-Reply-To: >> 2010/10/28 Nguyễn Thái Ngọc Duy : >>> git-rev-parse.txt does not say much about this. But I'm sure >>> git-sh-setup.sh wants "git rev-parse --git-dir" be relative to user's >>> cwd. Yes, $(git rev-parse --git-dir) should be relative to the caller's working directory, or else git-sh-setup in the ! "$NONGIT_OK" case will fail, as you noticed. Maybe this can be clarified? The current behavior is often to print an absolute path rather than a ../../etc string, but callers must be ready to accept a relative path, too. The most common output is ".git" (from the toplevel of an ordinary work tree). Signed-off-by: Jonathan Nieder --- diff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt index 4a27643..10321cd 100644 --- a/Documentation/git-rev-parse.txt +++ b/Documentation/git-rev-parse.txt @@ -136,7 +136,12 @@ appending `/{asterisk}`. directory (typically a sequence of "../", or an empty string). --git-dir:: - Show `$GIT_DIR` if defined else show the path to the .git directory. + Show `$GIT_DIR` if defined. Otherwise, show the path to + the .git directory, relative to the current directory. ++ +If `$GIT_DIR` is not defined and the current directory +is not detected to lie in a git repository or work tree, +print a message to stderr and exit with nonzero status. --is-inside-git-dir:: When the current working directory is below the repository