summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-06-01 12:45:08 -0700
committerJunio C Hamano <gitster@pobox.com>2015-06-01 12:45:08 -0700
commitf93a3937877386af5d870b68db20d2ff27e3e41e (patch)
treece6b33c108e5bd47148ab080f55d80ebdfb64a6f
parent77bd3ea9f54f1584147b594abc04c26ca516d987 (diff)
parent838d6a928fc3aef3827d9a45e6aac044fea7451e (diff)
downloadgit-f93a3937877386af5d870b68db20d2ff27e3e41e.tar.gz
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
-rw-r--r--builtin/clean.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/builtin/clean.c b/builtin/clean.c
index 98c103fa8b..ada0196c9e 100644
--- a/builtin/clean.c
+++ b/builtin/clean.c
@@ -941,15 +941,15 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
if (!cache_name_is_other(ent->name, ent->len))
continue;
- if (lstat(ent->name, &st))
- die_errno("Cannot lstat '%s'", ent->name);
-
if (pathspec.nr)
matches = dir_path_match(ent, &pathspec, 0, NULL);
if (pathspec.nr && !matches)
continue;
+ if (lstat(ent->name, &st))
+ die_errno("Cannot lstat '%s'", ent->name);
+
if (S_ISDIR(st.st_mode) && !remove_directories &&
matches != MATCHED_EXACTLY)
continue;