summaryrefslogtreecommitdiff
path: root/src/path.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/path.c')
-rw-r--r--src/path.c29
1 files changed, 3 insertions, 26 deletions
diff --git a/src/path.c b/src/path.c
index 263cf9e7c..5767faeed 100644
--- a/src/path.c
+++ b/src/path.c
@@ -679,37 +679,14 @@ int git_path_apply_relative(git_buf *target, const char *relpath)
int git_path_cmp(
const char *name1, size_t len1, int isdir1,
- const char *name2, size_t len2, int isdir2)
+ const char *name2, size_t len2, int isdir2,
+ int (*compare)(const char *, const char *, size_t))
{
unsigned char c1, c2;
size_t len = len1 < len2 ? len1 : len2;
int cmp;
- cmp = memcmp(name1, name2, len);
- if (cmp)
- return cmp;
-
- c1 = name1[len];
- c2 = name2[len];
-
- if (c1 == '\0' && isdir1)
- c1 = '/';
-
- if (c2 == '\0' && isdir2)
- c2 = '/';
-
- return (c1 < c2) ? -1 : (c1 > c2) ? 1 : 0;
-}
-
-int git_path_icmp(
- const char *name1, size_t len1, int isdir1,
- const char *name2, size_t len2, int isdir2)
-{
- unsigned char c1, c2;
- size_t len = len1 < len2 ? len1 : len2;
- int cmp;
-
- cmp = strncasecmp(name1, name2, len);
+ cmp = compare(name1, name2, len);
if (cmp)
return cmp;