summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4133fd2)
raw | patch | inline | side by side (parent: 4133fd2)
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | |
Sun, 14 Feb 2010 15:44:41 +0000 (22:44 +0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 14 Feb 2010 21:21:31 +0000 (13:21 -0800) |
When concatenating two paths, if the first one already have '/', do
not put another '/' in between the two paths.
Usually this is not the case as getcwd() won't return '/foo/bar/',
except when you are standing at root, then it will return '/'.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
not put another '/' in between the two paths.
Usually this is not the case as getcwd() won't return '/foo/bar/',
except when you are standing at root, then it will return '/'.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
abspath.c | patch | blob | history |
diff --git a/abspath.c b/abspath.c
index b88122cbe73ec0c438e2d375fdebd51e5febf9ae..c91a29cb298a3ad792ff8745f3e8e0eb28d71678 100644 (file)
--- a/abspath.c
+++ b/abspath.c
if (len + strlen(last_elem) + 2 > PATH_MAX)
die ("Too long path name: '%s/%s'",
buf, last_elem);
- buf[len] = '/';
- strcpy(buf + len + 1, last_elem);
+ if (len && buf[len-1] != '/')
+ buf[len++] = '/';
+ strcpy(buf + len, last_elem);
free(last_elem);
last_elem = NULL;
}