When git_dir is relative, it is relative to Git's current working directory, which is worktree top directory. "git rev-parse --git-dir" is expected to output relative to user's current working directory. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> --- builtin/rev-parse.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c index 8fbf9d0..8819e8a 100644 --- a/builtin/rev-parse.c +++ b/builtin/rev-parse.c @@ -646,6 +646,14 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix) static char cwd[PATH_MAX]; int len; if (gitdir) { + if (prefix && !is_absolute_path(gitdir)) { + int len; + if (!getcwd(cwd, PATH_MAX)) + die_errno("unable to get current working directory"); + len = strlen(cwd); + printf("%s%s%s\n", cwd, len && cwd[len-1] != '/' ? "/" : "", gitdir); + continue; + } puts(gitdir); continue; } -- 1.7.0.1.384.g6abcaa -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html