fast-import: add a test for tree delta base corruption

fast-import is able to write imported tree objects in delta format. It holds a tree structure in memory where each tree entry may have a delta base sha1 assigned. When delta base data is needed it is reconstructed from this in-memory structure. Though sometimes the delta base data doesn't match the delta base sha1 so wrong or even corrupt pack is produced. Add a small test that produces a corrupt pack. It uses just tree copy and file modification commands aside from the very basic commit and blob commands. Signed-off-by: Dmitry Ivankov <divanorama@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Dmitry Ivankov committed Aug 15, 2011 at 00:32 UTC 9a0edb79f2f00c79b9dced22f67d226f6bb9c741
1 file changed +41
t/t9300-fast-import.sh
+41
@@ -734,6 +734,47 @@ test_expect_success \
734 git diff-tree --abbrev --raw L^ L >output &&
735 test_cmp expect output'
736
737 +cat >input <<INPUT_END
738 +blob
739 +mark :1
740 +data <<EOF
741 +the data
742 +EOF
743 +
744 +commit refs/heads/L2
745 +committer C O Mitter <committer@example.com> 1112912473 -0700
746 +data <<COMMIT
747 +init L2
748 +COMMIT
749 +M 644 :1 a/b/c
750 +M 644 :1 a/b/d
751 +M 644 :1 a/e/f
752 +
753 +commit refs/heads/L2
754 +committer C O Mitter <committer@example.com> 1112912473 -0700
755 +data <<COMMIT
756 +update L2
757 +COMMIT
758 +C a g
759 +C a/e g/b
760 +M 644 :1 g/b/h
761 +INPUT_END
762 +
763 +cat <<EOF >expect
764 +g/b/f
765 +g/b/h
766 +EOF
767 +
768 +test_expect_failure \
769 + 'L: nested tree copy does not corrupt deltas' \
770 + 'git fast-import <input &&
771 + git ls-tree L2 g/b/ >tmp &&
772 + cat tmp | cut -f 2 >actual &&
773 + test_cmp expect actual &&
774 + git fsck `git rev-parse L2`'
775 +
776 +git update-ref -d refs/heads/L2
777 +
778 ###
779 ### series M
780 ###