summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-12-16 20:49:48 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-12-16 20:49:48 (GMT)
commit20cb8e202520173727f3ea060e1eca035b32e2b7 (patch)
tree0f7b8b7168c108c9cfb09793fa06db5c49c9883e
parentb720c75afde3d813588fdfc84f762ef947f5587a (diff)
parentfbbb4e19bee8c4d62f274f9e07b91c45e4df838c (diff)
downloadgit-20cb8e202520173727f3ea060e1eca035b32e2b7.zip
git-20cb8e202520173727f3ea060e1eca035b32e2b7.tar.gz
git-20cb8e202520173727f3ea060e1eca035b32e2b7.tar.bz2
Merge branch 'nd/maint-relative'
* nd/maint-relative: get_cwd_relative(): do not misinterpret root path
-rw-r--r--dir.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/dir.c b/dir.c
index 852e60f..38f3e3e 100644
--- a/dir.c
+++ b/dir.c
@@ -1033,6 +1033,12 @@ char *get_relative_cwd(char *buffer, int size, const char *dir)
case '/':
return cwd + 1;
default:
+ /*
+ * dir can end with a path separator when it's root
+ * directory. Return proper prefix in that case.
+ */
+ if (dir[-1] == '/')
+ return cwd;
return NULL;
}
}