Re: [PATCH 35/42] rev-parse: prints --git-dir relative to user's cwd
- From
Jonathan Nieder <jrnieder@gmail.com>
- Date
- Oct 30, 2010, 07:09 UTC
- Message-ID
- <20101030070942.GC30613@burratino>
- In-Reply-To
- <AANLkTinircf2H9GcqOym036o=av1dvNx9xDVOVXok6xt@mail.gmail.com>
>> 2010/10/28 Nguyễn Thái Ngọc Duy <pclouds@gmail.com>:
>>> 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 <jrnieder@gmail.com> ---
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