diff-lib.c: remove implicit dependency on the_index

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 Sep 21, 2018 at 17:57 UTC 5adbb403c24880b758149378bc7874d7617db4bc
1 file changed +10 -7
diff-lib.c
+10 -7
@@ -70,7 +70,7 @@ static int match_stat_with_submodule(struct diff_options *diffopt,
70 struct stat *st, unsigned ce_option,
71 unsigned *dirty_submodule)
72 {
73 - int changed = ce_match_stat(ce, st, ce_option);
73 + int changed = ie_match_stat(diffopt->repo->index, ce, st, ce_option);
74 if (S_ISGITLINK(ce->ce_mode)) {
75 struct diff_flags orig_flags = diffopt->flags;
76 if (!diffopt->flags.override_submodule_config)
@@ -93,15 +93,16 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
93 unsigned ce_option = ((option & DIFF_RACY_IS_MODIFIED)
94 ? CE_MATCH_RACY_IS_DIRTY : 0);
95 uint64_t start = getnanotime();
96 + struct index_state *istate = revs->diffopt.repo->index;
97
98 diff_set_mnemonic_prefix(&revs->diffopt, "i/", "w/");
99
100 if (diff_unmerged_stage < 0)
101 diff_unmerged_stage = 2;
101 - entries = active_nr;
102 + entries = istate->cache_nr;
103 for (i = 0; i < entries; i++) {
104 unsigned int oldmode, newmode;
104 - struct cache_entry *ce = active_cache[i];
105 + struct cache_entry *ce = istate->cache[i];
106 int changed;
107 unsigned dirty_submodule = 0;
108 const struct object_id *old_oid, *new_oid;
@@ -109,7 +110,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
110 if (diff_can_quit_early(&revs->diffopt))
111 break;
112
112 - if (!ce_path_match(&the_index, ce, &revs->prune_data, NULL))
113 + if (!ce_path_match(istate, ce, &revs->prune_data, NULL))
114 continue;
115
116 if (ce_stage(ce)) {
@@ -145,7 +146,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
146 dpath->mode = wt_mode;
147
148 while (i < entries) {
148 - struct cache_entry *nce = active_cache[i];
149 + struct cache_entry *nce = istate->cache[i];
150 int stage;
151
152 if (strcmp(ce->name, nce->name))
@@ -474,7 +475,9 @@ static int oneway_diff(const struct cache_entry * const *src,
475 if (tree == o->df_conflict_entry)
476 tree = NULL;
477
477 - if (ce_path_match(&the_index, idx ? idx : tree, &revs->prune_data, NULL)) {
478 + if (ce_path_match(revs->diffopt.repo->index,
479 + idx ? idx : tree,
480 + &revs->prune_data, NULL)) {
481 do_oneway_diff(o, idx, tree);
482 if (diff_can_quit_early(&revs->diffopt)) {
483 o->exiting_early = 1;
@@ -506,7 +509,7 @@ static int diff_cache(struct rev_info *revs,
509 opts.merge = 1;
510 opts.fn = oneway_diff;
511 opts.unpack_data = revs;
509 - opts.src_index = &the_index;
512 + opts.src_index = revs->diffopt.repo->index;
513 opts.dst_index = NULL;
514 opts.pathspec = &revs->diffopt.pathspec;
515 opts.pathspec->recursive = 1;