diff options
| author | Junio C Hamano <gitster@pobox.com> | 2021-05-20 08:54:58 +0900 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2021-05-20 08:54:59 +0900 |
| commit | 33be431c0c7284c1adf0fe49f7838dbc8aee6ea9 (patch) | |
| tree | ce7b37182ebe1c89b0d9d4f5ced18e514e60c09d /worktree.c | |
| parent | 2e2ed74be03993706d467e4b8e785afeb5f173d9 (diff) | |
| parent | b548f0f1568f6b01e55ca69c24d3cb19489f92aa (diff) | |
| download | git-33be431c0c7284c1adf0fe49f7838dbc8aee6ea9.tar.gz | |
Merge branch 'en/dir-traversal'
"git clean" and "git ls-files -i" had confusion around working on
or showing ignored paths inside an ignored directory, which has
been corrected.
* en/dir-traversal:
dir: introduce readdir_skip_dot_and_dotdot() helper
dir: update stale description of treat_directory()
dir: traverse into untracked directories if they may have ignored subfiles
dir: avoid unnecessary traversal into ignored directory
t3001, t7300: add testcase showcasing missed directory traversal
t7300: add testcase showing unnecessary traversal into ignored directory
ls-files: error out on -i unless -o or -c are specified
dir: report number of visited directories and paths with trace2
dir: convert trace calls to trace2 equivalents
Diffstat (limited to 'worktree.c')
| -rw-r--r-- | worktree.c | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/worktree.c b/worktree.c index f35ac40a84..237517baee 100644 --- a/worktree.c +++ b/worktree.c @@ -128,10 +128,8 @@ struct worktree **get_worktrees(void) dir = opendir(path.buf); strbuf_release(&path); if (dir) { - while ((d = readdir(dir)) != NULL) { + while ((d = readdir_skip_dot_and_dotdot(dir)) != NULL) { struct worktree *linked = NULL; - if (is_dot_or_dotdot(d->d_name)) - continue; if ((linked = get_linked_worktree(d->d_name))) { ALLOC_GROW(list, counter + 1, alloc); @@ -486,13 +484,9 @@ int submodule_uses_worktrees(const char *path) if (!dir) return 0; - while ((d = readdir(dir)) != NULL) { - if (is_dot_or_dotdot(d->d_name)) - continue; - + d = readdir_skip_dot_and_dotdot(dir); + if (d != NULL) ret = 1; - break; - } closedir(dir); return ret; } |
