path: root/t/perf/
diff options
authorLessley Dennington <>2021-12-06 15:56:00 (GMT)
committerJunio C Hamano <>2021-12-06 17:55:06 (GMT)
commit51ba65b5c355a835fb0d83ee88dc7276dccb66a4 (patch)
tree015ba99c12a5f6560a1c5ce5ba6e54753940048c /t/perf/
parent338e2a9acc801ed4c5153b926579e7bea55a0be9 (diff)
diff: enable and test the sparse index
Enable the sparse index within the 'git diff' command. Its implementation already safely integrates with the sparse index because it shares code with the 'git status' and 'git checkout' commands that were already integrated. For more details see: d76723ee53 (status: use sparse-index throughout, 2021-07-14) 1ba5f45132 (checkout: stop expanding sparse indexes, 2021-06-29) The most interesting thing to do is to add tests that verify that 'git diff' behaves correctly when the sparse index is enabled. These cases are: 1. The index is not expanded for 'diff' and 'diff --staged' 2. 'diff' and 'diff --staged' behave the same in full checkout, sparse checkout, and sparse index repositories in the following partially-staged scenarios (i.e. the index, HEAD, and working directory differ at a given path): 1. Path is within sparse-checkout cone 2. Path is outside sparse-checkout cone 3. A merge conflict exists for paths outside sparse-checkout cone The `p2000` tests demonstrate a ~44% execution time reduction for 'git diff' and a ~86% execution time reduction for 'git diff --staged' using a sparse index: Test before after ------------------------------------------------------------- 2000.30: git diff (full-v3) 0.33 0.34 +3.0% 2000.31: git diff (full-v4) 0.33 0.35 +6.1% 2000.32: git diff (sparse-v3) 0.53 0.31 -41.5% 2000.33: git diff (sparse-v4) 0.54 0.29 -46.3% 2000.34: git diff --cached (full-v3) 0.07 0.07 +0.0% 2000.35: git diff --cached (full-v4) 0.07 0.08 +14.3% 2000.36: git diff --cached (sparse-v3) 0.28 0.04 -85.7% 2000.37: git diff --cached (sparse-v4) 0.23 0.03 -87.0% Co-authored-by: Derrick Stolee <> Signed-off-by: Lessley Dennington <> Reviewed-by: Elijah Newren <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 't/perf/')
1 files changed, 2 insertions, 0 deletions
diff --git a/t/perf/ b/t/perf/
index bfd3321..5cf9462 100755
--- a/t/perf/
+++ b/t/perf/
@@ -113,5 +113,7 @@ test_perf_on_all git checkout -f -
test_perf_on_all git reset
test_perf_on_all git reset --hard
test_perf_on_all git reset -- does-not-exist
+test_perf_on_all git diff
+test_perf_on_all git diff --cached