From: Karthik Nayak Date: Thu, 12 Nov 2026 17:34:10 GMT Subject: [PATCH v2 10/20] t9300: make the ref update tests self-contained Message-ID: <20261112-kn-fast-import-tests-1-v2-10-b8c3a0ab27e8@gmail.com> In-Reply-To: <20261112-kn-fast-import-tests-1-v2-0-b8c3a0ab27e8@gmail.com> Similar to the previous commits, modify the reference update tests in series 'F', 'G', 'J' and 'K' to make them independent of state from previous tests. Add a 'setup_two_commit_repo()' function which creates a repository with two commits on 'main', so each test can invoke it. Fold the tests which only check the result of an import into the tests performing it, as they can't run on their own. As 'fastimport.unpackLimit' is no longer set by an earlier test, set it for the 'F' and 'G' imports so that a pack is written, and verify it with an inline loop in place of 'verify_packs()'. Signed-off-by: Karthik Nayak --- t/t9300-fast-import.sh | 214 +++++++++++++++++++++++++++---------------------- 1 file changed, 119 insertions(+), 95 deletions(-) diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh index 2231e1bdab..446cf0c51a 100755 --- a/t/t9300-fast-import.sh +++ b/t/t9300-fast-import.sh @@ -865,43 +865,53 @@ test_expect_success 'E: verify commit' ' ### series F ### +setup_two_commit_repo () { + test_when_finished "rm -rf repo" && + git init repo && + test_commit -C repo one && + test_commit -C repo two +} + test_expect_success 'F: non-fast-forward update skips' ' - old_branch=$(git rev-parse --verify branch^0) && - test_tick && - cat >input <<-INPUT_END && - commit refs/heads/branch - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <input <<-INPUT_END && + commit refs/heads/main + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <expect <<-EOF && - tree $(git rev-parse branch~1^{tree}) - parent $(git rev-parse branch~1) - author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + cat >expect <<-EOF && + tree $(git rev-parse main~1^{tree}) + parent $(git rev-parse main~1) + author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - losing things already? - EOF - git cat-file commit other >actual && - test_cmp expect actual + losing things already? + EOF + git cat-file commit other >actual && + test_cmp expect actual + ) ' ### @@ -909,28 +919,31 @@ test_expect_success 'F: verify other commit' ' ### test_expect_success 'G: non-fast-forward update forced' ' - old_branch=$(git rev-parse --verify branch^0) && - test_tick && - cat >input <<-INPUT_END && - commit refs/heads/branch - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <input <<-INPUT_END && + commit refs/heads/main + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <input <<-INPUT_END && - commit refs/heads/J - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <input <<-INPUT_END && + commit refs/heads/J + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data < $GIT_COMMITTER_DATE - data < $GIT_COMMITTER_DATE + data <input <<-INPUT_END && - reset refs/heads/J2 + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + cat >input <<-INPUT_END && + reset refs/heads/J2 - tag wrong_tag - from refs/heads/J2 - data <input <<-INPUT_END && - commit refs/heads/K - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <input <<-INPUT_END && + commit refs/heads/K + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data < $GIT_COMMITTER_DATE - data < $GIT_COMMITTER_DATE + data <