diff options
| author | Derrick Stolee <stolee@gmail.com> | 2025-05-16 14:55:28 +0000 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-05-16 12:01:51 -0700 |
| commit | 02ed8555f68440c5f533ad3c098ac01fc8965861 (patch) | |
| tree | 8dce22e7123a0a48cf57e9319e21882e7191af57 /builtin/add.c | |
| parent | 952de281fe63eb03e0dcc8adf773ce54cb581b83 (diff) | |
| download | git-02ed8555f68440c5f533ad3c098ac01fc8965861.tar.gz | |
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>
Diffstat (limited to 'builtin/add.c')
| -rw-r--r-- | builtin/add.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/builtin/add.c b/builtin/add.c index 78dfb26577..b96360dc5c 100644 --- a/builtin/add.c +++ b/builtin/add.c @@ -391,6 +391,10 @@ int cmd_add(int argc, argc = parse_options(argc, argv, prefix, builtin_add_options, builtin_add_usage, PARSE_OPT_KEEP_ARGV0); + + prepare_repo_settings(repo); + repo->settings.command_requires_full_index = 0; + if (patch_interactive) add_interactive = 1; if (add_interactive) { @@ -427,9 +431,6 @@ int cmd_add(int argc, add_new_files = !take_worktree_changes && !refresh_only && !add_renormalize; require_pathspec = !(take_worktree_changes || (0 < addremove_explicit)); - prepare_repo_settings(repo); - repo->settings.command_requires_full_index = 0; - repo_hold_locked_index(repo, &lock_file, LOCK_DIE_ON_ERROR); /* |
