提交 6d2df284 编写于 作者: N Nguyễn Thái Ngọc Duy 提交者: Junio C Hamano

dir.c: remove an implicit dependency on the_index in pathspec code

Make the match_patchspec API and friends take an index_state instead
of assuming the_index in dir.c. All external call sites are converted
blindly to keep the patch simple and retain current behavior.
Individual call sites may receive further updates to use the right
index instead of the_index.
Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 7f944e26
...@@ -313,7 +313,7 @@ static int reject_entry(const struct object_id *oid, struct strbuf *base, ...@@ -313,7 +313,7 @@ static int reject_entry(const struct object_id *oid, struct strbuf *base,
struct strbuf sb = STRBUF_INIT; struct strbuf sb = STRBUF_INIT;
strbuf_addbuf(&sb, base); strbuf_addbuf(&sb, base);
strbuf_addstr(&sb, filename); strbuf_addstr(&sb, filename);
if (!match_pathspec(context, sb.buf, sb.len, 0, NULL, 1)) if (!match_pathspec(&the_index, context, sb.buf, sb.len, 0, NULL, 1))
ret = READ_TREE_RECURSIVE; ret = READ_TREE_RECURSIVE;
strbuf_release(&sb); strbuf_release(&sb);
} }
......
...@@ -40,7 +40,7 @@ static void chmod_pathspec(struct pathspec *pathspec, char flip) ...@@ -40,7 +40,7 @@ static void chmod_pathspec(struct pathspec *pathspec, char flip)
for (i = 0; i < active_nr; i++) { for (i = 0; i < active_nr; i++) {
struct cache_entry *ce = active_cache[i]; struct cache_entry *ce = active_cache[i];
if (pathspec && !ce_path_match(ce, pathspec, NULL)) if (pathspec && !ce_path_match(&the_index, ce, pathspec, NULL))
continue; continue;
if (chmod_cache_entry(ce, flip) < 0) if (chmod_cache_entry(ce, flip) < 0)
...@@ -135,7 +135,7 @@ static int renormalize_tracked_files(const struct pathspec *pathspec, int flags) ...@@ -135,7 +135,7 @@ static int renormalize_tracked_files(const struct pathspec *pathspec, int flags)
continue; /* do not touch unmerged paths */ continue; /* do not touch unmerged paths */
if (!S_ISREG(ce->ce_mode) && !S_ISLNK(ce->ce_mode)) if (!S_ISREG(ce->ce_mode) && !S_ISLNK(ce->ce_mode))
continue; /* do not touch non blobs */ continue; /* do not touch non blobs */
if (pathspec && !ce_path_match(ce, pathspec, NULL)) if (pathspec && !ce_path_match(&the_index, ce, pathspec, NULL))
continue; continue;
retval |= add_file_to_cache(ce->name, flags | HASH_RENORMALIZE); retval |= add_file_to_cache(ce->name, flags | HASH_RENORMALIZE);
} }
...@@ -155,7 +155,7 @@ static char *prune_directory(struct dir_struct *dir, struct pathspec *pathspec, ...@@ -155,7 +155,7 @@ static char *prune_directory(struct dir_struct *dir, struct pathspec *pathspec,
i = dir->nr; i = dir->nr;
while (--i >= 0) { while (--i >= 0) {
struct dir_entry *entry = *src++; struct dir_entry *entry = *src++;
if (dir_path_match(entry, pathspec, prefix, seen)) if (dir_path_match(&the_index, entry, pathspec, prefix, seen))
*dst++ = entry; *dst++ = entry;
} }
dir->nr = dst - dir->entries; dir->nr = dst - dir->entries;
......
...@@ -318,7 +318,7 @@ static int checkout_paths(const struct checkout_opts *opts, ...@@ -318,7 +318,7 @@ static int checkout_paths(const struct checkout_opts *opts,
* match_pathspec() for _all_ entries when * match_pathspec() for _all_ entries when
* opts->source_tree != NULL. * opts->source_tree != NULL.
*/ */
if (ce_path_match(ce, &opts->pathspec, ps_matched)) if (ce_path_match(&the_index, ce, &opts->pathspec, ps_matched))
ce->ce_flags |= CE_MATCHED; ce->ce_flags |= CE_MATCHED;
} }
......
...@@ -976,7 +976,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix) ...@@ -976,7 +976,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
continue; continue;
if (pathspec.nr) if (pathspec.nr)
matches = dir_path_match(ent, &pathspec, 0, NULL); matches = dir_path_match(&the_index, ent, &pathspec, 0, NULL);
if (pathspec.nr && !matches) if (pathspec.nr && !matches)
continue; continue;
......
...@@ -251,7 +251,7 @@ static int list_paths(struct string_list *list, const char *with_tree, ...@@ -251,7 +251,7 @@ static int list_paths(struct string_list *list, const char *with_tree,
if (ce->ce_flags & CE_UPDATE) if (ce->ce_flags & CE_UPDATE)
continue; continue;
if (!ce_path_match(ce, pattern, m)) if (!ce_path_match(&the_index, ce, pattern, m))
continue; continue;
item = string_list_insert(list, ce->name); item = string_list_insert(list, ce->name);
if (ce_skip_worktree(ce)) if (ce_skip_worktree(ce))
......
...@@ -497,7 +497,7 @@ static int grep_cache(struct grep_opt *opt, struct repository *repo, ...@@ -497,7 +497,7 @@ static int grep_cache(struct grep_opt *opt, struct repository *repo,
strbuf_addstr(&name, ce->name); strbuf_addstr(&name, ce->name);
if (S_ISREG(ce->ce_mode) && if (S_ISREG(ce->ce_mode) &&
match_pathspec(pathspec, name.buf, name.len, 0, NULL, match_pathspec(&the_index, pathspec, name.buf, name.len, 0, NULL,
S_ISDIR(ce->ce_mode) || S_ISDIR(ce->ce_mode) ||
S_ISGITLINK(ce->ce_mode))) { S_ISGITLINK(ce->ce_mode))) {
/* /*
...@@ -515,7 +515,7 @@ static int grep_cache(struct grep_opt *opt, struct repository *repo, ...@@ -515,7 +515,7 @@ static int grep_cache(struct grep_opt *opt, struct repository *repo,
hit |= grep_file(opt, name.buf); hit |= grep_file(opt, name.buf);
} }
} else if (recurse_submodules && S_ISGITLINK(ce->ce_mode) && } else if (recurse_submodules && S_ISGITLINK(ce->ce_mode) &&
submodule_path_match(pathspec, name.buf, NULL)) { submodule_path_match(&the_index, pathspec, name.buf, NULL)) {
hit |= grep_submodule(opt, repo, pathspec, NULL, ce->name, ce->name); hit |= grep_submodule(opt, repo, pathspec, NULL, ce->name, ce->name);
} else { } else {
continue; continue;
...@@ -679,7 +679,7 @@ static int grep_directory(struct grep_opt *opt, const struct pathspec *pathspec, ...@@ -679,7 +679,7 @@ static int grep_directory(struct grep_opt *opt, const struct pathspec *pathspec,
fill_directory(&dir, &the_index, pathspec); fill_directory(&dir, &the_index, pathspec);
for (i = 0; i < dir.nr; i++) { for (i = 0; i < dir.nr; i++) {
if (!dir_path_match(dir.entries[i], pathspec, 0, NULL)) if (!dir_path_match(&the_index, dir.entries[i], pathspec, 0, NULL))
continue; continue;
hit |= grep_file(opt, dir.entries[i]->name); hit |= grep_file(opt, dir.entries[i]->name);
if (hit && opt->status_only) if (hit && opt->status_only)
......
...@@ -128,7 +128,7 @@ static void show_dir_entry(const char *tag, struct dir_entry *ent) ...@@ -128,7 +128,7 @@ static void show_dir_entry(const char *tag, struct dir_entry *ent)
if (len > ent->len) if (len > ent->len)
die("git ls-files: internal error - directory entry not superset of prefix"); die("git ls-files: internal error - directory entry not superset of prefix");
if (!dir_path_match(ent, &pathspec, len, ps_matched)) if (!dir_path_match(&the_index, ent, &pathspec, len, ps_matched))
return; return;
fputs(tag, stdout); fputs(tag, stdout);
...@@ -228,7 +228,7 @@ static void show_ce(struct repository *repo, struct dir_struct *dir, ...@@ -228,7 +228,7 @@ static void show_ce(struct repository *repo, struct dir_struct *dir,
if (recurse_submodules && S_ISGITLINK(ce->ce_mode) && if (recurse_submodules && S_ISGITLINK(ce->ce_mode) &&
is_submodule_active(repo, ce->name)) { is_submodule_active(repo, ce->name)) {
show_submodule(repo, dir, ce->name); show_submodule(repo, dir, ce->name);
} else if (match_pathspec(&pathspec, fullname, strlen(fullname), } else if (match_pathspec(&the_index, &pathspec, fullname, strlen(fullname),
max_prefix_len, ps_matched, max_prefix_len, ps_matched,
S_ISDIR(ce->ce_mode) || S_ISDIR(ce->ce_mode) ||
S_ISGITLINK(ce->ce_mode))) { S_ISGITLINK(ce->ce_mode))) {
...@@ -264,7 +264,7 @@ static void show_ru_info(const struct index_state *istate) ...@@ -264,7 +264,7 @@ static void show_ru_info(const struct index_state *istate)
len = strlen(path); len = strlen(path);
if (len < max_prefix_len) if (len < max_prefix_len)
continue; /* outside of the prefix */ continue; /* outside of the prefix */
if (!match_pathspec(&pathspec, path, len, if (!match_pathspec(&the_index, &pathspec, path, len,
max_prefix_len, ps_matched, 0)) max_prefix_len, ps_matched, 0))
continue; /* uninterested */ continue; /* uninterested */
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
......
...@@ -278,7 +278,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix) ...@@ -278,7 +278,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
for (i = 0; i < active_nr; i++) { for (i = 0; i < active_nr; i++) {
const struct cache_entry *ce = active_cache[i]; const struct cache_entry *ce = active_cache[i];
if (!ce_path_match(ce, &pathspec, seen)) if (!ce_path_match(&the_index, ce, &pathspec, seen))
continue; continue;
ALLOC_GROW(list.entry, list.nr + 1, list.alloc); ALLOC_GROW(list.entry, list.nr + 1, list.alloc);
list.entry[list.nr].name = xstrdup(ce->name); list.entry[list.nr].name = xstrdup(ce->name);
......
...@@ -331,7 +331,7 @@ static int module_list_compute(int argc, const char **argv, ...@@ -331,7 +331,7 @@ static int module_list_compute(int argc, const char **argv,
for (i = 0; i < active_nr; i++) { for (i = 0; i < active_nr; i++) {
const struct cache_entry *ce = active_cache[i]; const struct cache_entry *ce = active_cache[i];
if (!match_pathspec(pathspec, ce->name, ce_namelen(ce), if (!match_pathspec(&the_index, pathspec, ce->name, ce_namelen(ce),
0, ps_matched, 1) || 0, ps_matched, 1) ||
!S_ISGITLINK(ce->ce_mode)) !S_ISGITLINK(ce->ce_mode))
continue; continue;
......
...@@ -748,7 +748,7 @@ static int do_reupdate(int ac, const char **av, ...@@ -748,7 +748,7 @@ static int do_reupdate(int ac, const char **av,
int save_nr; int save_nr;
char *path; char *path;
if (ce_stage(ce) || !ce_path_match(ce, &pathspec, NULL)) if (ce_stage(ce) || !ce_path_match(&the_index, ce, &pathspec, NULL))
continue; continue;
if (has_head) if (has_head)
old = read_one_ent(NULL, &head_oid, old = read_one_ent(NULL, &head_oid,
......
...@@ -109,7 +109,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option) ...@@ -109,7 +109,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
if (diff_can_quit_early(&revs->diffopt)) if (diff_can_quit_early(&revs->diffopt))
break; break;
if (!ce_path_match(ce, &revs->prune_data, NULL)) if (!ce_path_match(&the_index, ce, &revs->prune_data, NULL))
continue; continue;
if (ce_stage(ce)) { if (ce_stage(ce)) {
...@@ -474,7 +474,7 @@ static int oneway_diff(const struct cache_entry * const *src, ...@@ -474,7 +474,7 @@ static int oneway_diff(const struct cache_entry * const *src,
if (tree == o->df_conflict_entry) if (tree == o->df_conflict_entry)
tree = NULL; tree = NULL;
if (ce_path_match(idx ? idx : tree, &revs->prune_data, NULL)) { if (ce_path_match(&the_index, idx ? idx : tree, &revs->prune_data, NULL)) {
do_oneway_diff(o, idx, tree); do_oneway_diff(o, idx, tree);
if (diff_can_quit_early(&revs->diffopt)) { if (diff_can_quit_early(&revs->diffopt)) {
o->exiting_early = 1; o->exiting_early = 1;
......
...@@ -276,12 +276,13 @@ static int do_read_blob(const struct object_id *oid, struct oid_stat *oid_stat, ...@@ -276,12 +276,13 @@ static int do_read_blob(const struct object_id *oid, struct oid_stat *oid_stat,
#define DO_MATCH_DIRECTORY (1<<1) #define DO_MATCH_DIRECTORY (1<<1)
#define DO_MATCH_SUBMODULE (1<<2) #define DO_MATCH_SUBMODULE (1<<2)
static int match_attrs(const char *name, int namelen, static int match_attrs(const struct index_state *istate,
const char *name, int namelen,
const struct pathspec_item *item) const struct pathspec_item *item)
{ {
int i; int i;
git_check_attr(&the_index, name, item->attr_check); git_check_attr(istate, name, item->attr_check);
for (i = 0; i < item->attr_match_nr; i++) { for (i = 0; i < item->attr_match_nr; i++) {
const char *value; const char *value;
int matched; int matched;
...@@ -318,7 +319,8 @@ static int match_attrs(const char *name, int namelen, ...@@ -318,7 +319,8 @@ static int match_attrs(const char *name, int namelen,
* *
* It returns 0 when there is no match. * It returns 0 when there is no match.
*/ */
static int match_pathspec_item(const struct pathspec_item *item, int prefix, static int match_pathspec_item(const struct index_state *istate,
const struct pathspec_item *item, int prefix,
const char *name, int namelen, unsigned flags) const char *name, int namelen, unsigned flags)
{ {
/* name/namelen has prefix cut off by caller */ /* name/namelen has prefix cut off by caller */
...@@ -358,7 +360,7 @@ static int match_pathspec_item(const struct pathspec_item *item, int prefix, ...@@ -358,7 +360,7 @@ static int match_pathspec_item(const struct pathspec_item *item, int prefix,
strncmp(item->match, name - prefix, item->prefix)) strncmp(item->match, name - prefix, item->prefix))
return 0; return 0;
if (item->attr_match_nr && !match_attrs(name, namelen, item)) if (item->attr_match_nr && !match_attrs(istate, name, namelen, item))
return 0; return 0;
/* If the match was just the prefix, we matched */ /* If the match was just the prefix, we matched */
...@@ -426,7 +428,8 @@ static int match_pathspec_item(const struct pathspec_item *item, int prefix, ...@@ -426,7 +428,8 @@ static int match_pathspec_item(const struct pathspec_item *item, int prefix,
* pathspec did not match any names, which could indicate that the * pathspec did not match any names, which could indicate that the
* user mistyped the nth pathspec. * user mistyped the nth pathspec.
*/ */
static int do_match_pathspec(const struct pathspec *ps, static int do_match_pathspec(const struct index_state *istate,
const struct pathspec *ps,
const char *name, int namelen, const char *name, int namelen,
int prefix, char *seen, int prefix, char *seen,
unsigned flags) unsigned flags)
...@@ -472,7 +475,7 @@ static int do_match_pathspec(const struct pathspec *ps, ...@@ -472,7 +475,7 @@ static int do_match_pathspec(const struct pathspec *ps,
*/ */
if (seen && ps->items[i].magic & PATHSPEC_EXCLUDE) if (seen && ps->items[i].magic & PATHSPEC_EXCLUDE)
seen[i] = MATCHED_FNMATCH; seen[i] = MATCHED_FNMATCH;
how = match_pathspec_item(ps->items+i, prefix, name, how = match_pathspec_item(istate, ps->items+i, prefix, name,
namelen, flags); namelen, flags);
if (ps->recursive && if (ps->recursive &&
(ps->magic & PATHSPEC_MAXDEPTH) && (ps->magic & PATHSPEC_MAXDEPTH) &&
...@@ -496,17 +499,18 @@ static int do_match_pathspec(const struct pathspec *ps, ...@@ -496,17 +499,18 @@ static int do_match_pathspec(const struct pathspec *ps,
return retval; return retval;
} }
int match_pathspec(const struct pathspec *ps, int match_pathspec(const struct index_state *istate,
const struct pathspec *ps,
const char *name, int namelen, const char *name, int namelen,
int prefix, char *seen, int is_dir) int prefix, char *seen, int is_dir)
{ {
int positive, negative; int positive, negative;
unsigned flags = is_dir ? DO_MATCH_DIRECTORY : 0; unsigned flags = is_dir ? DO_MATCH_DIRECTORY : 0;
positive = do_match_pathspec(ps, name, namelen, positive = do_match_pathspec(istate, ps, name, namelen,
prefix, seen, flags); prefix, seen, flags);
if (!(ps->magic & PATHSPEC_EXCLUDE) || !positive) if (!(ps->magic & PATHSPEC_EXCLUDE) || !positive)
return positive; return positive;
negative = do_match_pathspec(ps, name, namelen, negative = do_match_pathspec(istate, ps, name, namelen,
prefix, seen, prefix, seen,
flags | DO_MATCH_EXCLUDE); flags | DO_MATCH_EXCLUDE);
return negative ? 0 : positive; return negative ? 0 : positive;
...@@ -515,11 +519,12 @@ int match_pathspec(const struct pathspec *ps, ...@@ -515,11 +519,12 @@ int match_pathspec(const struct pathspec *ps,
/** /**
* Check if a submodule is a superset of the pathspec * Check if a submodule is a superset of the pathspec
*/ */
int submodule_path_match(const struct pathspec *ps, int submodule_path_match(const struct index_state *istate,
const struct pathspec *ps,
const char *submodule_name, const char *submodule_name,
char *seen) char *seen)
{ {
int matched = do_match_pathspec(ps, submodule_name, int matched = do_match_pathspec(istate, ps, submodule_name,
strlen(submodule_name), strlen(submodule_name),
0, seen, 0, seen,
DO_MATCH_DIRECTORY | DO_MATCH_DIRECTORY |
......
...@@ -216,7 +216,8 @@ extern int count_slashes(const char *s); ...@@ -216,7 +216,8 @@ extern int count_slashes(const char *s);
extern int simple_length(const char *match); extern int simple_length(const char *match);
extern int no_wildcard(const char *string); extern int no_wildcard(const char *string);
extern char *common_prefix(const struct pathspec *pathspec); extern char *common_prefix(const struct pathspec *pathspec);
extern int match_pathspec(const struct pathspec *pathspec, extern int match_pathspec(const struct index_state *istate,
const struct pathspec *pathspec,
const char *name, int namelen, const char *name, int namelen,
int prefix, char *seen, int is_dir); int prefix, char *seen, int is_dir);
extern int report_path_error(const char *ps_matched, const struct pathspec *pathspec, const char *prefix); extern int report_path_error(const char *ps_matched, const struct pathspec *pathspec, const char *prefix);
...@@ -326,25 +327,28 @@ extern int git_fnmatch(const struct pathspec_item *item, ...@@ -326,25 +327,28 @@ extern int git_fnmatch(const struct pathspec_item *item,
const char *pattern, const char *string, const char *pattern, const char *string,
int prefix); int prefix);
extern int submodule_path_match(const struct pathspec *ps, extern int submodule_path_match(const struct index_state *istate,
const struct pathspec *ps,
const char *submodule_name, const char *submodule_name,
char *seen); char *seen);
static inline int ce_path_match(const struct cache_entry *ce, static inline int ce_path_match(const struct index_state *istate,
const struct cache_entry *ce,
const struct pathspec *pathspec, const struct pathspec *pathspec,
char *seen) char *seen)
{ {
return match_pathspec(pathspec, ce->name, ce_namelen(ce), 0, seen, return match_pathspec(istate, pathspec, ce->name, ce_namelen(ce), 0, seen,
S_ISDIR(ce->ce_mode) || S_ISGITLINK(ce->ce_mode)); S_ISDIR(ce->ce_mode) || S_ISGITLINK(ce->ce_mode));
} }
static inline int dir_path_match(const struct dir_entry *ent, static inline int dir_path_match(const struct index_state *istate,
const struct dir_entry *ent,
const struct pathspec *pathspec, const struct pathspec *pathspec,
int prefix, char *seen) int prefix, char *seen)
{ {
int has_trailing_dir = ent->len && ent->name[ent->len - 1] == '/'; int has_trailing_dir = ent->len && ent->name[ent->len - 1] == '/';
int len = has_trailing_dir ? ent->len - 1 : ent->len; int len = has_trailing_dir ? ent->len - 1 : ent->len;
return match_pathspec(pathspec, ent->name, len, prefix, seen, return match_pathspec(istate, pathspec, ent->name, len, prefix, seen,
has_trailing_dir); has_trailing_dir);
} }
......
...@@ -37,7 +37,7 @@ void add_pathspec_matches_against_index(const struct pathspec *pathspec, ...@@ -37,7 +37,7 @@ void add_pathspec_matches_against_index(const struct pathspec *pathspec,
return; return;
for (i = 0; i < istate->cache_nr; i++) { for (i = 0; i < istate->cache_nr; i++) {
const struct cache_entry *ce = istate->cache[i]; const struct cache_entry *ce = istate->cache[i];
ce_path_match(ce, pathspec, seen); ce_path_match(&the_index, ce, pathspec, seen);
} }
} }
......
...@@ -58,7 +58,7 @@ static void *preload_thread(void *_data) ...@@ -58,7 +58,7 @@ static void *preload_thread(void *_data)
continue; continue;
if (ce->ce_flags & CE_FSMONITOR_VALID) if (ce->ce_flags & CE_FSMONITOR_VALID)
continue; continue;
if (!ce_path_match(ce, &p->pathspec, NULL)) if (!ce_path_match(&the_index, ce, &p->pathspec, NULL))
continue; continue;
if (threaded_has_symlink_leading_path(&cache, ce->name, ce_namelen(ce))) if (threaded_has_symlink_leading_path(&cache, ce->name, ce_namelen(ce)))
continue; continue;
......
...@@ -1493,7 +1493,7 @@ int refresh_index(struct index_state *istate, unsigned int flags, ...@@ -1493,7 +1493,7 @@ int refresh_index(struct index_state *istate, unsigned int flags,
if (ignore_submodules && S_ISGITLINK(ce->ce_mode)) if (ignore_submodules && S_ISGITLINK(ce->ce_mode))
continue; continue;
if (pathspec && !ce_path_match(ce, pathspec, seen)) if (pathspec && !ce_path_match(&the_index, ce, pathspec, seen))
filtered = 1; filtered = 1;
if (ce_stage(ce)) { if (ce_stage(ce)) {
......
...@@ -1120,7 +1120,7 @@ int rerere_forget(struct pathspec *pathspec) ...@@ -1120,7 +1120,7 @@ int rerere_forget(struct pathspec *pathspec)
find_conflict(&conflict); find_conflict(&conflict);
for (i = 0; i < conflict.nr; i++) { for (i = 0; i < conflict.nr; i++) {
struct string_list_item *it = &conflict.items[i]; struct string_list_item *it = &conflict.items[i];
if (!match_pathspec(pathspec, it->string, if (!match_pathspec(&the_index, pathspec, it->string,
strlen(it->string), 0, NULL, 0)) strlen(it->string), 0, NULL, 0))
continue; continue;
rerere_forget_one_path(it->string, &merge_rr); rerere_forget_one_path(it->string, &merge_rr);
......
...@@ -188,7 +188,7 @@ void unmerge_index(struct index_state *istate, const struct pathspec *pathspec) ...@@ -188,7 +188,7 @@ void unmerge_index(struct index_state *istate, const struct pathspec *pathspec)
for (i = 0; i < istate->cache_nr; i++) { for (i = 0; i < istate->cache_nr; i++) {
const struct cache_entry *ce = istate->cache[i]; const struct cache_entry *ce = istate->cache[i];
if (!ce_path_match(ce, pathspec, NULL)) if (!ce_path_match(&the_index, ce, pathspec, NULL))
continue; continue;
i = unmerge_index_entry_at(istate, i); i = unmerge_index_entry_at(istate, i);
} }
......
...@@ -1517,7 +1517,7 @@ static void prepare_show_merge(struct rev_info *revs) ...@@ -1517,7 +1517,7 @@ static void prepare_show_merge(struct rev_info *revs)
const struct cache_entry *ce = active_cache[i]; const struct cache_entry *ce = active_cache[i];
if (!ce_stage(ce)) if (!ce_stage(ce))
continue; continue;
if (ce_path_match(ce, &revs->prune_data, NULL)) { if (ce_path_match(&the_index, ce, &revs->prune_data, NULL)) {
prune_num++; prune_num++;
REALLOC_ARRAY(prune, prune_num); REALLOC_ARRAY(prune, prune_num);
prune[prune_num-2] = ce->name; prune[prune_num-2] = ce->name;
......
...@@ -258,7 +258,7 @@ int is_submodule_active(struct repository *repo, const char *path) ...@@ -258,7 +258,7 @@ int is_submodule_active(struct repository *repo, const char *path)
} }
parse_pathspec(&ps, 0, 0, NULL, args.argv); parse_pathspec(&ps, 0, 0, NULL, args.argv);
ret = match_pathspec(&ps, path, strlen(path), 0, NULL, 1); ret = match_pathspec(&the_index, &ps, path, strlen(path), 0, NULL, 1);
argv_array_clear(&args); argv_array_clear(&args);
clear_pathspec(&ps); clear_pathspec(&ps);
......
...@@ -647,7 +647,7 @@ static void wt_status_collect_changes_initial(struct wt_status *s) ...@@ -647,7 +647,7 @@ static void wt_status_collect_changes_initial(struct wt_status *s)
struct wt_status_change_data *d; struct wt_status_change_data *d;
const struct cache_entry *ce = active_cache[i]; const struct cache_entry *ce = active_cache[i];
if (!ce_path_match(ce, &s->pathspec, NULL)) if (!ce_path_match(&the_index, ce, &s->pathspec, NULL))
continue; continue;
if (ce_intent_to_add(ce)) if (ce_intent_to_add(ce))
continue; continue;
...@@ -703,7 +703,7 @@ static void wt_status_collect_untracked(struct wt_status *s) ...@@ -703,7 +703,7 @@ static void wt_status_collect_untracked(struct wt_status *s)
for (i = 0; i < dir.nr; i++) { for (i = 0; i < dir.nr; i++) {
struct dir_entry *ent = dir.entries[i]; struct dir_entry *ent = dir.entries[i];
if (cache_name_is_other(ent->name, ent->len) && if (cache_name_is_other(ent->name, ent->len) &&
dir_path_match(ent, &s->pathspec, 0, NULL)) dir_path_match(&the_index, ent, &s->pathspec, 0, NULL))
string_list_insert(&s->untracked, ent->name); string_list_insert(&s->untracked, ent->name);
free(ent); free(ent);
} }
...@@ -711,7 +711,7 @@ static void wt_status_collect_untracked(struct wt_status *s) ...@@ -711,7 +711,7 @@ static void wt_status_collect_untracked(struct wt_status *s)
for (i = 0; i < dir.ignored_nr; i++) { for (i = 0; i < dir.ignored_nr; i++) {
struct dir_entry *ent = dir.ignored[i]; struct dir_entry *ent = dir.ignored[i];
if (cache_name_is_other(ent->name, ent->len) && if (cache_name_is_other(ent->name, ent->len) &&
dir_path_match(ent, &s->pathspec, 0, NULL)) dir_path_match(&the_index, ent, &s->pathspec, 0, NULL))
string_list_insert(&s->ignored, ent->name); string_list_insert(&s->ignored, ent->name);
free(ent); free(ent);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册