Skip to content

Commit 5adbb40

Browse files
pcloudsgitster
authored andcommitted
diff-lib.c: remove implicit dependency on the_index
Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d7b665c commit 5adbb40

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

diff-lib.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static int match_stat_with_submodule(struct diff_options *diffopt,
7070
struct stat *st, unsigned ce_option,
7171
unsigned *dirty_submodule)
7272
{
73-
int changed = ce_match_stat(ce, st, ce_option);
73+
int changed = ie_match_stat(diffopt->repo->index, ce, st, ce_option);
7474
if (S_ISGITLINK(ce->ce_mode)) {
7575
struct diff_flags orig_flags = diffopt->flags;
7676
if (!diffopt->flags.override_submodule_config)
@@ -93,23 +93,24 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
9393
unsigned ce_option = ((option & DIFF_RACY_IS_MODIFIED)
9494
? CE_MATCH_RACY_IS_DIRTY : 0);
9595
uint64_t start = getnanotime();
96+
struct index_state *istate = revs->diffopt.repo->index;
9697

9798
diff_set_mnemonic_prefix(&revs->diffopt, "i/", "w/");
9899

99100
if (diff_unmerged_stage < 0)
100101
diff_unmerged_stage = 2;
101-
entries = active_nr;
102+
entries = istate->cache_nr;
102103
for (i = 0; i < entries; i++) {
103104
unsigned int oldmode, newmode;
104-
struct cache_entry *ce = active_cache[i];
105+
struct cache_entry *ce = istate->cache[i];
105106
int changed;
106107
unsigned dirty_submodule = 0;
107108
const struct object_id *old_oid, *new_oid;
108109

109110
if (diff_can_quit_early(&revs->diffopt))
110111
break;
111112

112-
if (!ce_path_match(&the_index, ce, &revs->prune_data, NULL))
113+
if (!ce_path_match(istate, ce, &revs->prune_data, NULL))
113114
continue;
114115

115116
if (ce_stage(ce)) {
@@ -145,7 +146,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
145146
dpath->mode = wt_mode;
146147

147148
while (i < entries) {
148-
struct cache_entry *nce = active_cache[i];
149+
struct cache_entry *nce = istate->cache[i];
149150
int stage;
150151

151152
if (strcmp(ce->name, nce->name))
@@ -474,7 +475,9 @@ static int oneway_diff(const struct cache_entry * const *src,
474475
if (tree == o->df_conflict_entry)
475476
tree = NULL;
476477

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)) {
478481
do_oneway_diff(o, idx, tree);
479482
if (diff_can_quit_early(&revs->diffopt)) {
480483
o->exiting_early = 1;
@@ -506,7 +509,7 @@ static int diff_cache(struct rev_info *revs,
506509
opts.merge = 1;
507510
opts.fn = oneway_diff;
508511
opts.unpack_data = revs;
509-
opts.src_index = &the_index;
512+
opts.src_index = revs->diffopt.repo->index;
510513
opts.dst_index = NULL;
511514
opts.pathspec = &revs->diffopt.pathspec;
512515
opts.pathspec->recursive = 1;

0 commit comments

Comments
 (0)