summaryrefslogtreecommitdiffstats
path: root/abspath.c
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2012-09-07 00:41:03 +0200
committerJunio C Hamano <gitster@pobox.com>2012-09-06 16:19:58 -0700
commitf4c21e89d7c6b578140e90c02b40eccb51ab8428 (patch)
tree263d364a4ad03fd1def55d38d392f047224b511b /abspath.c
parent7bcf48dad83e7a07f27403c2ce9e5c29af9e317d (diff)
downloadgit-f4c21e89d7c6b578140e90c02b40eccb51ab8428.tar.gz
git-f4c21e89d7c6b578140e90c02b40eccb51ab8428.tar.xz
real_path(): properly handle nonexistent top-level paths
The change has two points: 1. Do not strip off a leading slash, because that erroneously turns an absolute path into a relative path. 2. Do not remove slashes from groups of multiple slashes; instead let chdir() handle them. It could be, for example, that it wants to leave leading double-slashes alone. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'abspath.c')
-rw-r--r--abspath.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/abspath.c b/abspath.c
index 3e8325c73..05f2d7934 100644
--- a/abspath.c
+++ b/abspath.c
@@ -45,8 +45,8 @@ const char *real_path(const char *path)
if (!is_directory(buf)) {
char *last_slash = find_last_dir_sep(buf);
if (last_slash) {
- *last_slash = '\0';
last_elem = xstrdup(last_slash + 1);
+ last_slash[1] = '\0';
} else {
last_elem = xstrdup(buf);
*buf = '\0';