1#!/bin/sh2#3# Copyright (c) 2007 Johannes E. Schindelin4#56test_description='Test commit notes index (expensive!)'78. ./test-lib.sh910create_repo () {11number_of_commits=$112nr=013test -d .git || {14git init &&15(16while test $nr -lt $number_of_commits17do18nr=$(($nr+1))19mark=$(($nr+$nr))20notemark=$(($mark+1))21test_tick &&22cat <<-INPUT_END &&23commit refs/heads/master24mark :$mark25committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE26data <<COMMIT27commit #$nr28COMMIT2930M 644 inline file31data <<EOF32file in commit #$nr33EOF3435blob36mark :$notemark37data <<EOF38note for commit #$nr39EOF4041INPUT_END42echo "N :$notemark :$mark" >>note_commit43done &&44test_tick &&45cat <<-INPUT_END &&46commit refs/notes/commits47committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE48data <<COMMIT49notes50COMMIT5152INPUT_END5354cat note_commit55) |56git fast-import --quiet &&57git config core.notesRef refs/notes/commits58}59}6061test_notes () {62count=$1 &&63git config core.notesRef refs/notes/commits &&64git log | grep "^ " >output &&65i=$count &&66while test $i -gt 067do68echo " commit #$i" &&69echo " note for commit #$i" &&70i=$(($i-1))71done >expect &&72test_cmp expect output73}7475write_script time_notes <<\EOF76mode=$177i=178while test $i -lt $279do80case $1 in81no-notes)82GIT_NOTES_REF=non-existing83export GIT_NOTES_REF84;;85notes)86unset GIT_NOTES_REF87;;88esac89git log90i=$(($i+1))91done >/dev/null92EOF9394time_notes () {95for mode in no-notes notes96do97echo $mode98/usr/bin/time ../time_notes $mode $199done100}101102do_tests () {103count=$1 pr=${2-}104105test_expect_success $pr "setup $count" '106mkdir "$count" &&107(108cd "$count" &&109create_repo "$count"110)111'112113test_expect_success $pr 'notes work' '114(115cd "$count" &&116test_notes "$count"117)118'119120test_expect_success "USR_BIN_TIME${pr:+,$pr}" 'notes timing with /usr/bin/time' '121(122cd "$count" &&123time_notes 100124)125'126}127128do_tests 10129for count in 100 1000 10000130do131do_tests "$count" EXPENSIVE132done133134test_done