From: Junio C Hamano Date: Wed, 22 Dec 2010 01:56:12 GMT Subject: Re: [PATCH 36/47] rev-parse: prints --git-dir relative to user's cwd Message-ID: <7vvd2m605f.fsf@alter.siamese.dyndns.org> In-Reply-To: <1290785563-15339-37-git-send-email-pclouds@gmail.com> Nguyễn Thái Ngọc Duy writes: > git_dir variable in environment.c is relative to git's cwd, not user's > cwd. Convert the relative path (actualy by making it absolute path) > before printing out. > > Signed-off-by: Nguyễn Thái Ngọc Duy > Signed-off-by: Junio C Hamano > --- > builtin/rev-parse.c | 6 +++++- > 1 files changed, 5 insertions(+), 1 deletions(-) > > diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c > index a5a1c86..65c287b 100644 > --- a/builtin/rev-parse.c > +++ b/builtin/rev-parse.c > @@ -647,7 +647,11 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix) > static char cwd[PATH_MAX]; > int len; > if (gitdir) { > - puts(gitdir); > + if (is_absolute_path(gitdir) || !prefix) { > + puts(gitdir); > + continue; > + } > + puts(make_absolute_path(gitdir)); > continue; > } > if (!prefix) { I do not quite understand this change. I can obtain GIT_DIR in a relative form without this patch already: $ cd t/ $ git --git-dir=../.git rev-parse --git-dir HEAD ../.git c7511731675da8b50c0d5243aa04a98c8a5ee316 Could we please have a new test case to demonstrate what is broken without this patch?