sparse-checkout: toggle sparse index from builtin
[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/f1
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 4)
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 branch -f wide $OLD_COMMIT &&
47         git -c core.sparseCheckoutCone=true clone --branch=wide --sparse . full-index-v3 &&
48         (
49                 cd full-index-v3 &&
50                 git sparse-checkout init --cone &&
51                 git sparse-checkout set $SPARSE_CONE &&
52                 git config index.version 3 &&
53                 git update-index --index-version=3
54         ) &&
55         git -c core.sparseCheckoutCone=true clone --branch=wide --sparse . full-index-v4 &&
56         (
57                 cd full-index-v4 &&
58                 git sparse-checkout init --cone &&
59                 git sparse-checkout set $SPARSE_CONE &&
60                 git config index.version 4 &&
61                 git update-index --index-version=4
62         )
63 '
64
65 test_perf_on_all () {
66         command="$@"
67         for repo in full-index-v3 full-index-v4
68         do
69                 test_perf "$command ($repo)" "
70                         (
71                                 cd $repo &&
72                                 echo >>$SPARSE_CONE/a &&
73                                 $command
74                         )
75                 "
76         done
77 }
78
79 test_perf_on_all git status
80 test_perf_on_all git add -A
81 test_perf_on_all git add .
82 test_perf_on_all git commit -a -m A
83
84 test_done