Skip to content

Commit 4eaffd8

Browse files
derrickstoleegitster
authored andcommitted
pathspec: stop calling ensure_full_index
The add_pathspec_matches_against_index() focuses on matching a pathspec to file entries in the index. This already works correctly for its only use: checking if untracked files exist in the index. The compatibility checks in t1092 already test that 'git add <dir>' works for a directory outside of the sparse cone. That provides coverage for removing this guard. This finalizes our ability to run 'git add .' without expanding a sparse index to a full one. This is evidenced by an update to t1092 and by these performance numbers for p2000-sparse-operations.sh: Test HEAD~1 HEAD -------------------------------------------------------------------------------- 2000.10: git add . (full-index-v3) 0.37(0.28+0.07) 0.36(0.27+0.06) -2.7% 2000.11: git add . (full-index-v4) 0.33(0.26+0.06) 0.32(0.28+0.05) -3.0% 2000.12: git add . (sparse-index-v3) 0.57(0.53+0.07) 0.06(0.06+0.07) -89.5% 2000.13: git add . (sparse-index-v4) 0.57(0.53+0.07) 0.05(0.03+0.09) -91.2% While the ~90% improvement is shown by the test results, it is worth noting that expanding the sparse index was adding overhead in previous commits. Comparing to the full index case, we see the performance go from 0.33s to 0.05s, an 85% improvement. Reviewed-by: Elijah Newren <[email protected]> Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5e7cbab commit 4eaffd8

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

pathspec.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ void add_pathspec_matches_against_index(const struct pathspec *pathspec,
3737
num_unmatched++;
3838
if (!num_unmatched)
3939
return;
40-
/* TODO: audit for interaction with sparse-index. */
41-
ensure_full_index(istate);
4240
for (i = 0; i < istate->cache_nr; i++) {
4341
const struct cache_entry *ce = istate->cache[i];
4442
if (sw_action == PS_IGNORE_SKIP_WORKTREE && ce_skip_worktree(ce))

t/t1092-sparse-checkout-compatibility.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,6 @@ test_expect_success 'commit including unstaged changes' '
322322
test_expect_success 'status/add: outside sparse cone' '
323323
init_repos &&
324324
325-
# adding a "missing" file outside the cone should fail
326-
test_sparse_match test_must_fail git add folder1/a &&
327-
328325
# folder1 is at HEAD, but outside the sparse cone
329326
run_on_sparse mkdir folder1 &&
330327
cp initial-repo/folder1/a sparse-checkout/folder1/a &&
@@ -652,7 +649,9 @@ test_expect_success 'sparse-index is not expanded' '
652649
echo >>sparse-index/README.md &&
653650
ensure_not_expanded add -A &&
654651
echo >>sparse-index/extra.txt &&
655-
ensure_not_expanded add extra.txt
652+
ensure_not_expanded add extra.txt &&
653+
echo >>sparse-index/untracked.txt &&
654+
ensure_not_expanded add .
656655
'
657656

658657
# NEEDSWORK: a sparse-checkout behaves differently from a full checkout

0 commit comments

Comments
 (0)