consolidate pathspec_prefix and common_prefix
[gitweb.git] / setup.c
diff --git a/setup.c b/setup.c
index ce87900ce3c68ace0f231827bdda0e9a65ef15b3..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: