git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] clean: only lstat files in pathspec

From
David Turner <dturner@twopensource.com>
Date
May 18, 2015, 18:08 UTC
Message-ID
<1431972526-26382-1-git-send-email-dturner@twopensource.com>

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
Message 1 of 1 in “clean: only lstat files in pathspec”
  1. clean: only lstat files in pathspecDavid Turner, May 18, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.