2009-10-09 12:22:00 +02:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Copyright (c) 2007 Johannes E. Schindelin
|
|
|
|
#
|
|
|
|
|
|
|
|
test_description='Test commit notes index (expensive!)'
|
|
|
|
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
2010-08-11 01:37:48 +02:00
|
|
|
test -n "$GIT_NOTES_TIMING_TESTS" && test_set_prereq EXPENSIVE
|
2009-10-09 12:22:00 +02:00
|
|
|
|
|
|
|
create_repo () {
|
|
|
|
number_of_commits=$1
|
|
|
|
nr=0
|
|
|
|
test -d .git || {
|
|
|
|
git init &&
|
2009-10-09 12:22:03 +02:00
|
|
|
(
|
2014-06-09 22:21:59 +02:00
|
|
|
while test $nr -lt $number_of_commits
|
|
|
|
do
|
2009-10-09 12:22:03 +02:00
|
|
|
nr=$(($nr+1))
|
|
|
|
mark=$(($nr+$nr))
|
|
|
|
notemark=$(($mark+1))
|
|
|
|
test_tick &&
|
2014-06-09 22:21:59 +02:00
|
|
|
cat <<-INPUT_END &&
|
|
|
|
commit refs/heads/master
|
|
|
|
mark :$mark
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
commit #$nr
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
M 644 inline file
|
|
|
|
data <<EOF
|
|
|
|
file in commit #$nr
|
|
|
|
EOF
|
|
|
|
|
|
|
|
blob
|
|
|
|
mark :$notemark
|
|
|
|
data <<EOF
|
|
|
|
note for commit #$nr
|
|
|
|
EOF
|
|
|
|
|
|
|
|
INPUT_END
|
|
|
|
echo "N :$notemark :$mark" >>note_commit
|
2009-10-09 12:22:03 +02:00
|
|
|
done &&
|
2009-10-09 12:22:00 +02:00
|
|
|
test_tick &&
|
2014-06-09 22:21:59 +02:00
|
|
|
cat <<-INPUT_END &&
|
|
|
|
commit refs/notes/commits
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
notes
|
|
|
|
COMMIT
|
2009-10-09 12:22:03 +02:00
|
|
|
|
2014-06-09 22:21:59 +02:00
|
|
|
INPUT_END
|
2009-10-09 12:22:03 +02:00
|
|
|
|
|
|
|
cat note_commit
|
|
|
|
) |
|
|
|
|
git fast-import --quiet &&
|
2009-10-09 12:22:00 +02:00
|
|
|
git config core.notesRef refs/notes/commits
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
test_notes () {
|
|
|
|
count=$1 &&
|
|
|
|
git config core.notesRef refs/notes/commits &&
|
2014-06-09 22:21:59 +02:00
|
|
|
git log | grep "^ " >output &&
|
2009-10-09 12:22:03 +02:00
|
|
|
i=$count &&
|
2014-06-09 22:21:59 +02:00
|
|
|
while test $i -gt 0
|
|
|
|
do
|
2009-10-09 12:22:03 +02:00
|
|
|
echo " commit #$i" &&
|
|
|
|
echo " note for commit #$i" &&
|
2014-06-09 22:21:59 +02:00
|
|
|
i=$(($i-1))
|
|
|
|
done >expect &&
|
2009-10-09 12:22:03 +02:00
|
|
|
test_cmp expect output
|
2009-10-09 12:22:00 +02:00
|
|
|
}
|
|
|
|
|
2014-06-09 22:21:59 +02:00
|
|
|
write_script time_notes <<\EOF
|
2009-10-09 12:22:00 +02:00
|
|
|
mode=$1
|
|
|
|
i=1
|
2014-06-09 22:21:59 +02:00
|
|
|
while test $i -lt $2
|
|
|
|
do
|
2009-10-09 12:22:00 +02:00
|
|
|
case $1 in
|
|
|
|
no-notes)
|
2014-06-09 22:21:59 +02:00
|
|
|
GIT_NOTES_REF=non-existing
|
|
|
|
export GIT_NOTES_REF
|
|
|
|
;;
|
2009-10-09 12:22:00 +02:00
|
|
|
notes)
|
|
|
|
unset GIT_NOTES_REF
|
2014-06-09 22:21:59 +02:00
|
|
|
;;
|
2009-10-09 12:22:00 +02:00
|
|
|
esac
|
2014-06-09 22:21:59 +02:00
|
|
|
git log
|
2009-10-09 12:22:00 +02:00
|
|
|
i=$(($i+1))
|
2014-06-09 22:21:59 +02:00
|
|
|
done >/dev/null
|
2009-10-09 12:22:00 +02:00
|
|
|
EOF
|
|
|
|
|
|
|
|
time_notes () {
|
|
|
|
for mode in no-notes notes
|
|
|
|
do
|
|
|
|
echo $mode
|
2014-06-09 22:21:59 +02:00
|
|
|
/usr/bin/time ../time_notes $mode $1
|
2009-10-09 12:22:00 +02:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2010-08-11 01:37:48 +02:00
|
|
|
do_tests () {
|
2014-06-09 22:43:19 +02:00
|
|
|
count=$1 pr=${2-}
|
2010-08-11 01:37:48 +02:00
|
|
|
|
2014-06-09 22:36:54 +02:00
|
|
|
test_expect_success $pr "setup $count" '
|
|
|
|
mkdir "$count" &&
|
|
|
|
(
|
|
|
|
cd "$count" &&
|
|
|
|
create_repo "$count"
|
|
|
|
)
|
2010-08-11 01:37:48 +02:00
|
|
|
'
|
2009-10-09 12:22:00 +02:00
|
|
|
|
2014-06-09 22:36:54 +02:00
|
|
|
test_expect_success $pr 'notes work' '
|
|
|
|
(
|
|
|
|
cd "$count" &&
|
|
|
|
test_notes "$count"
|
|
|
|
)
|
|
|
|
'
|
2010-08-11 01:37:48 +02:00
|
|
|
|
2014-06-09 22:43:19 +02:00
|
|
|
test_expect_success "USR_BIN_TIME${pr:+,$pr}" 'notes timing with /usr/bin/time' '
|
2014-06-09 22:36:54 +02:00
|
|
|
(
|
|
|
|
cd "$count" &&
|
|
|
|
time_notes 100
|
|
|
|
)
|
|
|
|
'
|
2010-08-11 01:37:48 +02:00
|
|
|
}
|
2009-10-09 12:22:00 +02:00
|
|
|
|
2014-06-09 22:43:19 +02:00
|
|
|
do_tests 10
|
2014-06-09 22:21:59 +02:00
|
|
|
for count in 100 1000 10000
|
|
|
|
do
|
2014-06-09 22:43:19 +02:00
|
|
|
do_tests "$count" EXPENSIVE
|
2009-10-09 12:22:00 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
test_done
|