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