t9301: Add 2nd testcase exposing bugs in fast-import's notes fanout handling

The previous patch exposed a bug in fast-import where _removing_ an existing note fails (when that note resides on a non-zero fanout level, and was added prior to this fast-import run). This patch demostrates the same issue when _changing_ an existing note (subject to the same circumstances). Discovered-by: Henrik Grubbström <grubba@roxen.com> Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johan Herland committed Nov 25, 2011 at 01:09 UTC 9ff5e21f0e2d0944535dbf4d35758a7e027ae0c6
1 file changed +54
t/t9301-fast-import-notes.sh
+54
@@ -505,6 +505,60 @@ test_expect_success 'verify that non-notes are untouched by a fanout change' '
505 test_cmp expect_non-note3 actual
506
507 '
508 +
509 +# Change the notes for the three top commits
510 +test_tick
511 +cat >input <<INPUT_END
512 +commit refs/notes/many_notes
513 +committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
514 +data <<COMMIT
515 +changing notes for the top three commits
516 +COMMIT
517 +from refs/notes/many_notes^0
518 +INPUT_END
519 +
520 +rm expect
521 +i=$num_commits
522 +j=0
523 +while test $j -lt 3
524 +do
525 + cat >>input <<INPUT_END
526 +N inline refs/heads/many_commits~$j
527 +data <<EOF
528 +changed note for commit #$i
529 +EOF
530 +INPUT_END
531 + cat >>expect <<EXPECT_END
532 + commit #$i
533 + changed note for commit #$i
534 +EXPECT_END
535 + i=$(($i - 1))
536 + j=$(($j + 1))
537 +done
538 +
539 +test_expect_failure 'change a few existing notes' '
540 +
541 + git fast-import <input &&
542 + GIT_NOTES_REF=refs/notes/many_notes git log -n3 refs/heads/many_commits |
543 + grep "^ " > actual &&
544 + test_cmp expect actual
545 +
546 +'
547 +
548 +test_expect_failure 'verify that changing notes respect existing fanout' '
549 +
550 + # None of the entries in the top-level notes tree should be a full SHA1
551 + git ls-tree --name-only refs/notes/many_notes |
552 + while read path
553 + do
554 + if test $(expr length "$path") -ge 40
555 + then
556 + return 1
557 + fi
558 + done
559 +
560 +'
561 +
562 remaining_notes=10
563 test_tick
564 cat >input <<INPUT_END