summaryrefslogtreecommitdiff
path: root/t/perf/p2000-sparse-operations.sh
blob: dddd527b633034014f72cafac68976780e01cc9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/sh

test_description="test performance of Git operations using the index"

. ./perf-lib.sh

test_perf_default_repo

SPARSE_CONE=f2/f4/f1

test_expect_success 'setup repo and indexes' '
	git reset --hard HEAD &&

	# Remove submodules from the example repo, because our
	# duplication of the entire repo creates an unlikely data shape.
	if git config --file .gitmodules --get-regexp "submodule.*.path" >modules
	then
		git rm $(awk "{print \$2}" modules) &&
		git commit -m "remove submodules" || return 1
	fi &&

	echo bogus >a &&
	cp a b &&
	git add a b &&
	git commit -m "level 0" &&
	BLOB=$(git rev-parse HEAD:a) &&
	OLD_COMMIT=$(git rev-parse HEAD) &&
	OLD_TREE=$(git rev-parse HEAD^{tree}) &&

	for i in $(test_seq 1 4)
	do
		cat >in <<-EOF &&
			100755 blob $BLOB	a
			040000 tree $OLD_TREE	f1
			040000 tree $OLD_TREE	f2
			040000 tree $OLD_TREE	f3
			040000 tree $OLD_TREE	f4
		EOF
		NEW_TREE=$(git mktree <in) &&
		NEW_COMMIT=$(git commit-tree $NEW_TREE -p $OLD_COMMIT -m "level $i") &&
		OLD_TREE=$NEW_TREE &&
		OLD_COMMIT=$NEW_COMMIT || return 1
	done &&

	git sparse-checkout init --cone &&
	git branch -f wide $OLD_COMMIT &&
	git -c core.sparseCheckoutCone=true clone --branch=wide --sparse . full-index-v3 &&
	(
		cd full-index-v3 &&
		git sparse-checkout init --cone &&
		git sparse-checkout set $SPARSE_CONE &&
		git config index.version 3 &&
		git update-index --index-version=3
	) &&
	git -c core.sparseCheckoutCone=true clone --branch=wide --sparse . full-index-v4 &&
	(
		cd full-index-v4 &&
		git sparse-checkout init --cone &&
		git sparse-checkout set $SPARSE_CONE &&
		git config index.version 4 &&
		git update-index --index-version=4
	)
'

test_perf_on_all () {
	command="$@"
	for repo in full-index-v3 full-index-v4
	do
		test_perf "$command ($repo)" "
			(
				cd $repo &&
				echo >>$SPARSE_CONE/a &&
				$command
			)
		"
	done
}

test_perf_on_all git status
test_perf_on_all git add -A
test_perf_on_all git add .
test_perf_on_all git commit -a -m A

test_done