summaryrefslogtreecommitdiff
path: root/builtin/rev-parse.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2016-02-12 11:31:45 +0700
committerJunio C Hamano <gitster@pobox.com>2016-02-12 16:01:47 -0800
commit17f1365dbce9aa00cab3f196e7fa7138d9081eef (patch)
tree8d66e92d668049ec01b4d970d8fcc0506e0b1b99 /builtin/rev-parse.c
parent754884255bb580df159e58defa81cdd30b5c430c (diff)
downloadgit-17f1365dbce9aa00cab3f196e7fa7138d9081eef.tar.gz
rev-parse: take prefix into account in --git-common-dirnd/git-common-dir-fix
Most of the time, get_git_common_dir() returns an absolute path so prefix is irrelevant. If it returns a relative path (e.g. from the main worktree) then prefixing is required. Noticed-by: Mike Hommey <mh@glandium.org> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/rev-parse.c')
-rw-r--r--builtin/rev-parse.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index 7e074aad40..7a4f2c0b0c 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -763,7 +763,8 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
continue;
}
if (!strcmp(arg, "--git-common-dir")) {
- puts(get_git_common_dir());
+ const char *pfx = prefix ? prefix : "";
+ puts(prefix_filename(pfx, strlen(pfx), get_git_common_dir()));
continue;
}
if (!strcmp(arg, "--resolve-git-dir")) {