aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-01-19 08:25:31 -0800
committerJunio C Hamano <gitster@pobox.com>2011-01-19 08:25:31 -0800
commit0bc6180bcbe6bd821ac8cf2178cb13ff628b4f69 (patch)
treed9078d1b4e6b0263851e00314f7172f1178952ed
parent3f142468997f9d14d8051a96b2e9db265d41ac0d (diff)
parentfbbb4e19bee8c4d62f274f9e07b91c45e4df838c (diff)
downloadgit-0bc6180bcbe6bd821ac8cf2178cb13ff628b4f69.tar.gz
git-0bc6180bcbe6bd821ac8cf2178cb13ff628b4f69.tar.xz
Merge branch 'nd/maint-relative' into maint
* 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 b2dfb69eb..b68750450 100644
--- a/dir.c
+++ b/dir.c
@@ -965,6 +965,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;
}
}