]>
Commit | Line | Data |
---|---|---|
a5b0c24f JS |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2007 Johannes E. Schindelin | |
4 | # | |
5 | ||
6 | test_description='Test commit notes index (expensive!)' | |
7 | ||
8 | . ./test-lib.sh | |
9 | ||
d0736f7b ÆAB |
10 | test_set_prereq NOT_EXPENSIVE |
11 | test -n "$GIT_NOTES_TIMING_TESTS" && test_set_prereq EXPENSIVE | |
12 | test -x /usr/bin/time && test_set_prereq USR_BIN_TIME | |
a5b0c24f JS |
13 | |
14 | create_repo () { | |
15 | number_of_commits=$1 | |
16 | nr=0 | |
a5b0c24f JS |
17 | test -d .git || { |
18 | git init && | |
3ed24b6a JH |
19 | ( |
20 | while [ $nr -lt $number_of_commits ]; do | |
21 | nr=$(($nr+1)) | |
22 | mark=$(($nr+$nr)) | |
23 | notemark=$(($mark+1)) | |
24 | 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 | |
47 | done && | |
a5b0c24f | 48 | test_tick && |
3ed24b6a JH |
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 | |
55 | ||
56 | INPUT_END | |
57 | ||
58 | cat note_commit | |
59 | ) | | |
60 | git fast-import --quiet && | |
a5b0c24f JS |
61 | git config core.notesRef refs/notes/commits |
62 | } | |
63 | } | |
64 | ||
65 | test_notes () { | |
66 | count=$1 && | |
67 | git config core.notesRef refs/notes/commits && | |
68 | git log | grep "^ " > output && | |
3ed24b6a JH |
69 | i=$count && |
70 | while [ $i -gt 0 ]; do | |
71 | echo " commit #$i" && | |
72 | echo " note for commit #$i" && | |
73 | i=$(($i-1)); | |
a5b0c24f | 74 | done > expect && |
3ed24b6a | 75 | test_cmp expect output |
a5b0c24f JS |
76 | } |
77 | ||
78 | cat > time_notes << \EOF | |
79 | mode=$1 | |
80 | i=1 | |
81 | while [ $i -lt $2 ]; do | |
82 | case $1 in | |
83 | no-notes) | |
84 | GIT_NOTES_REF=non-existing; export GIT_NOTES_REF | |
85 | ;; | |
86 | notes) | |
87 | unset GIT_NOTES_REF | |
88 | ;; | |
89 | esac | |
90 | git log >/dev/null | |
91 | i=$(($i+1)) | |
92 | done | |
93 | EOF | |
94 | ||
95 | time_notes () { | |
96 | for mode in no-notes notes | |
97 | do | |
98 | echo $mode | |
6325ca31 | 99 | /usr/bin/time "$SHELL_PATH" ../time_notes $mode $1 |
a5b0c24f JS |
100 | done |
101 | } | |
102 | ||
d0736f7b ÆAB |
103 | do_tests () { |
104 | pr=$1 | |
105 | count=$2 | |
106 | ||
107 | test_expect_success $pr 'setup / mkdir' ' | |
108 | mkdir $count && | |
109 | cd $count | |
110 | ' | |
a5b0c24f | 111 | |
d0736f7b | 112 | test_expect_success $pr "setup $count" "create_repo $count" |
a5b0c24f | 113 | |
d0736f7b | 114 | test_expect_success $pr 'notes work' "test_notes $count" |
a5b0c24f | 115 | |
d0736f7b ÆAB |
116 | test_expect_success USR_BIN_TIME,$pr 'notes timing with /usr/bin/time' "time_notes 100" |
117 | ||
118 | test_expect_success $pr 'teardown / cd ..' 'cd ..' | |
119 | } | |
a5b0c24f | 120 | |
d0736f7b ÆAB |
121 | do_tests NOT_EXPENSIVE 10 |
122 | for count in 100 1000 10000; do | |
123 | do_tests EXPENSIVE $count | |
a5b0c24f JS |
124 | done |
125 | ||
126 | test_done |