diff options
author | Junio C Hamano <gitster@pobox.com> | 2020-04-30 02:15:30 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-04-30 02:15:31 +0300 |
commit | 6eacc39b6d2508b6a7522902330c29714c99f5f2 (patch) | |
tree | eb45e53464fed0f3251b6e81d4ea39fc87df3e65 /builtin/stash.c | |
parent | 48eee46d6accbb6ef491f811fd9a9c72843d469b (diff) | |
parent | c0af173a136785b3cfad4bd414b2fb10a130760a (diff) |
Merge branch 'en/fill-directory-exponential'
The directory traversal code had redundant recursive calls which
made its performance characteristics exponential with respect to
the depth of the tree, which was corrected.
* en/fill-directory-exponential:
completion: fix 'git add' on paths under an untracked directory
Fix error-prone fill_directory() API; make it only return matches
dir: replace double pathspec matching with single in treat_directory()
dir: include DIR_KEEP_UNTRACKED_CONTENTS handling in treat_directory()
dir: replace exponential algorithm with a linear one
dir: refactor treat_directory to clarify control flow
dir: fix confusion based on variable tense
dir: fix broken comment
dir: consolidate treat_path() and treat_one_path()
dir: fix simple typo in comment
t3000: add more testcases testing a variety of ls-files issues
t7063: more thorough status checking
Diffstat (limited to 'builtin/stash.c')
-rw-r--r-- | builtin/stash.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/builtin/stash.c b/builtin/stash.c index a43a92ec74..0c52a3b849 100644 --- a/builtin/stash.c +++ b/builtin/stash.c @@ -861,30 +861,23 @@ static int get_untracked_files(const struct pathspec *ps, int include_untracked, struct strbuf *untracked_files) { int i; - int max_len; int found = 0; - char *seen; struct dir_struct dir; memset(&dir, 0, sizeof(dir)); if (include_untracked != INCLUDE_ALL_FILES) setup_standard_excludes(&dir); - seen = xcalloc(ps->nr, 1); - - max_len = fill_directory(&dir, the_repository->index, ps); + fill_directory(&dir, the_repository->index, ps); for (i = 0; i < dir.nr; i++) { struct dir_entry *ent = dir.entries[i]; - if (dir_path_match(&the_index, ent, ps, max_len, seen)) { - found++; - strbuf_addstr(untracked_files, ent->name); - /* NUL-terminate: will be fed to update-index -z */ - strbuf_addch(untracked_files, '\0'); - } + found++; + strbuf_addstr(untracked_files, ent->name); + /* NUL-terminate: will be fed to update-index -z */ + strbuf_addch(untracked_files, '\0'); free(ent); } - free(seen); free(dir.entries); free(dir.ignored); clear_directory(&dir); |