consolidate pathspec_prefix and common_prefix
[gitweb.git] / setup.c
diff --git a/setup.c b/setup.c
index 013ad1127534367e64afeec3749e617ceccfb5d4..70b887fe683b4fa72d20066c42a50b7ca34bc458 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -264,6 +264,13 @@ const char **get_pathspec(const char *prefix, const char **pathspec)
        return pathspec;
 }
 
+char *pathspec_prefix(const char **pathspec)
+{
+       size_t len = common_prefix_len(pathspec);
+
+       return len ? xmemdupz(*pathspec, len) : NULL;
+}
+
 /*
  * Test if it looks like we're at a git directory.
  * We want to see:
@@ -382,7 +389,7 @@ const char *read_gitfile_gently(const char *path)
        const char *slash;
        struct stat st;
        int fd;
-       size_t len;
+       ssize_t len;
 
        if (stat(path, &st))
                return NULL;