Makefile: some platforms do not have hstrerror anywhere
[git/gitweb.git] / t / t3302-notes-index-expensive.sh
blobee84fc4884676ef683e6b3d2b6ad718dc2817445
1 #!/bin/sh
3 # Copyright (c) 2007 Johannes E. Schindelin
6 test_description='Test commit notes index (expensive!)'
8 . ./test-lib.sh
10 test -z "$GIT_NOTES_TIMING_TESTS" && {
11 say Skipping timing tests
12 test_done
13 exit
16 create_repo () {
17 number_of_commits=$1
18 nr=0
19 test -d .git || {
20 git init &&
22 while [ $nr -lt $number_of_commits ]; do
23 nr=$(($nr+1))
24 mark=$(($nr+$nr))
25 notemark=$(($mark+1))
26 test_tick &&
27 cat <<INPUT_END &&
28 commit refs/heads/master
29 mark :$mark
30 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
31 data <<COMMIT
32 commit #$nr
33 COMMIT
35 M 644 inline file
36 data <<EOF
37 file in commit #$nr
38 EOF
40 blob
41 mark :$notemark
42 data <<EOF
43 note for commit #$nr
44 EOF
46 INPUT_END
48 echo "N :$notemark :$mark" >> note_commit
49 done &&
50 test_tick &&
51 cat <<INPUT_END &&
52 commit refs/notes/commits
53 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
54 data <<COMMIT
55 notes
56 COMMIT
58 INPUT_END
60 cat note_commit
61 ) |
62 git fast-import --quiet &&
63 git config core.notesRef refs/notes/commits
67 test_notes () {
68 count=$1 &&
69 git config core.notesRef refs/notes/commits &&
70 git log | grep "^ " > output &&
71 i=$count &&
72 while [ $i -gt 0 ]; do
73 echo " commit #$i" &&
74 echo " note for commit #$i" &&
75 i=$(($i-1));
76 done > expect &&
77 test_cmp expect output
80 cat > time_notes << \EOF
81 mode=$1
82 i=1
83 while [ $i -lt $2 ]; do
84 case $1 in
85 no-notes)
86 GIT_NOTES_REF=non-existing; export GIT_NOTES_REF
88 notes)
89 unset GIT_NOTES_REF
91 esac
92 git log >/dev/null
93 i=$(($i+1))
94 done
95 EOF
97 time_notes () {
98 for mode in no-notes notes
100 echo $mode
101 /usr/bin/time sh ../time_notes $mode $1
102 done
105 for count in 10 100 1000 10000; do
107 mkdir $count
108 (cd $count;
110 test_expect_success "setup $count" "create_repo $count"
112 test_expect_success 'notes work' "test_notes $count"
114 test_expect_success 'notes timing' "time_notes 100"
116 done
118 test_done