static void prune_directory(struct dir_struct *dir, const char **pathspec, int prefix) { char *seen; int i, specs; struct dir_entry **src, **dst; for (specs = 0; pathspec[specs]; specs++) /* nothing */; seen = xcalloc(specs, 1); src = dst = dir->entries; i = dir->nr; while (--i >= 0) { struct dir_entry *entry = *src++; if (match_pathspec(pathspec, entry->name, entry->len, prefix, seen)) *dst++ = entry; } dir->nr = dst - dir->entries; fill_pathspec_matches(pathspec, seen, specs); for (i = 0; i < specs; i++) { if (!seen[i] && !file_exists(pathspec[i])) die("pathspec '%s' did not match any files", pathspec[i]); } free(seen); }
static char *find_used_pathspec(const char **pathspec) { char *seen; int i; for (i = 0; pathspec[i]; i++) ; /* just counting */ seen = xcalloc(i, 1); fill_pathspec_matches(pathspec, seen, i); return seen; }
static char *prune_directory(struct dir_struct *dir, const char **pathspec, int prefix) { char *seen; int i, specs; struct dir_entry **src, **dst; for (specs = 0; pathspec[specs]; specs++) /* nothing */; seen = xcalloc(specs, 1); src = dst = dir->entries; i = dir->nr; while (--i >= 0) { struct dir_entry *entry = *src++; if (match_pathspec(pathspec, entry->name, entry->len, prefix, seen)) *dst++ = entry; } dir->nr = dst - dir->entries; fill_pathspec_matches(pathspec, seen, specs); return seen; }