Skip to content

Commit 3a7f090

Browse files
matheustavaresgitster
authored andcommitted
clean: remove unnecessary variable
The variable `matches` used to hold the return of a `dir_path_match()` call that was removed in 95c11ec ("Fix error-prone fill_directory() API; make it only return matches", 2020-04-01). Now `matches` will always hold 0, which is the value it's initialized with; and the condition `matches != MATCHED_EXACTLY` will always evaluate to true. So let's remove this unnecessary variable. Interestingly, it seems that `matches != MATCHED_EXACTLY` was already unnecessary before 95c11ec. That's because `remove_directories` is always set to 1 when we have pathspecs; So, in the condition `!remove_directories && matches != MATCHED_EXACTLY`, we would either: - have pathspecs (or have been given `-d`) and ignore `matches` because `remove_directories` is 1; or - not have pathspecs (nor `-d`) and end up just checking that `0 != MATCHED_EXACTLY`, as `matches` would never get reassigned after its zero initialization (because there is no pathspec to match). Signed-off-by: Matheus Tavares <[email protected]> Reviewed-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6ff7f46 commit 3a7f090

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

builtin/clean.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,6 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
976976

977977
for (i = 0; i < dir.nr; i++) {
978978
struct dir_entry *ent = dir.entries[i];
979-
int matches = 0;
980979
struct stat st;
981980
const char *rel;
982981

@@ -986,8 +985,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
986985
if (lstat(ent->name, &st))
987986
die_errno("Cannot lstat '%s'", ent->name);
988987

989-
if (S_ISDIR(st.st_mode) && !remove_directories &&
990-
matches != MATCHED_EXACTLY)
988+
if (S_ISDIR(st.st_mode) && !remove_directories)
991989
continue;
992990

993991
rel = relative_path(ent->name, prefix, &buf);

0 commit comments

Comments
 (0)