]> git.ipfire.org Git - thirdparty/git.git/commit
merge-ours: integrate with sparse-index
authorSam Bostock <sam@sambostock.ca>
Fri, 6 Feb 2026 19:16:23 +0000 (19:16 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 6 Feb 2026 19:45:33 +0000 (11:45 -0800)
commitfb1b786ebfab18b851ce1fa94d5063daf11f647f
treedeec8e2810e3a06d9f7e18ff011d7a2cd48d1fb9
parentba447e9cec47ca5b1cc8cfeae8ca90bc962c54fa
merge-ours: integrate with sparse-index

The merge-ours built-in opens the index to compare it against HEAD.
The machinery used to do this (i.e. run_diff_index()) is capable of
working with a sparse index, but the start-up sequence of this
command does not take the necessary steps, so we end up expanding the
index fully before doing the comparison.

In order to convince sparse-index.c:is_sparse_index_allowed() to
return true, we need to:

 - Read basic configuration with git_default_config so that global
   variables like core_apply_sparse_checkout are populated.
   merge-ours currently does not read configuration at all.

 - Set command_requires_full_index to 0.

With that, the command can work without expanding the index fully
before doing its work.

Signed-off-by: Sam Bostock <sam@sambostock.ca>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/merge-ours.c
t/t1092-sparse-checkout-compatibility.sh