From: Karthik Nayak Date: Tue, 10 Nov 2026 11:49:55 GMT Subject: [PATCH 10/20] t9300: make the ref update tests self-contained Message-ID: <20261110-kn-fast-import-tests-1-v1-10-dbd9ee502aae@gmail.com> In-Reply-To: <20261110-kn-fast-import-tests-1-v1-0-dbd9ee502aae@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. The tests used to build on the 'branch' branch of earlier tests. 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 9f4aea09dd..9576df78a1 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 <