Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 2e70c01

Browse files
pcloudsgitster
authored andcommitted
clean: use cache_name_is_other()
cmd_clean() has the exact same code of index_name_is_other(). Reduce code duplication. Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 05b8502 commit 2e70c01

File tree

1 file changed

+2
-19
lines changed

1 file changed

+2
-19
lines changed

builtin/clean.c

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -933,29 +933,12 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
933933

934934
for (i = 0; i < dir.nr; i++) {
935935
struct dir_entry *ent = dir.entries[i];
936-
int len, pos;
937936
int matches = 0;
938-
const struct cache_entry *ce;
939937
struct stat st;
940938
const char *rel;
941939

942-
/*
943-
* Remove the '/' at the end that directory
944-
* walking adds for directory entries.
945-
*/
946-
len = ent->len;
947-
if (len && ent->name[len-1] == '/')
948-
len--;
949-
pos = cache_name_pos(ent->name, len);
950-
if (0 <= pos)
951-
continue; /* exact match */
952-
pos = -pos - 1;
953-
if (pos < active_nr) {
954-
ce = active_cache[pos];
955-
if (ce_namelen(ce) == len &&
956-
!memcmp(ce->name, ent->name, len))
957-
continue; /* Yup, this one exists unmerged */
958-
}
940+
if (!cache_name_is_other(ent->name, ent->len))
941+
continue;
959942

960943
if (lstat(ent->name, &st))
961944
die_errno("Cannot lstat '%s'", ent->name);

0 commit comments

Comments
 (0)