Subject: Re: [PATCH 35/42] rev-parse: prints --git-dir relative to user's cwd

From: Jonathan Nieder <[email-masked]>
Date: Sat, 30 Oct 2010 02:09:42 -0500

>> 2010/10/28 Nguyễn Thái Ngọc Duy <[email-masked]>:

>>> 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 <[email-masked]>
---
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