@@ -7,53 +7,51 @@ test_description='Test commit notes index (expensive!)'
77
88. ./test-lib.sh
99
10- test_set_prereq NOT_EXPENSIVE
1110test -n " $GIT_NOTES_TIMING_TESTS " && test_set_prereq EXPENSIVE
12- test -x /usr/bin/time && test_set_prereq USR_BIN_TIME
1311
1412create_repo () {
1513 number_of_commits=$1
1614 nr=0
1715 test -d .git || {
1816 git init &&
1917 (
20- while [ $nr -lt $number_of_commits ]; do
18+ while test $nr -lt $number_of_commits
19+ do
2120 nr=$(( $nr + 1 ))
2221 mark=$(( $nr + $nr ))
2322 notemark=$(( $mark + 1 ))
2423 test_tick &&
25- cat << INPUT_END &&
26- commit refs/heads/master
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-
46- echo " N :$notemark :$mark " >> note_commit
24+ cat << -INPUT_END &&
25+ commit refs/heads/master
26+ mark :$mark
27+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL > $GIT_COMMITTER_DATE
28+ data <<COMMIT
29+ commit #$nr
30+ COMMIT
31+
32+ M 644 inline file
33+ data <<EOF
34+ file in commit #$nr
35+ EOF
36+
37+ blob
38+ mark :$notemark
39+ data <<EOF
40+ note for commit #$nr
41+ EOF
42+
43+ INPUT_END
44+ echo " N :$notemark :$mark " >> note_commit
4745 done &&
4846 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
47+ cat << - INPUT_END &&
48+ commit refs/notes/commits
49+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL > $GIT_COMMITTER_DATE
50+ data <<COMMIT
51+ notes
52+ COMMIT
5553
56- INPUT_END
54+ INPUT_END
5755
5856 cat note_commit
5957 ) |
@@ -65,62 +63,74 @@ INPUT_END
6563test_notes () {
6664 count=$1 &&
6765 git config core.notesRef refs/notes/commits &&
68- git log | grep " ^ " > output &&
66+ git log | grep " ^ " > output &&
6967 i=$count &&
70- while [ $i -gt 0 ]; do
68+ while test $i -gt 0
69+ do
7170 echo " commit #$i " &&
7271 echo " note for commit #$i " &&
73- i=$(( $i - 1 )) ;
74- done > expect &&
72+ i=$(( $i - 1 ))
73+ done > expect &&
7574 test_cmp expect output
7675}
7776
78- cat > time_notes << \EOF
77+ write_script time_notes << \EOF
7978 mode=$1
8079 i=1
81- while [ $i -lt $2 ]; do
80+ while test $i -lt $2
81+ do
8282 case $1 in
8383 no-notes)
84- GIT_NOTES_REF=non-existing; export GIT_NOTES_REF
85- ;;
84+ GIT_NOTES_REF=non-existing
85+ export GIT_NOTES_REF
86+ ;;
8687 notes)
8788 unset GIT_NOTES_REF
88- ;;
89+ ;;
8990 esac
90- git log >/dev/null
91+ git log
9192 i=$(( $i + 1 ))
92- done
93+ done >/dev/null
9394EOF
9495
9596time_notes () {
9697 for mode in no-notes notes
9798 do
9899 echo $mode
99- /usr/bin/time " $SHELL_PATH " ../time_notes $mode $1
100+ /usr/bin/time ../time_notes $mode $1
100101 done
101102}
102103
103104do_tests () {
104- pr=$1
105- count=$2
106-
107- test_expect_success $pr ' setup / mkdir' '
108- mkdir $count &&
109- cd $count
105+ count=$1 pr=${2-}
106+
107+ test_expect_success $pr " setup $count " '
108+ mkdir "$count" &&
109+ (
110+ cd "$count" &&
111+ create_repo "$count"
112+ )
110113 '
111114
112- test_expect_success $pr " setup $count " " create_repo $count "
113-
114- test_expect_success $pr ' notes work' " test_notes $count "
115-
116- test_expect_success USR_BIN_TIME,$pr ' notes timing with /usr/bin/time' " time_notes 100"
115+ test_expect_success $pr ' notes work' '
116+ (
117+ cd "$count" &&
118+ test_notes "$count"
119+ )
120+ '
117121
118- test_expect_success $pr ' teardown / cd ..' ' cd ..'
122+ test_expect_success " USR_BIN_TIME${pr: +,$pr } " ' notes timing with /usr/bin/time' '
123+ (
124+ cd "$count" &&
125+ time_notes 100
126+ )
127+ '
119128}
120129
121- do_tests NOT_EXPENSIVE 10
122- for count in 100 1000 10000; do
123- do_tests EXPENSIVE $count
130+ do_tests 10
131+ for count in 100 1000 10000
132+ do
133+ do_tests " $count " EXPENSIVE
124134done
125135
126136test_done
0 commit comments