Johan Herland | 048cdd4 | 2010-02-13 22:28:22 +0100 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
Johan Herland | b0032d1 | 2010-02-13 22:28:26 +0100 | [diff] [blame] | 3 | test_description='Test that adding/removing many notes triggers automatic fanout restructuring' |
Johan Herland | 048cdd4 | 2010-02-13 22:28:22 +0100 | [diff] [blame] | 4 | |
| 5 | . ./test-lib.sh |
| 6 | |
| 7 | test_expect_success 'creating many notes with git-notes' ' |
| 8 | num_notes=300 && |
| 9 | i=0 && |
| 10 | while test $i -lt $num_notes |
| 11 | do |
| 12 | i=$(($i + 1)) && |
| 13 | test_tick && |
| 14 | echo "file for commit #$i" > file && |
| 15 | git add file && |
| 16 | git commit -q -m "commit #$i" && |
Johan Herland | aaec9bc | 2010-02-13 22:28:34 +0100 | [diff] [blame] | 17 | git notes add -m "note #$i" || return 1 |
Johan Herland | 048cdd4 | 2010-02-13 22:28:22 +0100 | [diff] [blame] | 18 | done |
| 19 | ' |
| 20 | |
| 21 | test_expect_success 'many notes created correctly with git-notes' ' |
| 22 | git log | grep "^ " > output && |
| 23 | i=300 && |
| 24 | while test $i -gt 0 |
| 25 | do |
| 26 | echo " commit #$i" && |
| 27 | echo " note #$i" && |
| 28 | i=$(($i - 1)); |
| 29 | done > expect && |
| 30 | test_cmp expect output |
| 31 | ' |
| 32 | |
| 33 | test_expect_success 'many notes created with git-notes triggers fanout' ' |
| 34 | # Expect entire notes tree to have a fanout == 1 |
| 35 | git ls-tree -r --name-only refs/notes/commits | |
| 36 | while read path |
| 37 | do |
| 38 | case "$path" in |
| 39 | ??/??????????????????????????????????????) |
| 40 | : true |
| 41 | ;; |
| 42 | *) |
| 43 | echo "Invalid path \"$path\"" && |
| 44 | return 1 |
| 45 | ;; |
| 46 | esac |
| 47 | done |
| 48 | ' |
| 49 | |
Johan Herland | b0032d1 | 2010-02-13 22:28:26 +0100 | [diff] [blame] | 50 | test_expect_success 'deleting most notes with git-notes' ' |
| 51 | num_notes=250 && |
| 52 | i=0 && |
| 53 | git rev-list HEAD | |
Jeff King | 6636cf7 | 2015-03-25 01:28:57 -0400 | [diff] [blame] | 54 | while test $i -lt $num_notes && read sha1 |
Johan Herland | b0032d1 | 2010-02-13 22:28:26 +0100 | [diff] [blame] | 55 | do |
| 56 | i=$(($i + 1)) && |
Johan Herland | b0032d1 | 2010-02-13 22:28:26 +0100 | [diff] [blame] | 57 | test_tick && |
Jeff King | 6636cf7 | 2015-03-25 01:28:57 -0400 | [diff] [blame] | 58 | git notes remove "$sha1" || |
| 59 | exit 1 |
Johan Herland | b0032d1 | 2010-02-13 22:28:26 +0100 | [diff] [blame] | 60 | done |
| 61 | ' |
| 62 | |
| 63 | test_expect_success 'most notes deleted correctly with git-notes' ' |
| 64 | git log HEAD~250 | grep "^ " > output && |
| 65 | i=50 && |
| 66 | while test $i -gt 0 |
| 67 | do |
| 68 | echo " commit #$i" && |
| 69 | echo " note #$i" && |
| 70 | i=$(($i - 1)); |
| 71 | done > expect && |
| 72 | test_cmp expect output |
| 73 | ' |
| 74 | |
| 75 | test_expect_success 'deleting most notes triggers fanout consolidation' ' |
| 76 | # Expect entire notes tree to have a fanout == 0 |
| 77 | git ls-tree -r --name-only refs/notes/commits | |
| 78 | while read path |
| 79 | do |
| 80 | case "$path" in |
| 81 | ????????????????????????????????????????) |
| 82 | : true |
| 83 | ;; |
| 84 | *) |
| 85 | echo "Invalid path \"$path\"" && |
| 86 | return 1 |
| 87 | ;; |
| 88 | esac |
| 89 | done |
| 90 | ' |
| 91 | |
Johan Herland | 048cdd4 | 2010-02-13 22:28:22 +0100 | [diff] [blame] | 92 | test_done |