Johannes Schindelin | a5b0c24 | 2009-10-09 12:22:00 +0200 | [diff] [blame] | 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 | |
Johannes Schindelin | a5b0c24 | 2009-10-09 12:22:00 +0200 | [diff] [blame] | 10 | create_repo () { |
| 11 | number_of_commits=$1 |
| 12 | nr=0 |
Johannes Schindelin | a5b0c24 | 2009-10-09 12:22:00 +0200 | [diff] [blame] | 13 | test -d .git || { |
| 14 | git init && |
Johan Herland | 3ed24b6 | 2009-10-09 12:22:03 +0200 | [diff] [blame] | 15 | ( |
Junio C Hamano | ac2803b | 2014-06-09 13:21:59 -0700 | [diff] [blame] | 16 | while test $nr -lt $number_of_commits |
| 17 | do |
Johan Herland | 3ed24b6 | 2009-10-09 12:22:03 +0200 | [diff] [blame] | 18 | nr=$(($nr+1)) |
| 19 | mark=$(($nr+$nr)) |
| 20 | notemark=$(($mark+1)) |
| 21 | test_tick && |
Junio C Hamano | ac2803b | 2014-06-09 13:21:59 -0700 | [diff] [blame] | 22 | cat <<-INPUT_END && |
| 23 | commit refs/heads/master |
| 24 | mark :$mark |
| 25 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 26 | data <<COMMIT |
| 27 | commit #$nr |
| 28 | COMMIT |
Johan Herland | 3ed24b6 | 2009-10-09 12:22:03 +0200 | [diff] [blame] | 29 | |
Junio C Hamano | ac2803b | 2014-06-09 13:21:59 -0700 | [diff] [blame] | 30 | M 644 inline file |
| 31 | data <<EOF |
| 32 | file in commit #$nr |
| 33 | EOF |
Johan Herland | 3ed24b6 | 2009-10-09 12:22:03 +0200 | [diff] [blame] | 34 | |
Junio C Hamano | ac2803b | 2014-06-09 13:21:59 -0700 | [diff] [blame] | 35 | blob |
| 36 | mark :$notemark |
| 37 | data <<EOF |
| 38 | note for commit #$nr |
| 39 | EOF |
Johan Herland | 3ed24b6 | 2009-10-09 12:22:03 +0200 | [diff] [blame] | 40 | |
Junio C Hamano | ac2803b | 2014-06-09 13:21:59 -0700 | [diff] [blame] | 41 | INPUT_END |
| 42 | echo "N :$notemark :$mark" >>note_commit |
Johan Herland | 3ed24b6 | 2009-10-09 12:22:03 +0200 | [diff] [blame] | 43 | done && |
Johannes Schindelin | a5b0c24 | 2009-10-09 12:22:00 +0200 | [diff] [blame] | 44 | test_tick && |
Junio C Hamano | ac2803b | 2014-06-09 13:21:59 -0700 | [diff] [blame] | 45 | cat <<-INPUT_END && |
| 46 | commit refs/notes/commits |
| 47 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 48 | data <<COMMIT |
| 49 | notes |
| 50 | COMMIT |
Johan Herland | 3ed24b6 | 2009-10-09 12:22:03 +0200 | [diff] [blame] | 51 | |
Junio C Hamano | ac2803b | 2014-06-09 13:21:59 -0700 | [diff] [blame] | 52 | INPUT_END |
Johan Herland | 3ed24b6 | 2009-10-09 12:22:03 +0200 | [diff] [blame] | 53 | |
| 54 | cat note_commit |
| 55 | ) | |
| 56 | git fast-import --quiet && |
Johannes Schindelin | a5b0c24 | 2009-10-09 12:22:00 +0200 | [diff] [blame] | 57 | git config core.notesRef refs/notes/commits |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | test_notes () { |
| 62 | count=$1 && |
| 63 | git config core.notesRef refs/notes/commits && |
Junio C Hamano | ac2803b | 2014-06-09 13:21:59 -0700 | [diff] [blame] | 64 | git log | grep "^ " >output && |
Johan Herland | 3ed24b6 | 2009-10-09 12:22:03 +0200 | [diff] [blame] | 65 | i=$count && |
Junio C Hamano | ac2803b | 2014-06-09 13:21:59 -0700 | [diff] [blame] | 66 | while test $i -gt 0 |
| 67 | do |
Johan Herland | 3ed24b6 | 2009-10-09 12:22:03 +0200 | [diff] [blame] | 68 | echo " commit #$i" && |
| 69 | echo " note for commit #$i" && |
Junio C Hamano | ac2803b | 2014-06-09 13:21:59 -0700 | [diff] [blame] | 70 | i=$(($i-1)) |
| 71 | done >expect && |
Johan Herland | 3ed24b6 | 2009-10-09 12:22:03 +0200 | [diff] [blame] | 72 | test_cmp expect output |
Johannes Schindelin | a5b0c24 | 2009-10-09 12:22:00 +0200 | [diff] [blame] | 73 | } |
| 74 | |
Junio C Hamano | ac2803b | 2014-06-09 13:21:59 -0700 | [diff] [blame] | 75 | write_script time_notes <<\EOF |
Johannes Schindelin | a5b0c24 | 2009-10-09 12:22:00 +0200 | [diff] [blame] | 76 | mode=$1 |
| 77 | i=1 |
Junio C Hamano | ac2803b | 2014-06-09 13:21:59 -0700 | [diff] [blame] | 78 | while test $i -lt $2 |
| 79 | do |
Johannes Schindelin | a5b0c24 | 2009-10-09 12:22:00 +0200 | [diff] [blame] | 80 | case $1 in |
| 81 | no-notes) |
Junio C Hamano | ac2803b | 2014-06-09 13:21:59 -0700 | [diff] [blame] | 82 | GIT_NOTES_REF=non-existing |
| 83 | export GIT_NOTES_REF |
| 84 | ;; |
Johannes Schindelin | a5b0c24 | 2009-10-09 12:22:00 +0200 | [diff] [blame] | 85 | notes) |
| 86 | unset GIT_NOTES_REF |
Junio C Hamano | ac2803b | 2014-06-09 13:21:59 -0700 | [diff] [blame] | 87 | ;; |
Johannes Schindelin | a5b0c24 | 2009-10-09 12:22:00 +0200 | [diff] [blame] | 88 | esac |
Junio C Hamano | ac2803b | 2014-06-09 13:21:59 -0700 | [diff] [blame] | 89 | git log |
Johannes Schindelin | a5b0c24 | 2009-10-09 12:22:00 +0200 | [diff] [blame] | 90 | i=$(($i+1)) |
Junio C Hamano | ac2803b | 2014-06-09 13:21:59 -0700 | [diff] [blame] | 91 | done >/dev/null |
Johannes Schindelin | a5b0c24 | 2009-10-09 12:22:00 +0200 | [diff] [blame] | 92 | EOF |
| 93 | |
| 94 | time_notes () { |
| 95 | for mode in no-notes notes |
| 96 | do |
| 97 | echo $mode |
Junio C Hamano | ac2803b | 2014-06-09 13:21:59 -0700 | [diff] [blame] | 98 | /usr/bin/time ../time_notes $mode $1 |
Johannes Schindelin | a5b0c24 | 2009-10-09 12:22:00 +0200 | [diff] [blame] | 99 | done |
| 100 | } |
| 101 | |
Ævar Arnfjörð Bjarmason | d0736f7 | 2010-08-10 23:37:48 +0000 | [diff] [blame] | 102 | do_tests () { |
Junio C Hamano | 19c8c4a | 2014-06-09 13:43:19 -0700 | [diff] [blame] | 103 | count=$1 pr=${2-} |
Johannes Schindelin | a5b0c24 | 2009-10-09 12:22:00 +0200 | [diff] [blame] | 104 | |
Junio C Hamano | f23b1d0 | 2014-06-09 13:36:54 -0700 | [diff] [blame] | 105 | test_expect_success $pr "setup $count" ' |
| 106 | mkdir "$count" && |
| 107 | ( |
| 108 | cd "$count" && |
| 109 | create_repo "$count" |
| 110 | ) |
Ævar Arnfjörð Bjarmason | d0736f7 | 2010-08-10 23:37:48 +0000 | [diff] [blame] | 111 | ' |
Johannes Schindelin | a5b0c24 | 2009-10-09 12:22:00 +0200 | [diff] [blame] | 112 | |
Junio C Hamano | f23b1d0 | 2014-06-09 13:36:54 -0700 | [diff] [blame] | 113 | test_expect_success $pr 'notes work' ' |
| 114 | ( |
| 115 | cd "$count" && |
| 116 | test_notes "$count" |
| 117 | ) |
| 118 | ' |
Johannes Schindelin | a5b0c24 | 2009-10-09 12:22:00 +0200 | [diff] [blame] | 119 | |
Junio C Hamano | 19c8c4a | 2014-06-09 13:43:19 -0700 | [diff] [blame] | 120 | test_expect_success "USR_BIN_TIME${pr:+,$pr}" 'notes timing with /usr/bin/time' ' |
Junio C Hamano | f23b1d0 | 2014-06-09 13:36:54 -0700 | [diff] [blame] | 121 | ( |
| 122 | cd "$count" && |
| 123 | time_notes 100 |
| 124 | ) |
| 125 | ' |
Ævar Arnfjörð Bjarmason | d0736f7 | 2010-08-10 23:37:48 +0000 | [diff] [blame] | 126 | } |
| 127 | |
Junio C Hamano | 19c8c4a | 2014-06-09 13:43:19 -0700 | [diff] [blame] | 128 | do_tests 10 |
Junio C Hamano | ac2803b | 2014-06-09 13:21:59 -0700 | [diff] [blame] | 129 | for count in 100 1000 10000 |
| 130 | do |
Junio C Hamano | 19c8c4a | 2014-06-09 13:43:19 -0700 | [diff] [blame] | 131 | do_tests "$count" EXPENSIVE |
Johannes Schindelin | a5b0c24 | 2009-10-09 12:22:00 +0200 | [diff] [blame] | 132 | done |
| 133 | |
| 134 | test_done |