summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-06-16 14:33:46 -0700
committerJunio C Hamano <gitster@pobox.com>2015-06-16 14:33:46 -0700
commit6b2c0ead061b1bb9ce8e4b539da495ea0ef057b5 (patch)
tree9678b679f36a40abfb331c9c7a07ffc0b24e4261
parentb76b4cd4f1d822686374c5fdeb68ab0aac28bff1 (diff)
parent838d6a928fc3aef3827d9a45e6aac044fea7451e (diff)
downloadgit-6b2c0ead061b1bb9ce8e4b539da495ea0ef057b5.tar.gz
Merge branch 'dt/clean-pathspec-filter-then-lstat' into maint
"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;