Skip to content

Commit 9ff5e21

Browse files
jherlandgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Johan Herland <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d107541 commit 9ff5e21

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

t/t9301-fast-import-notes.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,60 @@ test_expect_success 'verify that non-notes are untouched by a fanout change' '
505505
test_cmp expect_non-note3 actual
506506
507507
'
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+
508562
remaining_notes=10
509563
test_tick
510564
cat >input <<INPUT_END

0 commit comments

Comments
 (0)