summaryrefslogtreecommitdiff
path: root/abspath.c
diff options
context:
space:
mode:
authorTheo Niessink <theo@taletn.com>2011-05-27 16:00:39 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-05-27 17:59:16 (GMT)
commitd1c69255a1014ccaeb9841f2114e20f048556391 (patch)
treecf14af796f23230e0f2cbda339e4bc7074c1c7d1 /abspath.c
parent88135203af9df27c0f9c76c27bbbf48833bb31c8 (diff)
downloadgit-d1c69255a1014ccaeb9841f2114e20f048556391.zip
git-d1c69255a1014ccaeb9841f2114e20f048556391.tar.gz
git-d1c69255a1014ccaeb9841f2114e20f048556391.tar.bz2
real_path: do not assume '/' is the path seperator
real_path currently assumes it's input had '/' as path seperator. This assumption does not hold true for the code-path from prefix_path (on Windows), where real_path can be called before normalize_path_copy. Fix real_path so it doesn't make this assumption. Create a helper function to reverse-search for the last path-seperator in a string. Signed-off-by: Theo Niessink <theo@taletn.com> Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'abspath.c')
-rw-r--r--abspath.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/abspath.c b/abspath.c
index ff14068..5489900 100644
--- a/abspath.c
+++ b/abspath.c
@@ -33,7 +33,7 @@ const char *make_absolute_path(const char *path)
while (depth--) {
if (!is_directory(buf)) {
- char *last_slash = strrchr(buf, '/');
+ char *last_slash = find_last_dir_sep(buf);
if (last_slash) {
*last_slash = '\0';
last_elem = xstrdup(last_slash + 1);
@@ -58,7 +58,7 @@ const char *make_absolute_path(const char *path)
if (len + strlen(last_elem) + 2 > PATH_MAX)
die ("Too long path name: '%s/%s'",
buf, last_elem);
- if (len && buf[len-1] != '/')
+ if (len && !is_dir_sep(buf[len-1]))
buf[len++] = '/';
strcpy(buf + len, last_elem);
free(last_elem);