summaryrefslogtreecommitdiffstats
path: root/builtin-rev-parse.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-03-07 21:47:15 +0100
committerJunio C Hamano <gitster@pobox.com>2010-03-07 21:47:15 +0100
commitc2b456b8956c2091318edaee362119e0e96b86b7 (patch)
treedc2fa7fbcc84a8638248cfaaa4b10538efcf5857 /builtin-rev-parse.c
parentMerge branch 'js/runtime-prefix-trace-not-warn' (diff)
parentAdd test for using Git at root of file system (diff)
downloadgit-c2b456b8956c2091318edaee362119e0e96b86b7.tar.xz
git-c2b456b8956c2091318edaee362119e0e96b86b7.zip
Merge branch 'nd/root-git'
* nd/root-git: Add test for using Git at root of file system Support working directory located at root Move offset_1st_component() to path.c init-db, rev-parse --git-dir: do not append redundant slash make_absolute_path(): Do not append redundant slash Conflicts: setup.c sha1_file.c
Diffstat (limited to 'builtin-rev-parse.c')
-rw-r--r--builtin-rev-parse.c4
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")) {