summaryrefslogtreecommitdiff
path: root/builtin/clean.c
diff options
context:
space:
mode:
authorDavid Turner <dturner@twopensource.com>2015-05-18 18:08:46 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-05-18 21:04:15 (GMT)
commit838d6a928fc3aef3827d9a45e6aac044fea7451e (patch)
treef64afc9d14ae6cabf55d946765600071eddea6f0 /builtin/clean.c
parent282616c72d1d08a77ca4fe1186cb708c38408d87 (diff)
downloadgit-838d6a928fc3aef3827d9a45e6aac044fea7451e.zip
git-838d6a928fc3aef3827d9a45e6aac044fea7451e.tar.gz
git-838d6a928fc3aef3827d9a45e6aac044fea7451e.tar.bz2
clean: only lstat files in pathspec
Even though "git clean" takes pathspec to limit the part of the working tree to be cleaned, it checked the paths it encounters during its directory traversal with lstat(2), before checking if the path is within the pathspec. Ignore paths outside pathspec and proceed without checking with lstat(2). Even if such a path is unreadable due to e.g. EPERM, "git clean" should not care. Signed-off-by: David Turner <dturner@twopensource.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/clean.c')
-rw-r--r--builtin/clean.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/builtin/clean.c b/builtin/clean.c
index 1032563..3c1f4b0 100644
--- a/builtin/clean.c
+++ b/builtin/clean.c
@@ -940,15 +940,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;