summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authorClemens Buchacher <drizzd@aon.at>2010-05-22 11:13:05 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-05-28 22:02:50 (GMT)
commit490544b1282416a033dc25481db205248ac0bfc8 (patch)
treec577a1d7844e2a39bcf2ba5577ad1bba9b1a08f9 /dir.c
parente498257d650529812ffe1872b3cd62e2bd604287 (diff)
downloadgit-490544b1282416a033dc25481db205248ac0bfc8.zip
git-490544b1282416a033dc25481db205248ac0bfc8.tar.gz
git-490544b1282416a033dc25481db205248ac0bfc8.tar.bz2
get_cwd_relative(): do not misinterpret suffix as subdirectory
If the current working directory is the same as the work tree path plus a suffix, e.g. 'work' and 'work-xyz', then the suffix '-xyz' would be interpreted as a subdirectory of 'work'. Signed-off-by: Clemens Buchacher <drizzd@aon.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/dir.c b/dir.c
index cb83332..5615f33 100644
--- a/dir.c
+++ b/dir.c
@@ -958,9 +958,14 @@ char *get_relative_cwd(char *buffer, int size, const char *dir)
}
if (*dir)
return NULL;
- if (*cwd == '/')
+ switch (*cwd) {
+ case '\0':
+ return cwd;
+ case '/':
return cwd + 1;
- return cwd;
+ default:
+ return NULL;
+ }
}
int is_inside_dir(const char *dir)