Skip to content

Commit f93a393

Browse files
committed
Merge branch 'dt/clean-pathspec-filter-then-lstat'
"git clean pathspec..." tried to lstat(2) and complain even for paths outside the given pathspec. * dt/clean-pathspec-filter-then-lstat: clean: only lstat files in pathspec
2 parents 77bd3ea + 838d6a9 commit f93a393

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

builtin/clean.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -941,15 +941,15 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
941941
if (!cache_name_is_other(ent->name, ent->len))
942942
continue;
943943

944-
if (lstat(ent->name, &st))
945-
die_errno("Cannot lstat '%s'", ent->name);
946-
947944
if (pathspec.nr)
948945
matches = dir_path_match(ent, &pathspec, 0, NULL);
949946

950947
if (pathspec.nr && !matches)
951948
continue;
952949

950+
if (lstat(ent->name, &st))
951+
die_errno("Cannot lstat '%s'", ent->name);
952+
953953
if (S_ISDIR(st.st_mode) && !remove_directories &&
954954
matches != MATCHED_EXACTLY)
955955
continue;

0 commit comments

Comments
 (0)