[PATCH v2 0/2] Sparse Index: diff and blame builtins
From: Lessley Dennington via GitGitGadget <hidden>
Date: 2021-10-15 21:20:41
This series is based on vd/sparse-reset. It integrates the sparse index with
git diff and git blame and includes:
1. tests added to t1092 and p2000 to establish the baseline functionality
of the commands
2. repository settings to enable the sparse index
The p2000 tests demonstrate a ~30% execution time reduction for 'git diff'
and a ~75% execution time reduction for 'git diff --staged' using a sparse
index. For 'git blame', the reduction time was ~60% for a file two levels
deep and ~30% for a file three levels deep.
Test before after
----------------------------------------------------------------
2000.30: git diff (full-v3) 0.37 0.36 -2.7%
2000.31: git diff (full-v4) 0.36 0.35 -2.8%
2000.32: git diff (sparse-v3) 0.46 0.30 -34.8%
2000.33: git diff (sparse-v4) 0.43 0.31 -27.9%
2000.34: git diff --staged (full-v3) 0.08 0.08 +0.0%
2000.35: git diff --staged (full-v4) 0.08 0.08 +0.0%
2000.36: git diff --staged (sparse-v3) 0.17 0.04 -76.5%
2000.37: git diff --staged (sparse-v4) 0.16 0.04 -75.0%
2000.62: git blame f2/f4/a (full-v3) 0.31 0.32 +3.2%
2000.63: git blame f2/f4/a (full-v4) 0.29 0.31 +6.9%
2000.64: git blame f2/f4/a (sparse-v3) 0.55 0.23 -58.2%
2000.65: git blame f2/f4/a (sparse-v4) 0.57 0.23 -59.6%
2000.66: git blame f2/f4/f3/a (full-v3) 0.77 0.85 +10.4%
2000.67: git blame f2/f4/f3/a (full-v4) 0.78 0.81 +3.8%
2000.68: git blame f2/f4/f3/a (sparse-v3) 1.07 0.72 -32.7%
2000.99: git blame f2/f4/f3/a (sparse-v4) 1.05 0.73 -30.5%
Changes since V1
================
* Fix failing diff partially-staged test in
t1092-sparse-checkout-compatibility.sh, which was breaking in seen.
Thanks, Lessley
Lessley Dennington (2):
diff: enable and test the sparse index
blame: enable and test the sparse index
builtin/blame.c | 3 ++
builtin/diff.c | 3 ++
t/perf/p2000-sparse-operations.sh | 4 ++
t/t1092-sparse-checkout-compatibility.sh | 69 +++++++++++++++++++++---
4 files changed, 72 insertions(+), 7 deletions(-)
base-commit: 57049e844c80d5fe1394e6d65b28705eabfd6585
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1050%2Fldennington%2Fdiff-blame-sparse-index-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1050/ldennington/diff-blame-sparse-index-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/1050
Range-diff vs v1:
1: 9a597233cf4 ! 1: ac33159d020 diff: enable and test the sparse index
@@ t/t1092-sparse-checkout-compatibility.sh: test_expect_success 'diff --staged' '
+ EOF
+
+ # Add file within cone
-+ test_all_match git sparse-checkout set deep &&
++ test_sparse_match git sparse-checkout set deep &&
+ run_on_all ../edit-contents deep/testfile &&
+ test_all_match git add deep/testfile &&
+ run_on_all ../edit-contents deep/testfile &&
@@ t/t1092-sparse-checkout-compatibility.sh: test_expect_success 'diff --staged' '
+ test_all_match git reset --hard &&
+ run_on_all mkdir newdirectory &&
+ run_on_all ../edit-contents newdirectory/testfile &&
-+ test_all_match git sparse-checkout set newdirectory &&
++ test_sparse_match git sparse-checkout set newdirectory &&
+ test_all_match git add newdirectory/testfile &&
+ run_on_all ../edit-contents newdirectory/testfile &&
-+ test_all_match git sparse-checkout set &&
++ test_sparse_match git sparse-checkout set &&
+
+ test_all_match git diff &&
+ test_all_match git diff --staged &&
+
+ # Merge conflict outside cone
-+ test_all_match git reset --hard &&
++ # The sparse checkout will report a warning that is not in the
++ # full checkout, so we use `run_on_all` instead of
++ # `test_all_match`
++ run_on_all git reset --hard &&
+ test_all_match git checkout merge-left &&
+ test_all_match test_must_fail git merge merge-right &&
+
2: ddcee003c92 = 2: a0b6a152c75 blame: enable and test the sparse index
--
gitgitgadget