]> git.ipfire.org Git - thirdparty/git.git/blob - t/perf/p2000-sparse-operations.sh
Merge branch 'en/fetch-negotiation-default-fix'
[thirdparty/git.git] / t / perf / p2000-sparse-operations.sh
1 #!/bin/sh
2
3 test_description="test performance of Git operations using the index"
4
5 . ./perf-lib.sh
6
7 test_perf_default_repo
8
9 SPARSE_CONE=f2/f4
10
11 test_expect_success 'setup repo and indexes' '
12 git reset --hard HEAD &&
13
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
17 then
18 git rm $(awk "{print \$2}" modules) &&
19 git commit -m "remove submodules" || return 1
20 fi &&
21
22 echo bogus >a &&
23 cp a b &&
24 git add a b &&
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}) &&
29
30 for i in $(test_seq 1 3)
31 do
32 cat >in <<-EOF &&
33 100755 blob $BLOB a
34 040000 tree $OLD_TREE f1
35 040000 tree $OLD_TREE f2
36 040000 tree $OLD_TREE f3
37 040000 tree $OLD_TREE f4
38 EOF
39 NEW_TREE=$(git mktree <in) &&
40 NEW_COMMIT=$(git commit-tree $NEW_TREE -p $OLD_COMMIT -m "level $i") &&
41 OLD_TREE=$NEW_TREE &&
42 OLD_COMMIT=$NEW_COMMIT || return 1
43 done &&
44
45 git sparse-checkout init --cone &&
46 git sparse-checkout set $SPARSE_CONE &&
47 git checkout -b wide $OLD_COMMIT &&
48
49 for l2 in f1 f2 f3 f4
50 do
51 echo more bogus >>$SPARSE_CONE/$l2/a &&
52 git commit -a -m "edit $SPARSE_CONE/$l2/a" || return 1
53 done &&
54
55 git -c core.sparseCheckoutCone=true clone --branch=wide --sparse . full-v3 &&
56 (
57 cd 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 &&
62 git checkout HEAD~4
63 ) &&
64 git -c core.sparseCheckoutCone=true clone --branch=wide --sparse . full-v4 &&
65 (
66 cd 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 &&
71 git checkout HEAD~4
72 ) &&
73 git -c core.sparseCheckoutCone=true clone --branch=wide --sparse . sparse-v3 &&
74 (
75 cd 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 &&
80 git checkout HEAD~4
81 ) &&
82 git -c core.sparseCheckoutCone=true clone --branch=wide --sparse . sparse-v4 &&
83 (
84 cd 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 &&
89 git checkout HEAD~4
90 )
91 '
92
93 test_perf_on_all () {
94 command="$@"
95 for repo in full-v3 full-v4 \
96 sparse-v3 sparse-v4
97 do
98 test_perf "$command ($repo)" "
99 (
100 cd $repo &&
101 echo >>$SPARSE_CONE/a &&
102 $command
103 )
104 "
105 done
106 }
107
108 test_perf_on_all git status
109 test_perf_on_all git add -A
110 test_perf_on_all git add .
111 test_perf_on_all git commit -a -m A
112 test_perf_on_all git checkout -f -
113 test_perf_on_all git reset
114 test_perf_on_all git reset --hard
115 test_perf_on_all git reset -- does-not-exist
116 test_perf_on_all git diff
117 test_perf_on_all git diff --cached
118 test_perf_on_all git blame $SPARSE_CONE/a
119 test_perf_on_all git blame $SPARSE_CONE/f3/a
120
121 test_done