summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--path.c4
-rwxr-xr-xt/t0000-basic.sh2
2 files changed, 5 insertions, 1 deletions
diff --git a/path.c b/path.c
index 42609524a5..af2716199b 100644
--- a/path.c
+++ b/path.c
@@ -311,8 +311,10 @@ const char *make_absolute_path(const char *path)
if (last_slash) {
*last_slash = '\0';
last_elem = xstrdup(last_slash + 1);
- } else
+ } else {
last_elem = xstrdup(buf);
+ *buf = '\0';
+ }
}
if (*buf) {
diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index 92de088227..27b54cbb12 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -304,6 +304,8 @@ test_expect_success 'absolute path works as expected' '
test "$dir" = "$(test-absolute-path $dir2)" &&
file="$dir"/index &&
test "$file" = "$(test-absolute-path $dir2/index)" &&
+ basename=blub &&
+ test "$dir/$basename" = $(cd .git && test-absolute-path $basename) &&
ln -s ../first/file .git/syml &&
sym="$(cd first; pwd -P)"/file &&
test "$sym" = "$(test-absolute-path $dir2/syml)"