clean: only lstat files in pathspec
PATCH 1/1 clean: only lstat files in pathspec
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 <[email protected]>
--- builtin/clean.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
builtin/clean.c +3 -3
@@ -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 ;
Signature · 1 line
2.0.4.315.gad8727a-twtrsrc