Raw
1 #!/bin/sh
2
3 test_description='Test :/ object name notation'
4
5 . ./perf-lib.sh
6
7 test_perf_fresh_repo
8
9 #
10 # Creates lots of merges to make history traversal costly. In
11 # particular it creates 2^($max_level-1)-1 2-way merges on top of
12 # 2^($max_level-1) root commits. E.g., the commit history looks like
13 # this for a $max_level of 3:
14 #
15 # _1_
16 # / \
17 # 2 3
18 # / \ / \
19 # 4 5 6 7
20 #
21 # The numbers are the fast-import marks, which also are the commit
22 # messages. 1 is the HEAD commit and a merge, 2 and 3 are also merges,
23 # 4-7 are the root commits.
24 #
25 build_history () {
26 local max_level="$1" &&
27 local level="${2:-1}" &&
28 local mark="${3:-1}" &&
29 if test $level -eq $max_level
30 then
31 echo "reset refs/heads/master" &&
32 echo "from $ZERO_OID" &&
33 echo "commit refs/heads/master" &&
34 echo "mark :$mark" &&
35 echo "committer C <c@example.com> 1234567890 +0000" &&
36 echo "data <<EOF" &&
37 echo "$mark" &&
38 echo "EOF"
39 else
40 local level1=$((level+1)) &&
41 local mark1=$((2*mark)) &&
42 local mark2=$((2*mark+1)) &&
43 build_history $max_level $level1 $mark1 &&
44 build_history $max_level $level1 $mark2 &&
45 echo "commit refs/heads/master" &&
46 echo "mark :$mark" &&
47 echo "committer C <c@example.com> 1234567890 +0000" &&
48 echo "data <<EOF" &&
49 echo "$mark" &&
50 echo "EOF" &&
51 echo "from :$mark1" &&
52 echo "merge :$mark2"
53 fi
54 }
55
56 test_expect_success 'setup' '
57 build_history 16 | git fast-import &&
58 git log --format="%H %s" --reverse >commits &&
59 sed -n -e "s/ .*$//p" -e "q" <commits >expect &&
60 sed -n -e "s/^.* //p" -e "q" <commits >needle
61 '
62
63 test_perf "rev-parse :/$(cat needle)" '
64 git rev-parse :/$(cat needle) >actual
65 '
66
67 test_expect_success 'verify result' '
68 test_cmp expect actual
69 '
70
71 test_done