Skip to content

Commit 0c1ecfb

Browse files
committed
sequencer: ensure full index if not ORT strategy
The sequencer is used by 'cherry-pick' and 'rebase' to sequence a list of operations that modify the index. Since we intend to remove the need for 'command_requires_full_index', we need to ensure the sparse index is expanded every time it is written to disk between these steps. That is, unless the merge strategy is 'ort' where the index can remain sparse throughout. There are two main places to be extra careful about a full index: 1. Right before calling merge_trees(), ensure the index is full. This happens within an 'else' where the 'if' block checks if the 'ort' strategy is selected. 2. During read_and_refresh_cache(), the index might be written to disk and converted to sparse in the process. Ensure it expands back to full afterwards by checking if the strategy is _not_ 'ort'. This 'if' statement is the logical negation of the 'if' in item (1). Signed-off-by: Derrick Stolee <[email protected]>
1 parent cdecb85 commit 0c1ecfb

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

sequencer.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,7 @@ static int do_recursive_merge(struct repository *r,
652652
merge_switch_to_result(&o, head_tree, &result, 1, show_output);
653653
clean = result.clean;
654654
} else {
655+
ensure_full_index(r->index);
655656
clean = merge_trees(&o, head_tree, next_tree, base_tree);
656657
if (is_rebase_i(opts) && clean <= 0)
657658
fputs(o.obuf.buf, stdout);
@@ -2346,13 +2347,21 @@ static int read_and_refresh_cache(struct repository *r,
23462347
_(action_name(opts)));
23472348
}
23482349
refresh_index(r->index, REFRESH_QUIET|REFRESH_UNMERGED, NULL, NULL, NULL);
2350+
23492351
if (index_fd >= 0) {
23502352
if (write_locked_index(r->index, &index_lock,
23512353
COMMIT_LOCK | SKIP_IF_UNCHANGED)) {
23522354
return error(_("git %s: failed to refresh the index"),
23532355
_(action_name(opts)));
23542356
}
23552357
}
2358+
2359+
/*
2360+
* If we are resolving merges in any way other than "ort", then
2361+
* expand the sparse index.
2362+
*/
2363+
if (opts->strategy && strcmp(opts->strategy, "ort"))
2364+
ensure_full_index(r->index);
23562365
return 0;
23572366
}
23582367

0 commit comments

Comments
 (0)