]>
Commit | Line | Data |
---|---|---|
a5b0c24f JS |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2007 Johannes E. Schindelin | |
4 | # | |
5 | ||
6 | test_description='Test commit notes index (expensive!)' | |
7 | ||
8 | . ./test-lib.sh | |
9 | ||
a5b0c24f JS |
10 | create_repo () { |
11 | number_of_commits=$1 | |
12 | nr=0 | |
a5b0c24f JS |
13 | test -d .git || { |
14 | git init && | |
3ed24b6a | 15 | ( |
ac2803b9 JH |
16 | while test $nr -lt $number_of_commits |
17 | do | |
3ed24b6a JH |
18 | nr=$(($nr+1)) |
19 | mark=$(($nr+$nr)) | |
20 | notemark=$(($mark+1)) | |
21 | test_tick && | |
ac2803b9 JH |
22 | cat <<-INPUT_END && |
23 | commit refs/heads/master | |
24 | mark :$mark | |
25 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
26 | data <<COMMIT | |
27 | commit #$nr | |
28 | COMMIT | |
29 | ||
30 | M 644 inline file | |
31 | data <<EOF | |
32 | file in commit #$nr | |
33 | EOF | |
34 | ||
35 | blob | |
36 | mark :$notemark | |
37 | data <<EOF | |
38 | note for commit #$nr | |
39 | EOF | |
40 | ||
41 | INPUT_END | |
42 | echo "N :$notemark :$mark" >>note_commit | |
3ed24b6a | 43 | done && |
a5b0c24f | 44 | test_tick && |
ac2803b9 JH |
45 | cat <<-INPUT_END && |
46 | commit refs/notes/commits | |
47 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
48 | data <<COMMIT | |
49 | notes | |
50 | COMMIT | |
3ed24b6a | 51 | |
ac2803b9 | 52 | INPUT_END |
3ed24b6a JH |
53 | |
54 | cat note_commit | |
55 | ) | | |
56 | git fast-import --quiet && | |
a5b0c24f JS |
57 | git config core.notesRef refs/notes/commits |
58 | } | |
59 | } | |
60 | ||
61 | test_notes () { | |
62 | count=$1 && | |
63 | git config core.notesRef refs/notes/commits && | |
ac2803b9 | 64 | git log | grep "^ " >output && |
3ed24b6a | 65 | i=$count && |
ac2803b9 JH |
66 | while test $i -gt 0 |
67 | do | |
3ed24b6a JH |
68 | echo " commit #$i" && |
69 | echo " note for commit #$i" && | |
ac2803b9 JH |
70 | i=$(($i-1)) |
71 | done >expect && | |
3ed24b6a | 72 | test_cmp expect output |
a5b0c24f JS |
73 | } |
74 | ||
ac2803b9 | 75 | write_script time_notes <<\EOF |
a5b0c24f JS |
76 | mode=$1 |
77 | i=1 | |
ac2803b9 JH |
78 | while test $i -lt $2 |
79 | do | |
a5b0c24f JS |
80 | case $1 in |
81 | no-notes) | |
ac2803b9 JH |
82 | GIT_NOTES_REF=non-existing |
83 | export GIT_NOTES_REF | |
84 | ;; | |
a5b0c24f JS |
85 | notes) |
86 | unset GIT_NOTES_REF | |
ac2803b9 | 87 | ;; |
a5b0c24f | 88 | esac |
ac2803b9 | 89 | git log |
a5b0c24f | 90 | i=$(($i+1)) |
ac2803b9 | 91 | done >/dev/null |
a5b0c24f JS |
92 | EOF |
93 | ||
94 | time_notes () { | |
95 | for mode in no-notes notes | |
96 | do | |
97 | echo $mode | |
ac2803b9 | 98 | /usr/bin/time ../time_notes $mode $1 |
a5b0c24f JS |
99 | done |
100 | } | |
101 | ||
d0736f7b | 102 | do_tests () { |
19c8c4a9 | 103 | count=$1 pr=${2-} |
d0736f7b | 104 | |
f23b1d06 JH |
105 | test_expect_success $pr "setup $count" ' |
106 | mkdir "$count" && | |
107 | ( | |
108 | cd "$count" && | |
109 | create_repo "$count" | |
110 | ) | |
d0736f7b | 111 | ' |
a5b0c24f | 112 | |
f23b1d06 JH |
113 | test_expect_success $pr 'notes work' ' |
114 | ( | |
115 | cd "$count" && | |
116 | test_notes "$count" | |
117 | ) | |
118 | ' | |
d0736f7b | 119 | |
19c8c4a9 | 120 | test_expect_success "USR_BIN_TIME${pr:+,$pr}" 'notes timing with /usr/bin/time' ' |
f23b1d06 JH |
121 | ( |
122 | cd "$count" && | |
123 | time_notes 100 | |
124 | ) | |
125 | ' | |
d0736f7b | 126 | } |
a5b0c24f | 127 | |
19c8c4a9 | 128 | do_tests 10 |
ac2803b9 JH |
129 | for count in 100 1000 10000 |
130 | do | |
19c8c4a9 | 131 | do_tests "$count" EXPENSIVE |
a5b0c24f JS |
132 | done |
133 | ||
134 | test_done |