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