From 1d8842d921cc2695f155f4a10904eeffad085c77 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Thu, 14 May 2009 13:22:36 -0700 Subject: Add 'fill_directory()' helper function for directory traversal Most of the users of "read_directory()" actually want a much simpler interface than the whole complex (but rather powerful) one. In fact 'git add' had already largely abstracted out the core interface issues into a private "fill_directory()" function that was largely applicable almost as-is to a number of callers. Yes, 'git add' wants to do some extra work of its own, specific to the add semantics, but we can easily split that out, and use the core as a generic function. This function does exactly that, and now that much simplified 'fill_directory()' function can be shared with a number of callers, while also ensuring that the rather more complex calling conventions of read_directory() are used by fewer call-sites. This also makes the 'common_prefix()' helper function private to dir.c, since all callers are now in that file. Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- builtin-ls-files.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'builtin-ls-files.c') diff --git a/builtin-ls-files.c b/builtin-ls-files.c index 231286660..f47322050 100644 --- a/builtin-ls-files.c +++ b/builtin-ls-files.c @@ -161,12 +161,7 @@ static void show_files(struct dir_struct *dir, const char *prefix) /* For cached/deleted files we don't need to even do the readdir */ if (show_others || show_killed) { - const char *path = ".", *base = ""; - int baselen = prefix_len; - - if (baselen) - path = base = prefix; - read_directory(dir, path, base, baselen, pathspec); + fill_directory(dir, pathspec); if (show_others) show_other_files(dir); if (show_killed) -- cgit v1.2.1