From: Karthik Nayak Date: Thu, 12 Nov 2026 17:34:08 GMT Subject: [PATCH v2 08/20] t9300: make the series O tests self-contained Message-ID: <20261112-kn-fast-import-tests-1-v2-8-b8c3a0ab27e8@gmail.com> In-Reply-To: <20261112-kn-fast-import-tests-1-v2-0-b8c3a0ab27e8@gmail.com> Similar to the previous commits, modify the tests in 'series O' to make them independent of state from previous tests. The tests import on top of 'branch' and compare the result against the 'N3' commit from series N. Import on top of a commit created by the new 'setup_import_repo()' function instead, and compare the result against the same commit imported from a stream without comments and with blank lines, so that the whole commit is still checked and not just its tree. The function sets 'fastimport.unpackLimit' to 0, which 'O: blank lines not necessary after other commands' relies on. Drop the 'O: repack before next test' test, and repack in the test which relies on it. Signed-off-by: Karthik Nayak --- t/t9300-fast-import.sh | 291 +++++++++++++++++++++++++++++++------------------ 1 file changed, 182 insertions(+), 109 deletions(-) diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh index 920fcd52b5..e0b9663452 100755 --- a/t/t9300-fast-import.sh +++ b/t/t9300-fast-import.sh @@ -1748,143 +1748,216 @@ done ### series O ### -test_expect_success 'O: comments are all skipped' ' - cat >input <<-INPUT_END && - #we will - commit refs/heads/O1 - # -- ignore all of this text +setup_import_repo () { + test_when_finished "rm -rf repo" && + git init repo && + git -C repo config fastimport.unpackLimit 0 && + mkdir repo/file2 && + echo abcd >repo/file2/file4 && + git -C repo add file2/file4 && + test_tick && + git -C repo commit -m base +} + +import_reference_commit () { + git fast-import <<-INPUT_END + commit refs/heads/$1 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <input <<-INPUT_END && + #we will + commit refs/heads/O1 + # -- ignore all of this text + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <expect <<-EOF && + 100644 blob $blob4 file2/file4 + 100644 blob $blob4 file3/file4 + 100644 blob $blob5 file3/file5 + EOF + git ls-tree -r O1 >actual && + test_cmp expect actual && + + import_reference_commit O1-reference && + test_cmp_rev O1-reference O1 + ) ' test_expect_success 'O: blank lines not necessary after data commands' ' - cat >input <<-INPUT_END && - commit refs/heads/O2 - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <input <<-INPUT_END && + commit refs/heads/O2 + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <expect <<-EOF && + 100644 blob $blob4 file2/file4 + 100644 blob $blob4 file3/file4 + 100644 blob $blob5 file3/file5 + EOF + git ls-tree -r O2 >actual && + test_cmp expect actual && + + import_reference_commit O2-reference && + test_cmp_rev O2-reference O2 + ) ' test_expect_success 'O: blank lines not necessary after other commands' ' - cat >input <<-INPUT_END && - commit refs/heads/O3 - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data < $GIT_COMMITTER_DATE - data < $GIT_COMMITTER_DATE - data < $GIT_COMMITTER_DATE - data <expect <<-INPUT_END && - string - of - empty - commits - INPUT_END + cat >input <<-INPUT_END && + commit refs/heads/O3 + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data < $GIT_COMMITTER_DATE + data < $GIT_COMMITTER_DATE + data < $GIT_COMMITTER_DATE + data <packlist && - ls -la .git/objects/pack/pack-*.pack >idxlist && - test_line_count = 4 idxlist && - test_line_count = 4 packlist && - test $(git rev-parse refs/tags/O3-2nd) = $(git rev-parse O3^) && - git log --reverse --pretty=oneline O3 | sed s/^.*z// >actual && - test_cmp expect actual + cat >expect <<-INPUT_END && + string + of + empty + commits + INPUT_END + + git fast-import packlist && + ls -la .git/objects/pack/pack-*.pack >idxlist && + test_line_count = 4 idxlist && + test_line_count = 4 packlist && + test $(git rev-parse refs/tags/O3-2nd) = $(git rev-parse O3^) && + git log --reverse --pretty=oneline O3 | sed s/^.*z// >actual && + test_cmp expect actual + ) ' test_expect_success 'O: progress outputs as requested by input' ' - cat >input <<-INPUT_END && - commit refs/heads/O4 - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data < $GIT_COMMITTER_DATE - data < $GIT_COMMITTER_DATE - data < $GIT_COMMITTER_DATE - data <actual && - grep "progress " expect && - test_cmp expect actual + setup_import_repo && + ( + cd repo && + + cat >input <<-INPUT_END && + commit refs/heads/O4 + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data < $GIT_COMMITTER_DATE + data < $GIT_COMMITTER_DATE + data < $GIT_COMMITTER_DATE + data <actual && + grep "progress " expect && + test_cmp expect actual + ) ' ### -- 2.56.GIT