summaryrefslogtreecommitdiff
path: root/path.c
diff options
context:
space:
mode:
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>2008-03-02 07:40:33 +0000
committerJunio C Hamano <gitster@pobox.com>2008-03-02 01:58:31 -0800
commite371a4c648e72673fcfdf0b45192857dd149e2f5 (patch)
tree3c2e809b09ef02641e13880fc4491614f7c35275 /path.c
parent2b459b483cb264d3e9a39cd7857da2ccab08179f (diff)
downloadgit-e371a4c648e72673fcfdf0b45192857dd149e2f5.tar.gz
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>
Diffstat (limited to 'path.c')
-rw-r--r--path.c4
1 files changed, 3 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) {