{"thread":{"id":"39359","subject":"[PATCH] clean: only lstat files in pathspec","startedAt":"2015-05-18T18:08:46Z","lastAt":"2015-05-18T18:08:46Z","messageCount":1,"participants":["David Turner"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"261484","messageId":"1431972526-26382-1-git-send-email-dturner@twopensource.com","threadId":"39359","inReplyTo":null,"subject":"[PATCH] clean: only lstat files in pathspec","fromName":"David Turner","fromEmail":"dturner@twopensource.com","sentAt":"2015-05-18T18:08:46Z","receivedAt":"2015-05-18T18:08:46Z","isPatch":true,"sender":{"key":"novalis@novalis.org","avatar":"https://avatars.githubusercontent.com/u/77003?v=4"},"body":"Git clean takes a list of paths to clean.  Make sure that it only\nlstats files which match that list of paths.  Previously, if another\nprocess was deleting files outside of the specified paths, clean might\nhave failed when attempting to lstat those files.  Now, it will not\nlstat them, and thus will not fail.\n\nSigned-off-by: David Turner <dturner@twopensource.com>\n---\n builtin/clean.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/clean.c b/builtin/clean.c\nindex 98c103f..ada0196 100644\n--- a/builtin/clean.c\n+++ b/builtin/clean.c\n@@ -941,15 +941,15 @@ int cmd_clean(int argc, const char **argv, const char *prefix)\n \t\tif (!cache_name_is_other(ent->name, ent->len))\n \t\t\tcontinue;\n \n-\t\tif (lstat(ent->name, &st))\n-\t\t\tdie_errno(\"Cannot lstat '%s'\", ent->name);\n-\n \t\tif (pathspec.nr)\n \t\t\tmatches = dir_path_match(ent, &pathspec, 0, NULL);\n \n \t\tif (pathspec.nr && !matches)\n \t\t\tcontinue;\n \n+\t\tif (lstat(ent->name, &st))\n+\t\t\tdie_errno(\"Cannot lstat '%s'\", ent->name);\n+\n \t\tif (S_ISDIR(st.st_mode) && !remove_directories &&\n \t\t    matches != MATCHED_EXACTLY)\n \t\t\tcontinue;\n-- \n2.0.4.315.gad8727a-twtrsrc\n"}]}