git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clean: only lstat files in pathspec
@ 2015-05-18 18:08 David Turner
  0 siblings, 0 replies; only message in thread
From: David Turner @ 2015-05-18 18:08 UTC (permalink / raw)
  To: git; +Cc: David Turner

Git clean takes a list of paths to clean.  Make sure that it only
lstats files which match that list of paths.  Previously, if another
process was deleting files outside of the specified paths, clean might
have failed when attempting to lstat those files.  Now, it will not
lstat them, and thus will not fail.

Signed-off-by: David Turner <dturner@twopensource.com>
---
 builtin/clean.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/builtin/clean.c b/builtin/clean.c
index 98c103f..ada0196 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;
-- 
2.0.4.315.gad8727a-twtrsrc

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-05-18 18:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-18 18:08 [PATCH] clean: only lstat files in pathspec David Turner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).