diff options
author | Johannes Schindelin <Johannes.Schindelin@gmx.de> | 2008-03-02 07:40:33 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-03-02 01:58:31 -0800 |
commit | e371a4c648e72673fcfdf0b45192857dd149e2f5 (patch) | |
tree | 3c2e809b09ef02641e13880fc4491614f7c35275 | |
parent | diff: make sure work tree side is shown as 0{40} when different (diff) | |
download | tgif-e371a4c648e72673fcfdf0b45192857dd149e2f5.tar.xz |
Fix make_absolute_path() for parameters without a slash
When passing "xyz" to make_absolute_path(), make_absolute_path()
erroneously tried to chdir("xyz"), and then append "/xyz". Instead,
skip the chdir() completely when no slash was found.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | path.c | 4 | ||||
-rwxr-xr-x | t/t0000-basic.sh | 2 |
2 files changed, 5 insertions, 1 deletions
@@ -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)" |