Skip to content

merge-ours: sparse-index integration

Sam Bostock via GitGitGadget git 2 versions In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 2 repliesIn review
  2. v12 patches 3 repliesSuperseded

Changes in v2 from the cover letter

* 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)

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2merge-ours: drop USE_THE_REPOSITORY_VARIABLEbuiltin/merge-ours.c+3 -60 replies
2/2merge-ours: integrate with sparse-indexbuiltin/merge-ours.c t/t1092-sparse-checkout-compatibility.sh+20 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/2] merge-ours: sparse-index integration

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.

Signature · 1 line
gitgitgadget