Merge branch 'ds/mailmap'
[git/debian.git] / t / t3302-notes-index-expensive.sh
blobbc9d8ee1e6a8b223f084cdc405a52048630ba5b1
1 #!/bin/sh
3 # Copyright (c) 2007 Johannes E. Schindelin
6 test_description='Test commit notes index (expensive!)'
8 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
9 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
11 TEST_PASSES_SANITIZE_LEAK=true
12 . ./test-lib.sh
14 create_repo () {
15 number_of_commits=$1
16 nr=0
17 test -d .git || {
18 git init &&
20 while test $nr -lt $number_of_commits
22 nr=$(($nr+1))
23 mark=$(($nr+$nr))
24 notemark=$(($mark+1))
25 test_tick &&
26 cat <<-INPUT_END &&
27 commit refs/heads/main
28 mark :$mark
29 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
30 data <<COMMIT
31 commit #$nr
32 COMMIT
34 M 644 inline file
35 data <<EOF
36 file in commit #$nr
37 EOF
39 blob
40 mark :$notemark
41 data <<EOF
42 note for commit #$nr
43 EOF
45 INPUT_END
46 echo "N :$notemark :$mark" >>note_commit
47 done &&
48 test_tick &&
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
56 INPUT_END
58 cat note_commit
59 ) |
60 git fast-import --quiet &&
61 git config core.notesRef refs/notes/commits
65 test_notes () {
66 count=$1 &&
67 git config core.notesRef refs/notes/commits &&
68 git log | grep "^ " >output &&
69 i=$count &&
70 while test $i -gt 0
72 echo " commit #$i" &&
73 echo " note for commit #$i" &&
74 i=$(($i-1))
75 done >expect &&
76 test_cmp expect output
79 write_script time_notes <<\EOF
80 mode=$1
81 i=1
82 while test $i -lt $2
84 case $1 in
85 no-notes)
86 GIT_NOTES_REF=non-existing
87 export GIT_NOTES_REF
89 notes)
90 unset GIT_NOTES_REF
92 esac
93 git log
94 i=$(($i+1))
95 done >/dev/null
96 EOF
98 time_notes () {
99 for mode in no-notes notes
101 echo $mode
102 /usr/bin/time ../time_notes $mode $1
103 done
106 do_tests () {
107 count=$1 pr=${2-}
109 test_expect_success $pr "setup $count" '
110 mkdir "$count" &&
112 cd "$count" &&
113 create_repo "$count"
117 test_expect_success $pr 'notes work' '
119 cd "$count" &&
120 test_notes "$count"
124 test_expect_success "USR_BIN_TIME${pr:+,$pr}" 'notes timing with /usr/bin/time' '
126 cd "$count" &&
127 time_notes 100
132 do_tests 10
133 for count in 100 1000 10000
135 do_tests "$count" EXPENSIVE
136 done
138 test_done