Skip to content

Commit

Permalink
dir: simplify fill_directory()
Browse files Browse the repository at this point in the history
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 <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
René Scharfe authored and gitster committed May 11, 2012
1 parent 1528d24 commit 2b18943
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions dir.c
Expand Up @@ -74,23 +74,16 @@ char *common_prefix(const char **pathspec)

int fill_directory(struct dir_struct *dir, const char **pathspec)
{
const char *path;
size_t len;

/*
* Calculate common prefix for the pathspec, and
* use that to optimize the directory walk
*/
len = common_prefix_len(pathspec);
path = "";

if (len)
path = xmemdupz(*pathspec, len);

/* Read the directory and prune it */
read_directory(dir, path, len, pathspec);
if (*path)
free((char *)path);
read_directory(dir, pathspec ? *pathspec : "", len, pathspec);
return len;
}

Expand Down

0 comments on commit 2b18943

Please sign in to comment.