Merge branch 'jk/tempfile-ferror-fclose-confusion'
[gitweb.git] / dir.c
diff --git a/dir.c b/dir.c
index 65c3e681b8e04aa47b6cf41faca0822ead59fb6a..4541f9e1460cde7945e2443f2fee5c7df18073f5 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -174,20 +174,19 @@ char *common_prefix(const struct pathspec *pathspec)
 
 int fill_directory(struct dir_struct *dir, const struct pathspec *pathspec)
 {
-       char *prefix;
+       const char *prefix;
        size_t prefix_len;
 
        /*
         * Calculate common prefix for the pathspec, and
         * use that to optimize the directory walk
         */
-       prefix = common_prefix(pathspec);
-       prefix_len = prefix ? strlen(prefix) : 0;
+       prefix_len = common_prefix_len(pathspec);
+       prefix = prefix_len ? pathspec->items[0].match : "";
 
        /* Read the directory and prune it */
        read_directory(dir, prefix, prefix_len, pathspec);
 
-       free(prefix);
        return prefix_len;
 }