diff options
| author | Junio C Hamano <gitster@pobox.com> | 2011-12-13 22:02:51 -0800 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2011-12-13 22:02:51 -0800 |
| commit | df6246ed78d040f06f095dd62d8db07a0aa19a96 (patch) | |
| tree | cf9da0c48aa9450471d5c09a659cc99a1d3e1159 /dir.c | |
| parent | 8311158c66e0d83df950ea837fb1cb332c51f798 (diff) | |
| parent | ea4f9685cb432caf357ad8af56a91877b6d04663 (diff) | |
| download | git-df6246ed78d040f06f095dd62d8db07a0aa19a96.tar.xz | |
Merge branch 'nd/misc-cleanups' into maint
* nd/misc-cleanups:
unpack_object_header_buffer(): clear the size field upon error
tree_entry_interesting: make use of local pointer "item"
tree_entry_interesting(): give meaningful names to return values
read_directory_recursive: reduce one indentation level
get_tree_entry(): do not call find_tree_entry() on an empty tree
tree-walk.c: do not leak internal structure in tree_entry_len()
Diffstat (limited to 'dir.c')
| -rw-r--r-- | dir.c | 48 |
1 files changed, 24 insertions, 24 deletions
@@ -968,34 +968,34 @@ static int read_directory_recursive(struct dir_struct *dir, { DIR *fdir = opendir(*base ? base : "."); int contents = 0; + struct dirent *de; + char path[PATH_MAX + 1]; - if (fdir) { - struct dirent *de; - char path[PATH_MAX + 1]; - memcpy(path, base, baselen); + if (!fdir) + return 0; - while ((de = readdir(fdir)) != NULL) { - int len; - switch (treat_path(dir, de, path, sizeof(path), - baselen, simplify, &len)) { - case path_recurse: - contents += read_directory_recursive - (dir, path, len, 0, simplify); - continue; - case path_ignored: - continue; - case path_handled: - break; - } - contents++; - if (check_only) - goto exit_early; - else - dir_add_name(dir, path, len); + memcpy(path, base, baselen); + + while ((de = readdir(fdir)) != NULL) { + int len; + switch (treat_path(dir, de, path, sizeof(path), + baselen, simplify, &len)) { + case path_recurse: + contents += read_directory_recursive(dir, path, len, 0, simplify); + continue; + case path_ignored: + continue; + case path_handled: + break; } -exit_early: - closedir(fdir); + contents++; + if (check_only) + goto exit_early; + else + dir_add_name(dir, path, len); } +exit_early: + closedir(fdir); return contents; } |
