Files
git/compat/basename.c
Johannes Schindelin 560b1947ca Refactor skipping DOS drive prefixes
Junio Hamano pointed out that there is an implicit assumption in pretty
much all the code calling has_dos_drive_prefix(): it assumes 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.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-01-28 09:51:59 +01:00

14 lines
268 B
C

#include "../git-compat-util.h"
/* Adapted from libiberty's basename.c. */
char *gitbasename (char *path)
{
const char *base;
skip_dos_drive_prefix(&path);
for (base = path; *path; path++) {
if (is_dir_sep(*path))
base = path + 1;
}
return (char *)base;
}