Merge branch 'jk/unavailable-can-be-missing'
[alt-git.git] / t / t3302-notes-index-expensive.sh
blob7217c5e222baf0b99b934e36b9418c9d8e13ae9d
1 #!/bin/sh
3 # Copyright (c) 2007 Johannes E. Schindelin
6 test_description='Test commit notes index (expensive!)'
8 . ./test-lib.sh
10 create_repo () {
11 number_of_commits=$1
12 nr=0
13 test -d .git || {
14 git init &&
16 while test $nr -lt $number_of_commits
18 nr=$(($nr+1))
19 mark=$(($nr+$nr))
20 notemark=$(($mark+1))
21 test_tick &&
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
30 M 644 inline file
31 data <<EOF
32 file in commit #$nr
33 EOF
35 blob
36 mark :$notemark
37 data <<EOF
38 note for commit #$nr
39 EOF
41 INPUT_END
42 echo "N :$notemark :$mark" >>note_commit
43 done &&
44 test_tick &&
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
52 INPUT_END
54 cat note_commit
55 ) |
56 git fast-import --quiet &&
57 git config core.notesRef refs/notes/commits
61 test_notes () {
62 count=$1 &&
63 git config core.notesRef refs/notes/commits &&
64 git log | grep "^ " >output &&
65 i=$count &&
66 while test $i -gt 0
68 echo " commit #$i" &&
69 echo " note for commit #$i" &&
70 i=$(($i-1))
71 done >expect &&
72 test_cmp expect output
75 write_script time_notes <<\EOF
76 mode=$1
77 i=1
78 while test $i -lt $2
80 case $1 in
81 no-notes)
82 GIT_NOTES_REF=non-existing
83 export GIT_NOTES_REF
85 notes)
86 unset GIT_NOTES_REF
88 esac
89 git log
90 i=$(($i+1))
91 done >/dev/null
92 EOF
94 time_notes () {
95 for mode in no-notes notes
97 echo $mode
98 /usr/bin/time ../time_notes $mode $1
99 done
102 do_tests () {
103 count=$1 pr=${2-}
105 test_expect_success $pr "setup $count" '
106 mkdir "$count" &&
108 cd "$count" &&
109 create_repo "$count"
113 test_expect_success $pr 'notes work' '
115 cd "$count" &&
116 test_notes "$count"
120 test_expect_success "USR_BIN_TIME${pr:+,$pr}" 'notes timing with /usr/bin/time' '
122 cd "$count" &&
123 time_notes 100
128 do_tests 10
129 for count in 100 1000 10000
131 do_tests "$count" EXPENSIVE
132 done
134 test_done