aboutsummaryrefslogtreecommitdiff
path: root/compat/basename.c
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2016-01-12 08:57:22 +0100
committerJunio C Hamano <gitster@pobox.com>2016-01-12 10:39:40 -0800
commit2f36eed936f70105e80681aafac645ff34acc667 (patch)
tree5a226a4147e6f56a021d0492b713c39907a7b4da /compat/basename.c
parent833e48259e23aea76f3765d28d1b2200332301f7 (diff)
downloadgit-2f36eed936f70105e80681aafac645ff34acc667.tar.gz
git-2f36eed936f70105e80681aafac645ff34acc667.tar.xz
Refactor skipping DOS drive prefixes
Junio noticed that there is an implicit assumption in pretty much all the code calling has_dos_drive_prefix(): it forces all of its callsites to hardcode the knowledge that the DOS drive prefix is always two bytes long. While this assumption is pretty safe, we can still make the code more readable and less error-prone by introducing a function that skips the DOS drive prefix safely. While at it, we change the has_dos_drive_prefix() return value: it now returns the number of bytes to be skipped if there is a DOS drive prefix. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'compat/basename.c')
-rw-r--r--compat/basename.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/compat/basename.c b/compat/basename.c
index d8f8a3c6d..9f00421a2 100644
--- a/compat/basename.c
+++ b/compat/basename.c
@@ -4,9 +4,7 @@
char *gitbasename (char *path)
{
const char *base;
- /* Skip over the disk name in MSDOS pathnames. */
- if (has_dos_drive_prefix(path))
- path += 2;
+ skip_dos_drive_prefix(&path);
for (base = path; *path; path++) {
if (is_dir_sep(*path))
base = path + 1;