Skip to content

Commit ac2803b

Browse files
committed
t3302: coding style updates
Use "<<-END_OF_HERE_TEXT" to push the contents of here-text to the right in order to show the loop structure better. Use write_script when writing a script to be run. Use "test" (not "[ ... ]") and avoid unnecessary ";" in the middle of a line. Signed-off-by: Junio C Hamano <[email protected]>
1 parent e1ecd9e commit ac2803b

File tree

1 file changed

+47
-43
lines changed

1 file changed

+47
-43
lines changed

t/t3302-notes-index-expensive.sh

Lines changed: 47 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -16,43 +16,43 @@ create_repo () {
1616
test -d .git || {
1717
git init &&
1818
(
19-
while [ $nr -lt $number_of_commits ]; do
19+
while test $nr -lt $number_of_commits
20+
do
2021
nr=$(($nr+1))
2122
mark=$(($nr+$nr))
2223
notemark=$(($mark+1))
2324
test_tick &&
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-
45-
echo "N :$notemark :$mark" >> note_commit
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+
echo "N :$notemark :$mark" >>note_commit
4646
done &&
4747
test_tick &&
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
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
5454
55-
INPUT_END
55+
INPUT_END
5656

5757
cat note_commit
5858
) |
@@ -64,38 +64,41 @@ INPUT_END
6464
test_notes () {
6565
count=$1 &&
6666
git config core.notesRef refs/notes/commits &&
67-
git log | grep "^ " > output &&
67+
git log | grep "^ " >output &&
6868
i=$count &&
69-
while [ $i -gt 0 ]; do
69+
while test $i -gt 0
70+
do
7071
echo " commit #$i" &&
7172
echo " note for commit #$i" &&
72-
i=$(($i-1));
73-
done > expect &&
73+
i=$(($i-1))
74+
done >expect &&
7475
test_cmp expect output
7576
}
7677

77-
cat > time_notes << \EOF
78+
write_script time_notes <<\EOF
7879
mode=$1
7980
i=1
80-
while [ $i -lt $2 ]; do
81+
while test $i -lt $2
82+
do
8183
case $1 in
8284
no-notes)
83-
GIT_NOTES_REF=non-existing; export GIT_NOTES_REF
84-
;;
85+
GIT_NOTES_REF=non-existing
86+
export GIT_NOTES_REF
87+
;;
8588
notes)
8689
unset GIT_NOTES_REF
87-
;;
90+
;;
8891
esac
89-
git log >/dev/null
92+
git log
9093
i=$(($i+1))
91-
done
94+
done >/dev/null
9295
EOF
9396

9497
time_notes () {
9598
for mode in no-notes notes
9699
do
97100
echo $mode
98-
/usr/bin/time "$SHELL_PATH" ../time_notes $mode $1
101+
/usr/bin/time ../time_notes $mode $1
99102
done
100103
}
101104

@@ -118,7 +121,8 @@ do_tests () {
118121
}
119122

120123
do_tests NOT_EXPENSIVE 10
121-
for count in 100 1000 10000; do
124+
for count in 100 1000 10000
125+
do
122126
do_tests EXPENSIVE $count
123127
done
124128

0 commit comments

Comments
 (0)