diff options
Diffstat (limited to 'builtin-rev-parse.c')
-rw-r--r-- | builtin-rev-parse.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/builtin-rev-parse.c b/builtin-rev-parse.c index a8c5043ded..88bad9af3c 100644 --- a/builtin-rev-parse.c +++ b/builtin-rev-parse.c @@ -637,6 +637,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix) if (!strcmp(arg, "--git-dir")) { const char *gitdir = getenv(GIT_DIR_ENVIRONMENT); static char cwd[PATH_MAX]; + int len; if (gitdir) { puts(gitdir); continue; @@ -647,7 +648,8 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix) } if (!getcwd(cwd, PATH_MAX)) die_errno("unable to get current working directory"); - printf("%s/.git\n", cwd); + len = strlen(cwd); + printf("%s%s.git\n", cwd, len && cwd[len-1] != '/' ? "/" : ""); continue; } if (!strcmp(arg, "--is-inside-git-dir")) { |