]> git.ipfire.org Git - thirdparty/git.git/commit
git add: make -p/-i aware of sparse index
authorDerrick Stolee <stolee@gmail.com>
Fri, 16 May 2025 14:55:28 +0000 (14:55 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 16 May 2025 19:01:51 +0000 (12:01 -0700)
commit02ed8555f68440c5f533ad3c098ac01fc8965861
tree8dce22e7123a0a48cf57e9319e21882e7191af57
parent952de281fe63eb03e0dcc8adf773ce54cb581b83
git add: make -p/-i aware of sparse index

It is slow to expand a sparse index in-memory due to parsing of trees.
We aim to minimize that performance cost when possible. 'git add -p'
uses 'git apply' child processes to modify the index, but still there
are some expansions that occur.

It turns out that control flows out of cmd_add() in the interactive
cases before the lines that confirm that the builtin is integrated with
the sparse index.

Moving that integration point earlier in cmd_add() allows 'git add -i'
and 'git add -p' to operate without expanding a sparse index to a full
one.

Add test cases that confirm that these interactive add options work with
the sparse index.

Signed-off-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/add.c
t/t1092-sparse-checkout-compatibility.sh