From: "Sam Bostock via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Patrick Steinhardt <ps@pks.im>, Sam Bostock <sam@sambostock.ca>
Subject: [PATCH v2 0/2] merge-ours: sparse-index integration
Date: Fri, 06 Feb 2026 19:16:21 +0000 [thread overview]
Message-ID: <pull.2189.v2.git.git.1770405383.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.2189.git.git.1770345124.gitgitgadget@gmail.com>
This short series teaches merge-ours to work with a sparse index as a small
step toward broader sparse-index support.
Patch 1 is a preparatory cleanup that converts merge-ours away from
the_repository global, using the repo parameter instead.
Patch 2 adds the actual sparse-index integration and tests.
Changes since v1:
* Patch 1: note in commit message that RUN_SETUP guarantees repo is never
NULL (Patrick, Junio)
* Patch 2: rewrite commit message to follow the project's standard log
message structure (Junio)
Thanks Junio and Patrick for the review.
Developed with AI assistance (Claude).
Sam Bostock (2):
merge-ours: drop USE_THE_REPOSITORY_VARIABLE
merge-ours: integrate with sparse-index
builtin/merge-ours.c | 15 +++++++++------
t/t1092-sparse-checkout-compatibility.sh | 14 ++++++++++++++
2 files changed, 23 insertions(+), 6 deletions(-)
base-commit: b2826b52eb7caff9f4ed6e85ec45e338bf02ad09
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2189%2Fsambostock%2Fsb%2Fmerge-ours-sparse-index-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2189/sambostock/sb/merge-ours-sparse-index-v2
Pull-Request: https://github.com/git/git/pull/2189
Range-diff vs v1:
1: 6cb970e512 ! 1: 775d76df69 merge-ours: drop USE_THE_REPOSITORY_VARIABLE
@@ Metadata
## Commit message ##
merge-ours: drop USE_THE_REPOSITORY_VARIABLE
- Use the `repo` parameter passed to cmd_merge_ours() instead of
- `the_repository`, and drop the USE_THE_REPOSITORY_VARIABLE macro that
- is no longer needed.
+ The merge-ours built-in uses the `the_repository` global to access
+ the repository. The project is moving away from this global in favor
+ of the `repo` parameter that is passed to each built-in command.
+ Since merge-ours is registered with RUN_SETUP, `repo` is guaranteed
+ to be non-NULL and can be used directly.
+
+ Drop the USE_THE_REPOSITORY_VARIABLE macro and use `repo` throughout.
While at it, remove a stray double blank line between the #include
block and the usage string.
2: 20b9e0bf6e ! 2: 55d39ff778 merge-ours: integrate with sparse-index
@@ Metadata
## Commit message ##
merge-ours: integrate with sparse-index
- The merge-ours builtin reads the index only to compare it against HEAD
- via index_differs_from(), whose diff machinery (run_diff_index) is
- already sparse-aware.
+ 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.
- Teach merge-ours to opt out of requiring a full index by setting
- command_requires_full_index to 0. Because merge-ours is invoked as a
- subprocess by "git merge -s ours" and never previously read config,
- the global variables core_apply_sparse_checkout and
- core_sparse_checkout_cone remained unset, causing
- is_sparse_index_allowed() to return false and the index to be expanded
- anyway. Add a repo_config() call with git_default_config to populate
- these globals.
+ In order to convince sparse-index.c:is_sparse_index_allowed() to
+ return true, we need to:
- Add tests to t1092 verifying that "git merge -s ours" produces
- identical results across full-checkout, sparse-checkout, and
- sparse-index modes, including verifying the resulting merge commit
- structure, and that the sparse index is not expanded during the
- operation.
+ - 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>
--
gitgitgadget
next prev parent reply other threads:[~2026-02-06 19:16 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-06 2:32 [PATCH 0/2] merge-ours: sparse-index integration Sam Bostock via GitGitGadget
2026-02-06 2:32 ` [PATCH 1/2] merge-ours: drop USE_THE_REPOSITORY_VARIABLE Sam Bostock via GitGitGadget
2026-02-06 15:02 ` Patrick Steinhardt
2026-02-06 17:33 ` Junio C Hamano
2026-02-06 2:32 ` [PATCH 2/2] merge-ours: integrate with sparse-index Sam Bostock via GitGitGadget
2026-02-06 13:35 ` Junio C Hamano
2026-02-06 19:16 ` Sam Bostock via GitGitGadget [this message]
2026-02-06 19:16 ` [PATCH v2 1/2] merge-ours: drop USE_THE_REPOSITORY_VARIABLE Sam Bostock via GitGitGadget
2026-02-06 19:16 ` [PATCH v2 2/2] merge-ours: integrate with sparse-index Sam Bostock via GitGitGadget
2026-02-09 15:05 ` [PATCH v2 0/2] merge-ours: sparse-index integration Patrick Steinhardt
2026-02-10 4:35 ` Derrick Stolee
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=pull.2189.v2.git.git.1770405383.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=git@vger.kernel.org \
--cc=ps@pks.im \
--cc=sam@sambostock.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox