aboutsummaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-12-16 12:49:48 -0800
committerJunio C Hamano <gitster@pobox.com>2010-12-16 12:49:48 -0800
commit20cb8e202520173727f3ea060e1eca035b32e2b7 (patch)
tree0f7b8b7168c108c9cfb09793fa06db5c49c9883e /dir.c
parentb720c75afde3d813588fdfc84f762ef947f5587a (diff)
parentfbbb4e19bee8c4d62f274f9e07b91c45e4df838c (diff)
downloadgit-20cb8e202520173727f3ea060e1eca035b32e2b7.tar.gz
git-20cb8e202520173727f3ea060e1eca035b32e2b7.tar.xz
Merge branch 'nd/maint-relative'
* nd/maint-relative: get_cwd_relative(): do not misinterpret root path
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/dir.c b/dir.c
index 852e60f2a..38f3e3eb9 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;
}
}