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 <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nguyễn Thái Ngọc Duy committed Jan 24, 2014 at 20:40 UTC 2e70c01799bf663cc1fa5f6e37e025000ffdc0b0
1 file changed +2 -19
builtin/clean.c
+2 -19
@@ -933,29 +933,12 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
933
934 for (i = 0; i < dir.nr; i++) {
935 struct dir_entry *ent = dir.entries[i];
936 - int len, pos;
936 int matches = 0;
938 - const struct cache_entry *ce;
937 struct stat st;
938 const char *rel;
939
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;
942
943 if (lstat(ent->name, &st))
944 die_errno("Cannot lstat '%s'", ent->name);