static char *prune_directory(struct dir_struct *dir, struct pathspec *pathspec, int prefix, unsigned flag) { char *seen; int i; struct dir_entry **src, **dst; seen = xcalloc(pathspec->nr, 1); src = dst = dir->entries; i = dir->nr; while (--i >= 0) { struct dir_entry *entry = *src++; if (match_pathspec_depth(pathspec, entry->name, entry->len, prefix, seen)) *dst++ = entry; else if (flag & WARN_IMPLICIT_DOT) /* * "git add -A" was run from a subdirectory with a * new file outside that directory. * * "git add -A" will behave like "git add -A :/" * instead of "git add -A ." in the future. * Warn about the coming behavior change. */ warn_pathless_add(); } dir->nr = dst - dir->entries; add_pathspec_matches_against_index(pathspec, seen); return seen; }
static char *prune_directory(struct dir_struct *dir, struct pathspec *pathspec, int prefix) { char *seen; int i; struct dir_entry **src, **dst; seen = xcalloc(pathspec->nr, 1); src = dst = dir->entries; i = dir->nr; while (--i >= 0) { struct dir_entry *entry = *src++; if (dir_path_match(&the_index, entry, pathspec, prefix, seen)) *dst++ = entry; } dir->nr = dst - dir->entries; add_pathspec_matches_against_index(pathspec, &the_index, seen); 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; add_pathspec_matches_against_index(pathspec, seen, specs); return seen; }
/* * Finds which of the given pathspecs match items in the index. * * This is a one-shot wrapper around add_pathspec_matches_against_index() * which allocates, populates, and returns a seen[] array indicating the * nature of the "closest" (i.e. most specific) matches which each of the * given pathspecs achieves against all items in the index. */ char *find_pathspecs_matching_against_index(const struct pathspec *pathspec) { char *seen = xcalloc(pathspec->nr, 1); add_pathspec_matches_against_index(pathspec, seen); return seen; }