1#!/bin/sh
2#
3# Copyright (c) 2007 Johannes E. Schindelin
4#
56
test_description='Test commit notes index (expensive!)'
78
. ./test-lib.sh
910
test -z "$GIT_NOTES_TIMING_TESTS" && {
11skip_all="Skipping timing tests"
12test_done
13exit
14}
1516
create_repo () {
17number_of_commits=$1
18nr=0
19test -d .git || {
20git init &&
21(
22while [ $nr -lt $number_of_commits ]; do
23nr=$(($nr+1))
24mark=$(($nr+$nr))
25notemark=$(($mark+1))
26test_tick &&
27cat <<INPUT_END &&
28commit refs/heads/master
29mark :$mark
30committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
31data <<COMMIT
32commit #$nr
33COMMIT
3435
M 644 inline file
36data <<EOF
37file in commit #$nr
38EOF
3940
blob
41mark :$notemark
42data <<EOF
43note for commit #$nr
44EOF
4546
INPUT_END
4748
echo "N :$notemark :$mark" >> note_commit
49done &&
50test_tick &&
51cat <<INPUT_END &&
52commit refs/notes/commits
53committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
54data <<COMMIT
55notes
56COMMIT
5758
INPUT_END
5960
cat note_commit
61) |
62git fast-import --quiet &&
63git config core.notesRef refs/notes/commits
64}
65}
6667
test_notes () {
68count=$1 &&
69git config core.notesRef refs/notes/commits &&
70git log | grep "^ " > output &&
71i=$count &&
72while [ $i -gt 0 ]; do
73echo " commit #$i" &&
74echo " note for commit #$i" &&
75i=$(($i-1));
76done > expect &&
77test_cmp expect output
78}
7980
cat > time_notes << \EOF
81mode=$1
82i=1
83while [ $i -lt $2 ]; do
84case $1 in
85no-notes)
86GIT_NOTES_REF=non-existing; export GIT_NOTES_REF
87;;
88notes)
89unset GIT_NOTES_REF
90;;
91esac
92git log >/dev/null
93i=$(($i+1))
94done
95EOF
9697
time_notes () {
98for mode in no-notes notes
99do
100echo $mode
101/usr/bin/time sh ../time_notes $mode $1
102done
103}
104105
for count in 10 100 1000 10000; do
106107
mkdir $count
108(cd $count;
109110
test_expect_success "setup $count" "create_repo $count"
111112
test_expect_success 'notes work' "test_notes $count"
113114
test_expect_success 'notes timing' "time_notes 100"
115)
116done
117118
test_done