3 test_description
="test performance of Git operations using the index"
11 test_expect_success
'setup repo and indexes' '
12 git reset --hard HEAD &&
14 # Remove submodules from the example repo, because our
15 # duplication of the entire repo creates an unlikely data shape.
16 if git config --file .gitmodules --get-regexp "submodule.*.path" >modules
18 git rm $(awk "{print \$2}" modules) &&
19 git commit -m "remove submodules" || return 1
25 git commit -m "level 0" &&
26 BLOB=$(git rev-parse HEAD:a) &&
27 OLD_COMMIT=$(git rev-parse HEAD) &&
28 OLD_TREE=$(git rev-parse HEAD^{tree}) &&
30 for i in $(test_seq 1 3)
34 040000 tree $OLD_TREE f1
35 040000 tree $OLD_TREE f2
36 040000 tree $OLD_TREE f3
37 040000 tree $OLD_TREE f4
39 NEW_TREE=$(git mktree <in) &&
40 NEW_COMMIT=$(git commit-tree $NEW_TREE -p $OLD_COMMIT -m "level $i") &&
42 OLD_COMMIT=$NEW_COMMIT || return 1
45 git sparse-checkout init --cone &&
46 git sparse-checkout set $SPARSE_CONE &&
47 git checkout -b wide $OLD_COMMIT &&
51 echo more bogus >>$SPARSE_CONE/$l2/a &&
52 git commit -a -m "edit $SPARSE_CONE/$l2/a" || return 1
55 git -c core.sparseCheckoutCone=true clone --branch=wide --sparse . full-v3 &&
58 git sparse-checkout init --cone &&
59 git sparse-checkout set $SPARSE_CONE &&
60 git config index.version 3 &&
61 git update-index --index-version=3 &&
64 git -c core.sparseCheckoutCone=true clone --branch=wide --sparse . full-v4 &&
67 git sparse-checkout init --cone &&
68 git sparse-checkout set $SPARSE_CONE &&
69 git config index.version 4 &&
70 git update-index --index-version=4 &&
73 git -c core.sparseCheckoutCone=true clone --branch=wide --sparse . sparse-v3 &&
76 git sparse-checkout init --cone --sparse-index &&
77 git sparse-checkout set $SPARSE_CONE &&
78 git config index.version 3 &&
79 git update-index --index-version=3 &&
82 git -c core.sparseCheckoutCone=true clone --branch=wide --sparse . sparse-v4 &&
85 git sparse-checkout init --cone --sparse-index &&
86 git sparse-checkout set $SPARSE_CONE &&
87 git config index.version 4 &&
88 git update-index --index-version=4 &&
95 for repo
in full-v3 full-v4 \
98 test_perf
"$command ($repo)" "
101 echo >>$SPARSE_CONE/a &&
108 test_perf_on_all git status
109 test_perf_on_all
'git stash && git stash pop'
110 test_perf_on_all
'echo >>new && git stash -u && git stash pop'
111 test_perf_on_all git add
-A
112 test_perf_on_all git add .
113 test_perf_on_all git commit
-a -m A
114 test_perf_on_all git checkout
-f -
115 test_perf_on_all
"git sparse-checkout add f2/f3/f1 && git sparse-checkout set $SPARSE_CONE"
116 test_perf_on_all git
reset
117 test_perf_on_all git
reset --hard
118 test_perf_on_all git
reset -- does-not-exist
119 test_perf_on_all git
diff
120 test_perf_on_all git
diff --cached
121 test_perf_on_all git blame
$SPARSE_CONE/a
122 test_perf_on_all git blame
$SPARSE_CONE/f
3/a
123 test_perf_on_all git read-tree
-mu HEAD
124 test_perf_on_all git checkout-index
-f --all
125 test_perf_on_all git update-index
--add --remove $SPARSE_CONE/a
126 test_perf_on_all
"git rm -f $SPARSE_CONE/a && git checkout HEAD -- $SPARSE_CONE/a"