Skip to content

Commit 2b18943

Browse files
René Scharfegitster
authored andcommitted
dir: simplify fill_directory()
Now that read_directory_recursive() (reached through read_directory()) respects the string length limit we provide, we don't need to create a NUL-limited copy of the common prefix anymore. Signed-off-by: Rene Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1528d24 commit 2b18943

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

dir.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,23 +74,16 @@ char *common_prefix(const char **pathspec)
7474

7575
int fill_directory(struct dir_struct *dir, const char **pathspec)
7676
{
77-
const char *path;
7877
size_t len;
7978

8079
/*
8180
* Calculate common prefix for the pathspec, and
8281
* use that to optimize the directory walk
8382
*/
8483
len = common_prefix_len(pathspec);
85-
path = "";
86-
87-
if (len)
88-
path = xmemdupz(*pathspec, len);
8984

9085
/* Read the directory and prune it */
91-
read_directory(dir, path, len, pathspec);
92-
if (*path)
93-
free((char *)path);
86+
read_directory(dir, pathspec ? *pathspec : "", len, pathspec);
9487
return len;
9588
}
9689

0 commit comments

Comments
 (0)