From: Karthik Nayak Date: Thu, 12 Nov 2026 17:34:04 GMT Subject: [PATCH v2 04/20] t9300: make the series S tests self-contained Message-ID: <20261112-kn-fast-import-tests-1-v2-4-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 S' to make them independent of state from previous tests. Replace the 'S: initialize for S tests' test with a 'setup_marks_repo()' function, so each test can invoke it to setup its own repo and tear it down when the test completes. 'S: from with garbage after mark must fail' used to create the 'S2' commit which 'S: merge with garbage after mark must fail' needs. Create that commit in the merge test instead. Signed-off-by: Karthik Nayak --- t/t9300-fast-import.sh | 332 +++++++++++++++++++++++++++++-------------------- 1 file changed, 198 insertions(+), 134 deletions(-) diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh index a0e322b866..f9359bbaf3 100755 --- a/t/t9300-fast-import.sh +++ b/t/t9300-fast-import.sh @@ -3100,10 +3100,12 @@ test_expect_success 'R: --git-completion-helper-all does not read from stdin' ' # # invalid dataref .. # -test_expect_success 'S: initialize for S tests' ' +setup_marks_repo () { + test_when_finished "rm -rf repo" && + git init repo && test_tick && - cat >input <<-INPUT_END && + cat >repo/input <<-INPUT_END && commit refs/heads/S mark :301 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE @@ -3140,142 +3142,168 @@ test_expect_success 'S: initialize for S tests' ' BLOB INPUT_END - git fast-import --export-marks=marks err && - commit refs/heads/S - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <err && + commit refs/heads/S + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <err && - commit refs/heads/S - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <err && + commit refs/heads/S + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <err && - commit refs/heads/S - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <err && + commit refs/heads/S + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <err && - commit refs/heads/S - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <err && + commit refs/heads/S + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <err && - commit refs/heads/S - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <err && + commit refs/heads/S + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <err && - commit refs/heads/S - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <err && + commit refs/heads/S + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <err && - commit refs/heads/Snotes - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <err && + commit refs/heads/Snotes + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <err && - commit refs/heads/S2 - mark :303 - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <err && + commit refs/heads/S2 + mark :303 + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data < $GIT_COMMITTER_DATE - data <err && - commit refs/heads/S - mark :304 - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data < $GIT_COMMITTER_DATE + data <err && + commit refs/heads/S + mark :304 + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <err && - tag refs/tags/Stag - from :302x - tagger $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <err && + tag refs/tags/Stag + from :302x + tagger $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <err && - cat-blob :403x - EOF - test_grep "after mark" err + setup_marks_repo && + ( + cd repo && + + test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && + cat-blob :403x + EOF + test_grep "after mark" err + ) ' # # ls markref # test_expect_success 'S: ls with garbage after mark must fail' ' - test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && - ls :302x hello.c - EOF - test_grep "space after mark" err + setup_marks_repo && + ( + cd repo && + + test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && + ls :302x hello.c + EOF + test_grep "space after mark" err + ) ' test_expect_success 'S: ls with garbage after sha1 must fail' ' - sha1=$(grep :302 marks | cut -d\ -f2) && - test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && - ls ${sha1}x hello.c - EOF - test_grep "space after tree-ish" err + setup_marks_repo && + ( + cd repo && + + sha1=$(grep :302 marks | cut -d\ -f2) && + test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && + ls ${sha1}x hello.c + EOF + test_grep "space after tree-ish" err + ) ' # -- 2.56.GIT