t9300: group and move tests to other files
cover t9300: group and move tests to other files
While reading the git-fast-import(1) code, I stumbled upon t9300. The test file is around 4000 LoC and each test has some dependency on the state setup by previous tests.
This long series unwinds some of these tests and moves them into new/existing tests based on what they exercise. This leaves t9300 in a better state. I think we can do more here, but I decided to stop before this series got even longer. Based on the reception of this series, I will follow up with more cleanups.
Also, we could squash some of the commits together. But I found them easier to read through this way.
---
Karthik Nayak (20):
t9300: move 'fastimport.unpackLimit' to the required test
t9300: make the series B tests self-contained
t9300: make the series T tests self-contained
t9300: make the series S tests self-contained
t9300: make the series V tests self-contained
t9300: make the series Q tests self-contained
t9300: make the series P tests self-contained
t9300: make the series O tests self-contained
t9300: make the big blob tests self-contained
t9300: make the ref update tests self-contained
t9300: make the date format tests self-contained
t9300: make the pack edges test self-contained
t9300: make the marks tests self-contained
t9300: make the series Y tests self-contained
t9300: make the cat-blob tests self-contained
t9300: make the feature and option tests self-contained
t9300: make the stream tests self-contained
t9300: make the get-mark and encoding tests self-contained
t9300: move self-contained tests into dedicated files
t93xx: drop the series letter from the moved test names
t/meson.build | 5 + t/t9300-fast-import.sh | 2780 +------------------------------------ t/t9301-fast-import-notes.sh | 411 ++++++ t/t9304-fast-import-marks.sh | 393 ++++++ t/t9307-fast-import-validation.sh | 1193 ++++++++++++++++ t/t9308-fast-import-stream.sh | 822 +++++++++++ t/t9309-fast-import-checkpoint.sh | 188 +++ t/t9310-fast-import-submodule.sh | 341 +++++ t/t9311-fast-import-refs.sh | 194 +++ 9 files changed, 3548 insertions(+), 2779 deletions(-)
---
base-commit: 8d1b215c01512b9658d4525c54ff9b9245f9a7e8
change-id: 20261102-kn-fast-import-tests-1-03de57101c3b
Thanks
- Karthik
PATCH 1/20 t9300: move 'fastimport.unpackLimit' to the required test
The 'empty stream succeeds' test sets 'fastimport.unpackLimit' to '0', so that the following imports write packs for the 'verify pack' tests to check. The test itself doesn't need it. A following commit makes it run in its own repository, where the setting would no longer reach the tests after it.
Move the configuration to 'A: create pack from stdin', the first test which needs it. The configuration must persist for the 'verify pack' tests of the following series, so set it with 'git config' and not with 'test_config'.
--- t/t9300-fast-import.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
t/t9300-fast-import.sh +1 -1
@@ -38,7 +38,6 @@ echo "$@"' ### test_expect_success 'empty stream succeeds' ' - git config fastimport.unpackLimit 0 && git fast-import </dev/null '
@@ -47,6 +46,7 @@ test_expect_success 'truncated stream complains' ' ' test_expect_success 'A: create pack from stdin' ' + git config fastimport.unpackLimit 0 && test_tick && cat >input <<-INPUT_END && blob
Signature · 1 line
2.56.GIT
PATCH 2/20 t9300: make the series B tests self-contained
In reply to Karthik NayakThe 't/t9300-fast-import.sh' test file contains numerous tests and is currently just shy of 4000 lines. This is because the file contains tests over multiple series, each series testing particular functionality or sections of 'git-fast-import(1)'. In upcoming commits, we want to split out these tests into individual files for better discoverability.
First, we need to remove the dependency tests have on preceding tests. Modify the tests in 'series B' to each run in a new repository, which is removed when the test completes, so that they neither depend on nor leave behind any state.
The 'B: fail on invalid blob sha1' and 'B: accept branch name "TEMP_TAG"' tests import on top of 'main', which used to exist from earlier tests. Create it with 'test_commit', so that the first import can only fail because of the invalid blob ID.
The 'fsck' tests require the whole repository to be free of unreachable objects. They only passed because of the garbage collection in the cleanup of other tests. A new repository makes that unnecessary.
--- t/t9300-fast-import.sh | 472 ++++++++++++++++++++++++++++--------------------- 1 file changed, 275 insertions(+), 197 deletions(-)
t/t9300-fast-import.sh +275 -197
@@ -358,274 +358,352 @@ test_expect_success 'A: export marks with large values' ' ### test_expect_success 'B: fail on invalid blob sha1' ' - test_tick && - cat >input <<-INPUT_END && - commit refs/heads/branch - mark :1 - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <<COMMIT - corrupt - COMMIT + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + test_commit base && - from refs/heads/main - M 755 $(echo $ZERO_OID | sed -e "s/0$/1/") zero1 + test_tick && + cat >input <<-INPUT_END && + commit refs/heads/branch + mark :1 + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <<COMMIT + corrupt + COMMIT - INPUT_END + from refs/heads/main + M 755 $(echo $ZERO_OID | sed -e "s/0$/1/") zero1 - test_when_finished "rm -f .git/objects/pack_* .git/objects/index_*" && - test_must_fail git fast-import <input + INPUT_END + + test_must_fail git fast-import <input + ) ' test_expect_success 'B: accept branch name "TEMP_TAG"' ' - cat >input <<-INPUT_END && - commit TEMP_TAG - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <<COMMIT - tag base - COMMIT + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + test_commit new && - from refs/heads/main + cat >input <<-INPUT_END && + commit TEMP_TAG + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <<COMMIT + tag base + COMMIT - INPUT_END + from refs/heads/main - test_when_finished "rm -f .git/TEMP_TAG && git gc --prune=now" && - git fast-import <input && - test $(test-tool ref-store main resolve-ref TEMP_TAG 0 | cut -f1 -d " " ) != "$ZERO_OID" && - test $(git rev-parse main) = $(git rev-parse TEMP_TAG^) + INPUT_END + + git fast-import <input && + test $(test-tool ref-store main resolve-ref TEMP_TAG 0 | cut -f1 -d " " ) != "$ZERO_OID" && + test $(git rev-parse main) = $(git rev-parse TEMP_TAG^) + ) ' test_expect_success 'B: accept empty committer' ' - cat >input <<-INPUT_END && - commit refs/heads/empty-committer-1 - committer <> $GIT_COMMITTER_DATE - data <<COMMIT - empty commit - COMMIT - INPUT_END + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + cat >input <<-INPUT_END && + commit refs/heads/empty-committer-1 + committer <> $GIT_COMMITTER_DATE + data <<COMMIT + empty commit + COMMIT + INPUT_END - test_when_finished "git update-ref -d refs/heads/empty-committer-1 - git gc --prune=now" && - git fast-import <input && - out=$(git fsck) && - echo "$out" && - test -z "$out" + git fast-import <input && + out=$(git fsck) && + echo "$out" && + test -z "$out" + ) ' test_expect_success 'B: reject invalid timezone' ' - cat >input <<-INPUT_END && - commit refs/heads/invalid-timezone - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1234567890 +051800 - data <<COMMIT - empty commit - COMMIT - INPUT_END + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && - test_when_finished "git update-ref -d refs/heads/invalid-timezone" && - test_must_fail git fast-import <input + cat >input <<-INPUT_END && + commit refs/heads/invalid-timezone + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1234567890 +051800 + data <<COMMIT + empty commit + COMMIT + INPUT_END + + test_must_fail git fast-import <input + ) ' test_expect_success 'B: accept invalid timezone with raw-permissive' ' - cat >input <<-INPUT_END && - commit refs/heads/invalid-timezone - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1234567890 +051800 - data <<COMMIT - empty commit - COMMIT - INPUT_END + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && - git init invalid-timezone && - git -C invalid-timezone fast-import --date-format=raw-permissive <input && - git -C invalid-timezone cat-file -p invalid-timezone >out && - test_grep "1234567890 [+]051800" out + cat >input <<-INPUT_END && + commit refs/heads/invalid-timezone + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1234567890 +051800 + data <<COMMIT + empty commit + COMMIT + INPUT_END + + git fast-import --date-format=raw-permissive <input && + git cat-file -p invalid-timezone >out && + test_grep "1234567890 [+]051800" out + ) ' test_expect_success 'B: accept and fixup committer with no name' ' - cat >input <<-INPUT_END && - commit refs/heads/empty-committer-2 - committer <[email protected]> $GIT_COMMITTER_DATE - data <<COMMIT - empty commit - COMMIT - INPUT_END + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + cat >input <<-INPUT_END && + commit refs/heads/empty-committer-2 + committer <[email protected]> $GIT_COMMITTER_DATE + data <<COMMIT + empty commit + COMMIT + INPUT_END - test_when_finished "git update-ref -d refs/heads/empty-committer-2 - git gc --prune=now" && - git fast-import <input && - out=$(git fsck) && - echo "$out" && - test -z "$out" + git fast-import <input && + out=$(git fsck) && + echo "$out" && + test -z "$out" + ) ' test_expect_success 'B: fail on invalid committer (1)' ' - cat >input <<-INPUT_END && - commit refs/heads/invalid-committer - committer Name email> $GIT_COMMITTER_DATE - data <<COMMIT - empty commit - COMMIT - INPUT_END + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && - test_when_finished "git update-ref -d refs/heads/invalid-committer" && - test_must_fail git fast-import <input + cat >input <<-INPUT_END && + commit refs/heads/invalid-committer + committer Name email> $GIT_COMMITTER_DATE + data <<COMMIT + empty commit + COMMIT + INPUT_END + + test_must_fail git fast-import <input + ) ' test_expect_success 'B: fail on invalid committer (2)' ' - cat >input <<-INPUT_END && - commit refs/heads/invalid-committer - committer Name <e<mail> $GIT_COMMITTER_DATE - data <<COMMIT - empty commit - COMMIT - INPUT_END + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && - test_when_finished "git update-ref -d refs/heads/invalid-committer" && - test_must_fail git fast-import <input + cat >input <<-INPUT_END && + commit refs/heads/invalid-committer + committer Name <e<mail> $GIT_COMMITTER_DATE + data <<COMMIT + empty commit + COMMIT + INPUT_END + + test_must_fail git fast-import <input + ) ' test_expect_success 'B: fail on invalid committer (3)' ' - cat >input <<-INPUT_END && - commit refs/heads/invalid-committer - committer Name <email>> $GIT_COMMITTER_DATE - data <<COMMIT - empty commit - COMMIT - INPUT_END + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && - test_when_finished "git update-ref -d refs/heads/invalid-committer" && - test_must_fail git fast-import <input + cat >input <<-INPUT_END && + commit refs/heads/invalid-committer + committer Name <email>> $GIT_COMMITTER_DATE + data <<COMMIT + empty commit + COMMIT + INPUT_END + + test_must_fail git fast-import <input + ) ' test_expect_success 'B: fail on invalid committer (4)' ' - cat >input <<-INPUT_END && - commit refs/heads/invalid-committer - committer Name <email $GIT_COMMITTER_DATE - data <<COMMIT - empty commit - COMMIT - INPUT_END + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && - test_when_finished "git update-ref -d refs/heads/invalid-committer" && - test_must_fail git fast-import <input + cat >input <<-INPUT_END && + commit refs/heads/invalid-committer + committer Name <email $GIT_COMMITTER_DATE + data <<COMMIT + empty commit + COMMIT + INPUT_END + + test_must_fail git fast-import <input + ) ' test_expect_success 'B: fail on invalid committer (5)' ' - cat >input <<-INPUT_END && - commit refs/heads/invalid-committer - committer Name<email> $GIT_COMMITTER_DATE - data <<COMMIT - empty commit - COMMIT - INPUT_END + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && - test_when_finished "git update-ref -d refs/heads/invalid-committer" && - test_must_fail git fast-import <input + cat >input <<-INPUT_END && + commit refs/heads/invalid-committer + committer Name<email> $GIT_COMMITTER_DATE + data <<COMMIT + empty commit + COMMIT + INPUT_END + + test_must_fail git fast-import <input + ) ' test_expect_success 'B: fail on invalid file path of ..' ' - cat >input <<-INPUT_END && - blob - mark :1 - data <<EOF - File contents - EOF + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && - commit refs/heads/badpath - committer Name <email> $GIT_COMMITTER_DATE - data <<COMMIT - Commit Message - COMMIT - M 100644 :1 ../invalid-path - INPUT_END + cat >input <<-INPUT_END && + blob + mark :1 + data <<EOF + File contents + EOF - test_when_finished "git update-ref -d refs/heads/badpath" && - test_must_fail git fast-import <input + commit refs/heads/badpath + committer Name <email> $GIT_COMMITTER_DATE + data <<COMMIT + Commit Message + COMMIT + M 100644 :1 ../invalid-path + INPUT_END + + test_must_fail git fast-import <input + ) ' test_expect_success 'B: fail on invalid file path of .' ' - cat >input <<-INPUT_END && - blob - mark :1 - data <<EOF - File contents - EOF + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && - commit refs/heads/badpath - committer Name <email> $GIT_COMMITTER_DATE - data <<COMMIT - Good path - COMMIT - M 100644 :1 ok-path + cat >input <<-INPUT_END && + blob + mark :1 + data <<EOF + File contents + EOF - commit refs/heads/badpath - committer Name <email> $GIT_COMMITTER_DATE - data <<COMMIT - Bad path - COMMIT - R ok-path ./invalid-path - INPUT_END + commit refs/heads/badpath + committer Name <email> $GIT_COMMITTER_DATE + data <<COMMIT + Good path + COMMIT + M 100644 :1 ok-path - test_when_finished "git update-ref -d refs/heads/badpath" && - test_must_fail git fast-import <input + commit refs/heads/badpath + committer Name <email> $GIT_COMMITTER_DATE + data <<COMMIT + Bad path + COMMIT + R ok-path ./invalid-path + INPUT_END + + test_must_fail git fast-import <input + ) ' test_expect_success WINDOWS 'B: fail on invalid file path of C:' ' - cat >input <<-INPUT_END && - blob - mark :1 - data <<EOF - File contents - EOF + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && - commit refs/heads/badpath - committer Name <email> $GIT_COMMITTER_DATE - data <<COMMIT - Commit Message - COMMIT - M 100644 :1 C:/invalid-path - INPUT_END + cat >input <<-INPUT_END && + blob + mark :1 + data <<EOF + File contents + EOF - test_when_finished "git update-ref -d refs/heads/badpath" && - test_must_fail git fast-import <input + commit refs/heads/badpath + committer Name <email> $GIT_COMMITTER_DATE + data <<COMMIT + Commit Message + COMMIT + M 100644 :1 C:/invalid-path + INPUT_END + + test_must_fail git fast-import <input + ) ' test_expect_success 'B: fail on invalid file path of .git' ' - cat >input <<-INPUT_END && - blob - mark :1 - data <<EOF - File contents - EOF + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && - commit refs/heads/badpath - committer Name <email> $GIT_COMMITTER_DATE - data <<COMMIT - Commit Message - COMMIT - M 100644 :1 .git/invalid-path - INPUT_END + cat >input <<-INPUT_END && + blob + mark :1 + data <<EOF + File contents + EOF - test_when_finished "git update-ref -d refs/heads/badpath" && - test_must_fail git fast-import <input + commit refs/heads/badpath + committer Name <email> $GIT_COMMITTER_DATE + data <<COMMIT + Commit Message + COMMIT + M 100644 :1 .git/invalid-path + INPUT_END + + test_must_fail git fast-import <input + ) ' test_expect_success 'B: fail on invalid file path of .gitmodules' ' - cat >input <<-INPUT_END && - blob - mark :1 - data <<EOF - File contents - EOF + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && - commit refs/heads/badpath - committer Name <email> $GIT_COMMITTER_DATE - data <<COMMIT - Commit Message - COMMIT - M 120000 :1 .gitmodules - INPUT_END + cat >input <<-INPUT_END && + blob + mark :1 + data <<EOF + File contents + EOF - test_when_finished "git update-ref -d refs/heads/badpath" && - test_must_fail git fast-import <input + commit refs/heads/badpath + committer Name <email> $GIT_COMMITTER_DATE + data <<COMMIT + Commit Message + COMMIT + M 120000 :1 .gitmodules + INPUT_END + + test_must_fail git fast-import <input + ) ' ###
Signature · 1 line
2.56.GIT
PATCH 3/20 t9300: make the series T tests self-contained
In reply to Karthik NayakSimilar to the previous commit, modify the tests in 'series T' to make them independent of state from preceding tests.
The 'ls root' tests list the root tree of the 'S' branch, using the marks left behind by series S. The expected output is derived from the commit itself, so any commit will do. Run them against a commit created in a new repository instead. Run the branch tests in a new repository too.
--- t/t9300-fast-import.sh | 62 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 21 deletions(-)
t/t9300-fast-import.sh +41 -21
@@ -3525,38 +3525,58 @@ test_path_eol_quoted_fail 'ls (without dataref in commit)' 'ls ' path ### ### series T (ls) ### -# Setup is carried over from series S. for root in '""' '' do test_expect_success "T: ls root ($root) tree" ' - sed -e "s/Z\$//" >expect <<-EOF && - 040000 tree $(git rev-parse S^{tree}) Z - EOF - sha1=$(git rev-parse --verify S) && - git fast-import --import-marks=marks <<-EOF >actual && - ls $sha1 $root - EOF - test_cmp expect actual + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + test_commit one && + + sed -e "s/Z\$//" >expect <<-EOF && + 040000 tree $(git rev-parse HEAD^{tree}) Z + EOF + sha1=$(git rev-parse --verify HEAD) && + git fast-import <<-EOF >actual && + ls $sha1 $root + EOF + test_cmp expect actual + ) ' done test_expect_success 'T: delete branch' ' - git branch to-delete && - git fast-import <<-EOF && - reset refs/heads/to-delete - from $ZERO_OID - EOF - test_must_fail git rev-parse --verify refs/heads/to-delete + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + test_commit one && + + git branch to-delete && + git fast-import <<-EOF && + reset refs/heads/to-delete + from $ZERO_OID + EOF + test_must_fail git rev-parse --verify refs/heads/to-delete + ) ' test_expect_success 'T: empty reset doesnt delete branch' ' - git branch not-to-delete && - git fast-import <<-EOF && - reset refs/heads/not-to-delete - EOF - git show-ref && - git rev-parse --verify refs/heads/not-to-delete + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + test_commit one && + + git branch not-to-delete && + git fast-import <<-EOF && + reset refs/heads/not-to-delete + EOF + git show-ref && + git rev-parse --verify refs/heads/not-to-delete + ) ' ###
Signature · 1 line
2.56.GIT
PATCH 4/20 t9300: make the series S tests self-contained
In reply to Karthik NayakSimilar 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.
--- t/t9300-fast-import.sh | 332 +++++++++++++++++++++++++++++-------------------- 1 file changed, 198 insertions(+), 134 deletions(-)
t/t9300-fast-import.sh +198 -134
@@ -3023,10 +3023,12 @@ test_expect_success 'R: blob appears only once' ' # # 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
@@ -3063,142 +3065,168 @@ test_expect_success 'S: initialize for S tests' ' BLOB INPUT_END - git fast-import --export-marks=marks <input -' + git -C repo fast-import --export-marks=marks <repo/input +} # # filemodify, three datarefs # test_expect_success 'S: filemodify with garbage after mark must fail' ' - test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && - commit refs/heads/S - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <<COMMIT - commit N - COMMIT - M 100644 :403x 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 && + commit refs/heads/S + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <<COMMIT + commit N + COMMIT + M 100644 :403x hello.c + EOF + test_grep "space after mark" err + ) ' # inline is misspelled; fast-import thinks it is some unknown dataref test_expect_success 'S: filemodify with garbage after inline must fail' ' - test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && - commit refs/heads/S - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <<COMMIT - commit N - COMMIT - M 100644 inlineX hello.c - data <<BLOB - inline - BLOB - EOF - test_grep "nvalid dataref" err + setup_marks_repo && + ( + cd repo && + + test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && + commit refs/heads/S + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <<COMMIT + commit N + COMMIT + M 100644 inlineX hello.c + data <<BLOB + inline + BLOB + EOF + test_grep "nvalid dataref" err + ) ' test_expect_success 'S: filemodify with garbage after sha1 must fail' ' - sha1=$(grep :403 marks | cut -d\ -f2) && - test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && - commit refs/heads/S - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <<COMMIT - commit N - COMMIT - M 100644 ${sha1}x hello.c - EOF - test_grep "space after SHA1" err + setup_marks_repo && + ( + cd repo && + + sha1=$(grep :403 marks | cut -d\ -f2) && + test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && + commit refs/heads/S + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <<COMMIT + commit N + COMMIT + M 100644 ${sha1}x hello.c + EOF + test_grep "space after SHA1" err + ) ' # # notemodify, three ways to say dataref # test_expect_success 'S: notemodify with garbage after mark dataref must fail' ' - test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && - commit refs/heads/S - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <<COMMIT - commit S note dataref markref - COMMIT - N :202x :302 - EOF - test_grep "space after mark" err + setup_marks_repo && + ( + cd repo && + + test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && + commit refs/heads/S + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <<COMMIT + commit S note dataref markref + COMMIT + N :202x :302 + EOF + test_grep "space after mark" err + ) ' test_expect_success 'S: notemodify with garbage after inline dataref must fail' ' - test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && - commit refs/heads/S - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <<COMMIT - commit S note dataref inline - COMMIT - N inlineX :302 - data <<BLOB - note blob - BLOB - EOF - test_grep "nvalid dataref" err + setup_marks_repo && + ( + cd repo && + + test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && + commit refs/heads/S + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <<COMMIT + commit S note dataref inline + COMMIT + N inlineX :302 + data <<BLOB + note blob + BLOB + EOF + test_grep "nvalid dataref" err + ) ' test_expect_success 'S: notemodify with garbage after sha1 dataref must fail' ' - sha1=$(grep :202 marks | cut -d\ -f2) && - test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && - commit refs/heads/S - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <<COMMIT - commit S note dataref sha1 - COMMIT - N ${sha1}x :302 - EOF - test_grep "space after SHA1" err + setup_marks_repo && + ( + cd repo && + + sha1=$(grep :202 marks | cut -d\ -f2) && + test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && + commit refs/heads/S + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <<COMMIT + commit S note dataref sha1 + COMMIT + N ${sha1}x :302 + EOF + test_grep "space after SHA1" err + ) ' # # notemodify, mark in commit-ish # test_expect_success 'S: notemodify with garbage after mark commit-ish must fail' ' - test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && - commit refs/heads/Snotes - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <<COMMIT - commit S note commit-ish - COMMIT - N :202 :302x - EOF - test_grep "after mark" err + setup_marks_repo && + ( + cd repo && + + test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && + commit refs/heads/Snotes + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <<COMMIT + commit S note commit-ish + COMMIT + N :202 :302x + EOF + test_grep "after mark" err + ) ' # # from # test_expect_success 'S: from with garbage after mark must fail' ' - test_must_fail \ - git fast-import --import-marks=marks --export-marks=marks <<-EOF 2>err && - commit refs/heads/S2 - mark :303 - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <<COMMIT - commit 3 - COMMIT - from :301x - M 100644 :403 hello.c - EOF + setup_marks_repo && + ( + cd repo && + test_must_fail \ + git fast-import --import-marks=marks --export-marks=marks <<-EOF 2>err && + commit refs/heads/S2 + mark :303 + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <<COMMIT + commit 3 + COMMIT + from :301x + M 100644 :403 hello.c + EOF - # go create the commit, need it for merge test - git fast-import --import-marks=marks --export-marks=marks <<-EOF && - commit refs/heads/S2 - mark :303 - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <<COMMIT - commit 3 - COMMIT - from :301 - M 100644 :403 hello.c - EOF - - # now evaluate the error - test_grep "after mark" err + test_grep "after mark" err + ) '
@@ -3206,61 +3234,97 @@ test_expect_success 'S: from with garbage after mark must fail' ' # merge # test_expect_success 'S: merge with garbage after mark must fail' ' - test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && - commit refs/heads/S - mark :304 - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <<COMMIT - merge 4 - COMMIT - from :302 - merge :303x - M 100644 :403 hello.c - EOF - test_grep "after mark" err + setup_marks_repo && + ( + cd repo && + + git fast-import --import-marks=marks --export-marks=marks <<-EOF && + commit refs/heads/S2 + mark :303 + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <<COMMIT + commit 3 + COMMIT + from :301 + M 100644 :403 hello.c + EOF + + test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && + commit refs/heads/S + mark :304 + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <<COMMIT + merge 4 + COMMIT + from :302 + merge :303x + M 100644 :403 hello.c + EOF + test_grep "after mark" err + ) ' # # tag, from markref # test_expect_success 'S: tag with garbage after mark must fail' ' - test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && - tag refs/tags/Stag - from :302x - tagger $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <<TAG - tag S - TAG - EOF - test_grep "after mark" err + setup_marks_repo && + ( + cd repo && + + test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && + tag refs/tags/Stag + from :302x + tagger $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <<TAG + tag S + TAG + EOF + test_grep "after mark" err + ) ' # # cat-blob markref # test_expect_success 'S: cat-blob with garbage after mark must fail' ' - test_must_fail git fast-import --import-marks=marks <<-EOF 2>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 + ) ' #
Signature · 1 line
2.56.GIT
PATCH 5/20 t9300: make the series V tests self-contained
In reply to Karthik NayakSimilar to the previous commits, modify the tests in 'series V' to make them independent of state from previous tests.
Move the setup to a 'setup_checkpoint_repo()' function, so each test can invoke it. The tests used to build on the 'U' branch from series U, so let the function create a 'base' commit instead. For the same reason, the tag test now tags 'base' and not 'V'.
'background_import_then_checkpoint()' registers a cleanup with 'test_when_finished', which is not allowed in a subshell, so call it from the main shell.
The 'no new objects' test needs the 'V' commit in a pack, because fast-import only detects duplicates against packs and not against loose objects. It used to rely on the 'fastimport.unpackLimit' set by an earlier test, so create the commit in the test with 'fastimport.unpackLimit' set to 0.
--- t/t9300-fast-import.sh | 80 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 55 insertions(+), 25 deletions(-)
t/t9300-fast-import.sh +55 -25
@@ -3777,7 +3777,7 @@ background_import_then_checkpoint () { rm V.output ( - git fast-import $options <&8 >&9 & + git -C repo fast-import $options <&8 >&9 & echo $! >&9 wait $! echo >&2 "background fast-import terminated too early with exit code $?"
@@ -3829,80 +3829,110 @@ background_import_still_running () { fi } +setup_checkpoint_repo () { + test_when_finished "rm -rf repo" && + git init repo && + test_tick && + git -C repo fast-import <<-INPUT_END + commit refs/heads/base + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <<COMMIT + base commit + COMMIT + INPUT_END +} + test_expect_success PIPE 'V: checkpoint helper does not get stuck with extra output' ' - cat >input <<-INPUT_END && + setup_checkpoint_repo && + cat >repo/input <<-INPUT_END && progress foo progress bar INPUT_END - background_import_then_checkpoint "" input && + background_import_then_checkpoint "" repo/input && background_import_still_running ' test_expect_success PIPE 'V: checkpoint updates refs after reset' ' - cat >input <<-\INPUT_END && + setup_checkpoint_repo && + cat >repo/input <<-\INPUT_END && reset refs/heads/V - from refs/heads/U + from refs/heads/base INPUT_END - background_import_then_checkpoint "" input && - test "$(git rev-parse --verify V)" = "$(git rev-parse --verify U)" && + background_import_then_checkpoint "" repo/input && + test "$(git -C repo rev-parse --verify V)" = "$(git -C repo rev-parse --verify base)" && background_import_still_running ' test_expect_success PIPE 'V: checkpoint updates refs and marks after commit' ' - cat >input <<-INPUT_END && + setup_checkpoint_repo && + cat >repo/input <<-INPUT_END && commit refs/heads/V mark :1 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data 0 - from refs/heads/U + from refs/heads/base INPUT_END - background_import_then_checkpoint "--export-marks=marks.actual" input && + background_import_then_checkpoint "--export-marks=marks.actual" repo/input && + ( + cd repo && + echo ":1 $(git rev-parse --verify V)" >marks.expected && - echo ":1 $(git rev-parse --verify V)" >marks.expected && - - test "$(git rev-parse --verify V^)" = "$(git rev-parse --verify U)" && - test_cmp marks.expected marks.actual && + test "$(git rev-parse --verify V^)" = "$(git rev-parse --verify base)" && + test_cmp marks.expected marks.actual + ) && background_import_still_running ' # Re-create the exact same commit, but on a different branch: no new object is # created in the database, but the refs and marks still need to be updated. test_expect_success PIPE 'V: checkpoint updates refs and marks after commit (no new objects)' ' - cat >input <<-INPUT_END && + setup_checkpoint_repo && + git -C repo -c fastimport.unpackLimit=0 fast-import <<-INPUT_END && + commit refs/heads/V + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data 0 + from refs/heads/base + + INPUT_END + + cat >repo/input <<-INPUT_END && commit refs/heads/V2 mark :2 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data 0 - from refs/heads/U + from refs/heads/base INPUT_END - background_import_then_checkpoint "--export-marks=marks.actual" input && + background_import_then_checkpoint "--export-marks=marks.actual" repo/input && + ( + cd repo && + echo ":2 $(git rev-parse --verify V2)" >marks.expected && - echo ":2 $(git rev-parse --verify V2)" >marks.expected && - - test "$(git rev-parse --verify V2)" = "$(git rev-parse --verify V)" && - test_cmp marks.expected marks.actual && + test "$(git rev-parse --verify V2)" = "$(git rev-parse --verify V)" && + test_cmp marks.expected marks.actual + ) && background_import_still_running ' test_expect_success PIPE 'V: checkpoint updates tags after tag' ' - cat >input <<-INPUT_END && + setup_checkpoint_repo && + cat >repo/input <<-INPUT_END && tag Vtag - from refs/heads/V + from refs/heads/base tagger $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data 0 INPUT_END - background_import_then_checkpoint "" input && - git show-ref -d Vtag && + background_import_then_checkpoint "" repo/input && + git -C repo show-ref -d Vtag && background_import_still_running '
Signature · 1 line
2.56.GIT
PATCH 6/20 t9300: make the series Q tests self-contained
In reply to Karthik NayakSimilar to the previous commits, modify the tests in 'series Q' to make them independent of state from previous tests.
The 'Q: verify' tests inspect the commits and notes written by 'Q:
commit notes', and use shell variables set by the preceding tests. Replace 'Q: commit notes' with a 'setup_notes_repo()' function, which creates a new repository, runs the import and sets those variables, so each test can invoke it. Run the import with 'fastimport.unpackLimit' set to 0, so that a pack is written for 'Q: verify pack' to check.
Also stop using the 'verify_packs()' function, to make it easier to move these tests to another file.
--- t/t9300-fast-import.sh | 344 +++++++++++++++++++++++++++++++------------------ 1 file changed, 220 insertions(+), 124 deletions(-)
t/t9300-fast-import.sh +220 -124
@@ -2023,7 +2023,17 @@ test_expect_success 'P: fail on blob mark in gitlink' ' ### series Q (notes) ### -test_expect_success 'Q: commit notes' ' +setup_notes_repo () { + test_when_finished "rm -rf repo" && + git init repo && + file2_data="file2 +second line of EOF" && + file4_data=abcd && + file4_len=4 && + file5_data="an inline file. + we should see it later." && + file6_data="#!/bin/sh +echo \"\$@\"" && note1_data="The first note for the first commit" && note2_data="The first note for the second commit" && note3_data="The first note for the third commit" &&
@@ -2032,7 +2042,7 @@ test_expect_success 'Q: commit notes' ' note2b_data="The second note for the second commit" && test_tick && - cat >input <<-INPUT_END && + cat >repo/input <<-INPUT_END && blob mark :2 data <<EOF
@@ -2143,199 +2153,285 @@ test_expect_success 'Q: commit notes' ' INPUT_END - git fast-import <input && - git log --raw notes-test -' + git -C repo -c fastimport.unpackLimit=0 fast-import <repo/input && + commit1=$(git -C repo rev-parse notes-test~2) && + commit2=$(git -C repo rev-parse notes-test^) && + commit3=$(git -C repo rev-parse notes-test) +} test_expect_success 'Q: verify pack' ' - verify_packs + setup_notes_repo && + ( + cd repo && + for p in .git/objects/pack/*.pack + do + git verify-pack "$p" || return 1 + done + ) ' test_expect_success 'Q: verify first commit' ' - commit1=$(git rev-parse notes-test~2) && - commit2=$(git rev-parse notes-test^) && - commit3=$(git rev-parse notes-test) && + setup_notes_repo && + ( + cd repo && + cat >expect <<-EOF && + author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - cat >expect <<-EOF && - author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - - first (:3) - EOF - git cat-file commit notes-test~2 | sed 1d >actual && - test_cmp expect actual + first (:3) + EOF + git cat-file commit notes-test~2 | sed 1d >actual && + test_cmp expect actual + ) ' test_expect_success 'Q: verify second commit' ' - cat >expect <<-EOF && - parent $commit1 - author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + setup_notes_repo && + ( + cd repo && + cat >expect <<-EOF && + parent $commit1 + author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - second (:5) - EOF - git cat-file commit notes-test^ | sed 1d >actual && - test_cmp expect actual + second (:5) + EOF + git cat-file commit notes-test^ | sed 1d >actual && + test_cmp expect actual + ) ' test_expect_success 'Q: verify third commit' ' - cat >expect <<-EOF && - parent $commit2 - author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + setup_notes_repo && + ( + cd repo && + cat >expect <<-EOF && + parent $commit2 + author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - third (:6) - EOF - git cat-file commit notes-test | sed 1d >actual && - test_cmp expect actual + third (:6) + EOF + git cat-file commit notes-test | sed 1d >actual && + test_cmp expect actual + ) ' test_expect_success 'Q: verify first notes commit' ' - cat >expect <<-EOF && - author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + setup_notes_repo && + ( + cd repo && + cat >expect <<-EOF && + author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - notes (:9) - EOF - git cat-file commit refs/notes/foobar~2 | sed 1d >actual && - test_cmp expect actual + notes (:9) + EOF + git cat-file commit refs/notes/foobar~2 | sed 1d >actual && + test_cmp expect actual + ) ' test_expect_success 'Q: verify first notes tree' ' - sort >expect <<-EOF && - 100644 blob $commit1 - 100644 blob $commit2 - 100644 blob $commit3 - EOF - git cat-file -p refs/notes/foobar~2^{tree} | sed "s/ [0-9a-f]* / /" >actual && - test_cmp expect actual + setup_notes_repo && + ( + cd repo && + sort >expect <<-EOF && + 100644 blob $commit1 + 100644 blob $commit2 + 100644 blob $commit3 + EOF + git cat-file -p refs/notes/foobar~2^{tree} | sed "s/ [0-9a-f]* / /" >actual && + test_cmp expect actual + ) ' test_expect_success 'Q: verify first note for first commit' ' - echo "$note1_data" >expect && - git cat-file blob refs/notes/foobar~2:$commit1 >actual && - test_cmp expect actual + setup_notes_repo && + ( + cd repo && + echo "$note1_data" >expect && + git cat-file blob refs/notes/foobar~2:$commit1 >actual && + test_cmp expect actual + ) ' test_expect_success 'Q: verify first note for second commit' ' - echo "$note2_data" >expect && - git cat-file blob refs/notes/foobar~2:$commit2 >actual && - test_cmp expect actual + setup_notes_repo && + ( + cd repo && + echo "$note2_data" >expect && + git cat-file blob refs/notes/foobar~2:$commit2 >actual && + test_cmp expect actual + ) ' test_expect_success 'Q: verify first note for third commit' ' - echo "$note3_data" >expect && - git cat-file blob refs/notes/foobar~2:$commit3 >actual && - test_cmp expect actual + setup_notes_repo && + ( + cd repo && + echo "$note3_data" >expect && + git cat-file blob refs/notes/foobar~2:$commit3 >actual && + test_cmp expect actual + ) ' test_expect_success 'Q: verify second notes commit' ' - cat >expect <<-EOF && - parent $(git rev-parse --verify refs/notes/foobar~2) - author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + setup_notes_repo && + ( + cd repo && + cat >expect <<-EOF && + parent $(git rev-parse --verify refs/notes/foobar~2) + author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - notes (:10) - EOF - git cat-file commit refs/notes/foobar^ | sed 1d >actual && - test_cmp expect actual + notes (:10) + EOF + git cat-file commit refs/notes/foobar^ | sed 1d >actual && + test_cmp expect actual + ) ' test_expect_success 'Q: verify second notes tree' ' - sort >expect <<-EOF && - 100644 blob $commit1 - 100644 blob $commit2 - 100644 blob $commit3 - EOF - git cat-file -p refs/notes/foobar^^{tree} | sed "s/ [0-9a-f]* / /" >actual && - test_cmp expect actual + setup_notes_repo && + ( + cd repo && + sort >expect <<-EOF && + 100644 blob $commit1 + 100644 blob $commit2 + 100644 blob $commit3 + EOF + git cat-file -p refs/notes/foobar^^{tree} | sed "s/ [0-9a-f]* / /" >actual && + test_cmp expect actual + ) ' test_expect_success 'Q: verify second note for first commit' ' - echo "$note1b_data" >expect && - git cat-file blob refs/notes/foobar^:$commit1 >actual && - test_cmp expect actual + setup_notes_repo && + ( + cd repo && + echo "$note1b_data" >expect && + git cat-file blob refs/notes/foobar^:$commit1 >actual && + test_cmp expect actual + ) ' test_expect_success 'Q: verify first note for second commit' ' - echo "$note2_data" >expect && - git cat-file blob refs/notes/foobar^:$commit2 >actual && - test_cmp expect actual + setup_notes_repo && + ( + cd repo && + echo "$note2_data" >expect && + git cat-file blob refs/notes/foobar^:$commit2 >actual && + test_cmp expect actual + ) ' test_expect_success 'Q: verify first note for third commit' ' - echo "$note3_data" >expect && - git cat-file blob refs/notes/foobar^:$commit3 >actual && - test_cmp expect actual + setup_notes_repo && + ( + cd repo && + echo "$note3_data" >expect && + git cat-file blob refs/notes/foobar^:$commit3 >actual && + test_cmp expect actual + ) ' test_expect_success 'Q: verify third notes commit' ' - cat >expect <<-EOF && - author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + setup_notes_repo && + ( + cd repo && + cat >expect <<-EOF && + author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - notes (:11) - EOF - git cat-file commit refs/notes/foobar2 | sed 1d >actual && - test_cmp expect actual + notes (:11) + EOF + git cat-file commit refs/notes/foobar2 | sed 1d >actual && + test_cmp expect actual + ) ' test_expect_success 'Q: verify third notes tree' ' - sort >expect <<-EOF && - 100644 blob $commit1 - EOF - git cat-file -p refs/notes/foobar2^{tree} | sed "s/ [0-9a-f]* / /" >actual && - test_cmp expect actual + setup_notes_repo && + ( + cd repo && + sort >expect <<-EOF && + 100644 blob $commit1 + EOF + git cat-file -p refs/notes/foobar2^{tree} | sed "s/ [0-9a-f]* / /" >actual && + test_cmp expect actual + ) ' test_expect_success 'Q: verify third note for first commit' ' - echo "$note1c_data" >expect && - git cat-file blob refs/notes/foobar2:$commit1 >actual && - test_cmp expect actual + setup_notes_repo && + ( + cd repo && + echo "$note1c_data" >expect && + git cat-file blob refs/notes/foobar2:$commit1 >actual && + test_cmp expect actual + ) ' test_expect_success 'Q: verify fourth notes commit' ' - cat >expect <<-EOF && - parent $(git rev-parse --verify refs/notes/foobar^) - author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + setup_notes_repo && + ( + cd repo && + cat >expect <<-EOF && + parent $(git rev-parse --verify refs/notes/foobar^) + author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - notes (:12) - EOF - git cat-file commit refs/notes/foobar | sed 1d >actual && - test_cmp expect actual + notes (:12) + EOF + git cat-file commit refs/notes/foobar | sed 1d >actual && + test_cmp expect actual + ) ' test_expect_success 'Q: verify fourth notes tree' ' - sort >expect <<-EOF && - 100644 blob $commit2 - EOF - git cat-file -p refs/notes/foobar^{tree} | sed "s/ [0-9a-f]* / /" >actual && - test_cmp expect actual + setup_notes_repo && + ( + cd repo && + sort >expect <<-EOF && + 100644 blob $commit2 + EOF + git cat-file -p refs/notes/foobar^{tree} | sed "s/ [0-9a-f]* / /" >actual && + test_cmp expect actual + ) ' test_expect_success 'Q: verify second note for second commit' ' - echo "$note2b_data" >expect && - git cat-file blob refs/notes/foobar:$commit2 >actual && - test_cmp expect actual + setup_notes_repo && + ( + cd repo && + echo "$note2b_data" >expect && + git cat-file blob refs/notes/foobar:$commit2 >actual && + test_cmp expect actual + ) ' test_expect_success 'Q: deny note on empty branch' ' - cat >input <<-EOF && - reset refs/heads/Q0 + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + cat >input <<-EOF && + reset refs/heads/Q0 - commit refs/heads/note-Q0 - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <<COMMIT - Note for an empty branch. - COMMIT + commit refs/heads/note-Q0 + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <<COMMIT + Note for an empty branch. + COMMIT - N inline refs/heads/Q0 - data <<NOTE - some note - NOTE - EOF - test_must_fail git fast-import <input + N inline refs/heads/Q0 + data <<NOTE + some note + NOTE + EOF + test_must_fail git fast-import <input + ) ' ###
Signature · 1 line
2.56.GIT
PATCH 7/20 t9300: make the series P tests self-contained
In reply to Karthik NayakSimilar to the previous commits, modify the tests in 'series P' to make them independent of state from previous tests.
Move the setup to a 'setup_gitlinks_repo()' function, so each test can invoke it.
The 'fail on inline gitlink' and 'fail on blob mark in gitlink' tests create their commit on top of 'subuse2', which is only written by the 'verbatim SHA gitlinks' test. Use 'subuse1' from the setup instead, as these tests only check that the invalid gitlink is rejected.
--- t/t9300-fast-import.sh | 290 +++++++++++++++++++++++++++---------------------- 1 file changed, 161 insertions(+), 129 deletions(-)
t/t9300-fast-import.sh +161 -129
@@ -1866,157 +1866,189 @@ test_expect_success 'O: progress outputs as requested by input' ' ### series P (gitlinks) ### -test_expect_success 'P: superproject & submodule mix' ' - cat >input <<-INPUT_END && - blob - mark :1 - data 10 - test file - - reset refs/heads/sub - commit refs/heads/sub - mark :2 - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data 12 - sub_initial - M 100644 :1 file - - blob - mark :3 - data <<DATAEND - [submodule "sub"] - path = sub - url = "$(pwd)/sub" - DATAEND - - commit refs/heads/subuse1 - mark :4 - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data 8 - initial - from refs/heads/main - M 100644 :3 .gitmodules - M 160000 :2 sub - - blob - mark :5 - data 20 - test file - more data - - commit refs/heads/sub - mark :6 - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data 11 - sub_second - from :2 - M 100644 :5 file - - commit refs/heads/subuse1 - mark :7 - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data 7 - second - from :4 - M 160000 :6 sub - - INPUT_END - - git fast-import <input && - git checkout subuse1 && - rm -rf sub && - mkdir sub && +setup_gitlinks_repo () { + test_when_finished "rm -rf repo" && + git init repo && + test_commit -C repo base && ( - cd sub && - git init && - git fetch --update-head-ok .. refs/heads/sub:refs/heads/main && - git checkout main - ) && - git submodule init && - git submodule update + cd repo && + + cat >input <<-INPUT_END && + blob + mark :1 + data 10 + test file + + reset refs/heads/sub + commit refs/heads/sub + mark :2 + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data 12 + sub_initial + M 100644 :1 file + + blob + mark :3 + data <<DATAEND + [submodule "sub"] + path = sub + url = "$(pwd)/sub" + DATAEND + + commit refs/heads/subuse1 + mark :4 + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data 8 + initial + from refs/heads/main + M 100644 :3 .gitmodules + M 160000 :2 sub + + blob + mark :5 + data 20 + test file + more data + + commit refs/heads/sub + mark :6 + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data 11 + sub_second + from :2 + M 100644 :5 file + + commit refs/heads/subuse1 + mark :7 + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data 7 + second + from :4 + M 160000 :6 sub + + INPUT_END + + git fast-import <input + ) +} + +test_expect_success 'P: superproject & submodule mix' ' + setup_gitlinks_repo && + ( + cd repo && + + git checkout subuse1 && + rm -rf sub && + mkdir sub && + ( + cd sub && + git init && + git fetch --update-head-ok .. refs/heads/sub:refs/heads/main && + git checkout main + ) && + git submodule init && + git submodule update + ) ' test_expect_success 'P: verbatim SHA gitlinks' ' - SUBLAST=$(git rev-parse --verify sub) && - SUBPREV=$(git rev-parse --verify sub^) && + setup_gitlinks_repo && + ( + cd repo && - cat >input <<-INPUT_END && - blob - mark :1 - data <<DATAEND - [submodule "sub"] - path = sub - url = "$(pwd)/sub" - DATAEND + SUBLAST=$(git rev-parse --verify sub) && + SUBPREV=$(git rev-parse --verify sub^) && - commit refs/heads/subuse2 - mark :2 - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data 8 - initial - from refs/heads/main - M 100644 :1 .gitmodules - M 160000 $SUBPREV sub + cat >input <<-INPUT_END && + blob + mark :1 + data <<DATAEND + [submodule "sub"] + path = sub + url = "$(pwd)/sub" + DATAEND - commit refs/heads/subuse2 - mark :3 - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data 7 - second - from :2 - M 160000 $SUBLAST sub + commit refs/heads/subuse2 + mark :2 + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data 8 + initial + from refs/heads/main + M 100644 :1 .gitmodules + M 160000 $SUBPREV sub - INPUT_END + commit refs/heads/subuse2 + mark :3 + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data 7 + second + from :2 + M 160000 $SUBLAST sub - git branch -D sub && - git gc --prune=now && - git fast-import <input && - test $(git rev-parse --verify subuse2) = $(git rev-parse --verify subuse1) + INPUT_END + + git branch -D sub && + git gc --prune=now && + git fast-import <input && + test $(git rev-parse --verify subuse2) = $(git rev-parse --verify subuse1) + ) ' test_expect_success 'P: fail on inline gitlink' ' - test_tick && - cat >input <<-INPUT_END && - commit refs/heads/subuse3 - mark :1 - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <<COMMIT - corrupt - COMMIT + setup_gitlinks_repo && + ( + cd repo && - from refs/heads/subuse2 - M 160000 inline sub - data <<DATA - $SUBPREV - DATA + SUBPREV=$(git rev-parse --verify sub^) && + test_tick && + cat >input <<-INPUT_END && + commit refs/heads/subuse3 + mark :1 + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <<COMMIT + corrupt + COMMIT - INPUT_END + from refs/heads/subuse1 + M 160000 inline sub + data <<DATA + $SUBPREV + DATA - test_must_fail git fast-import <input + INPUT_END + + test_must_fail git fast-import <input + ) ' test_expect_success 'P: fail on blob mark in gitlink' ' - test_tick && - cat >input <<-INPUT_END && - blob - mark :1 - data <<DATA - $SUBPREV - DATA + setup_gitlinks_repo && + ( + cd repo && - commit refs/heads/subuse3 - mark :2 - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <<COMMIT - corrupt - COMMIT + SUBPREV=$(git rev-parse --verify sub^) && + test_tick && + cat >input <<-INPUT_END && + blob + mark :1 + data <<DATA + $SUBPREV + DATA - from refs/heads/subuse2 - M 160000 :1 sub + commit refs/heads/subuse3 + mark :2 + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <<COMMIT + corrupt + COMMIT - INPUT_END + from refs/heads/subuse1 + M 160000 :1 sub - test_must_fail git fast-import <input + INPUT_END + + test_must_fail git fast-import <input + ) ' ###
Signature · 1 line
2.56.GIT
PATCH 8/20 t9300: make the series O tests self-contained
In reply to Karthik NayakSimilar 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.
--- t/t9300-fast-import.sh | 291 +++++++++++++++++++++++++++++++------------------ 1 file changed, 182 insertions(+), 109 deletions(-)
t/t9300-fast-import.sh +182 -109
@@ -1723,143 +1723,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 <<COMMIT dirty directory copy COMMIT - # do not forget the import blank line! - # - # yes, we started from our usual base of branch^0. - # i like branch^0. - from refs/heads/branch^0 - # and we need to reuse file2/file5 from N3 above. + from refs/heads/main M 644 inline file2/file5 - # otherwise the tree will be different data <<EOF - $file5_data + an inline file. + we should see it later. EOF - # do not forget to copy file2 to file3 C file2 file3 - # - # or to delete file5 from file2. D file2/file5 - # are we done yet? INPUT_END +} - git fast-import <input && - test $(git rev-parse N3) = $(git rev-parse O1) +test_expect_success 'O: comments are all skipped' ' + setup_import_repo && + ( + cd repo && + + cat >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 <<COMMIT + dirty directory copy + COMMIT + + # do not forget the import blank line! + # + # yes, we started from our usual base of main. + # i like main. + from refs/heads/main + # and we need to add file2/file5 to file2. + M 644 inline file2/file5 + # otherwise the tree will be different + data <<EOF + an inline file. + we should see it later. + EOF + + # do not forget to copy file2 to file3 + C file2 file3 + # + # or to delete file5 from file2. + D file2/file5 + # are we done yet? + + INPUT_END + + git fast-import <input && + blob4=$(echo abcd | git hash-object --stdin) && + blob5=$(printf "an inline file.\n we should see it later.\n" | git hash-object --stdin) && + cat >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 <<COMMIT - dirty directory copy - COMMIT - from refs/heads/branch^0 - M 644 inline file2/file5 - data <<EOF - $file5_data - EOF - C file2 file3 - D file2/file5 + setup_import_repo && + ( + cd repo && - INPUT_END + cat >input <<-INPUT_END && + commit refs/heads/O2 + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <<COMMIT + dirty directory copy + COMMIT + from refs/heads/main + M 644 inline file2/file5 + data <<EOF + an inline file. + we should see it later. + EOF + C file2 file3 + D file2/file5 - git fast-import <input && - test $(git rev-parse N3) = $(git rev-parse O2) -' + INPUT_END -test_expect_success 'O: repack before next test' ' - git repack -a -d + git fast-import <input && + blob4=$(echo abcd | git hash-object --stdin) && + blob5=$(printf "an inline file.\n we should see it later.\n" | git hash-object --stdin) && + cat >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 <<COMMIT - zstring - COMMIT - commit refs/heads/O3 - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <<COMMIT - zof - COMMIT - checkpoint - commit refs/heads/O3 - mark :5 - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <<COMMIT - zempty - COMMIT - checkpoint - commit refs/heads/O3 - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <<COMMIT - zcommits - COMMIT - reset refs/tags/O3-2nd - from :5 - reset refs/tags/O3-3rd - from :5 - INPUT_END + setup_import_repo && + ( + cd repo && + git repack -a -d && - cat >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 <<COMMIT + zstring + COMMIT + commit refs/heads/O3 + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <<COMMIT + zof + COMMIT + checkpoint + commit refs/heads/O3 + mark :5 + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <<COMMIT + zempty + COMMIT + checkpoint + commit refs/heads/O3 + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <<COMMIT + zcommits + COMMIT + reset refs/tags/O3-2nd + from :5 + reset refs/tags/O3-3rd + from :5 + INPUT_END - git fast-import <input && - ls -la .git/objects/pack/pack-*.pack >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 <input && + ls -la .git/objects/pack/pack-*.pack >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 <<COMMIT - zstring - COMMIT - commit refs/heads/O4 - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <<COMMIT - zof - COMMIT - progress Two commits down, 2 to go! - commit refs/heads/O4 - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <<COMMIT - zempty - COMMIT - progress Three commits down, 1 to go! - commit refs/heads/O4 - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <<COMMIT - zcommits - COMMIT - progress done! - INPUT_END - git fast-import <input >actual && - grep "progress " <input >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 <<COMMIT + zstring + COMMIT + commit refs/heads/O4 + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <<COMMIT + zof + COMMIT + progress Two commits down, 2 to go! + commit refs/heads/O4 + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <<COMMIT + zempty + COMMIT + progress Three commits down, 1 to go! + commit refs/heads/O4 + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <<COMMIT + zcommits + COMMIT + progress done! + INPUT_END + git fast-import <input >actual && + grep "progress " <input >expect && + test_cmp expect actual + ) ' ###
Signature · 1 line
2.56.GIT
PATCH 9/20 t9300: make the big blob tests self-contained
In reply to Karthik NayakSimilar to the previous commits, modify the big blob tests in 'series R' to make them independent of state from previous tests.
'R: blob bigger than threshold' imports the blobs, and the tests after it inspect the result. Fold them into a single test, which does the import and checks the pack, the blob contents and that the blob is stored only once.
Set 'fastimport.unpackLimit' to 0 for the import so that a pack is written, and verify it with an inline loop in place of 'verify_packs()', which won't be available once the test is moved to another file.
--- t/t9300-fast-import.sh | 79 ++++++++++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 41 deletions(-)
t/t9300-fast-import.sh +38 -41
@@ -3148,51 +3148,48 @@ test_expect_success 'R: corrupt lines do not mess marks file' ' ## R: very large blobs ## test_expect_success 'R: blob bigger than threshold' ' - blobsize=$((2*1024*1024 + 53)) && - test-tool genrandom bar $blobsize >expect && - cat >input <<-INPUT_END && - commit refs/heads/big-file - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <<COMMIT - R - big file - COMMIT - - M 644 inline big1 - data $blobsize - INPUT_END - cat expect >>input && - cat >>input <<-INPUT_END && - M 644 inline big2 - data $blobsize - INPUT_END - cat expect >>input && - echo >>input && - - test_create_repo R && - git --git-dir=R/.git config fastimport.unpackLimit 0 && - git --git-dir=R/.git fast-import --big-file-threshold=1 <input -' - -test_expect_success 'R: verify created pack' ' + test_when_finished "rm -rf repo" && + git init repo && ( - cd R && - verify_packs -v > ../verify + cd repo && + + blobsize=$((2*1024*1024 + 53)) && + test-tool genrandom bar $blobsize >expect && + cat >input <<-INPUT_END && + commit refs/heads/big-file + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <<COMMIT + R - big file + COMMIT + + M 644 inline big1 + data $blobsize + INPUT_END + cat expect >>input && + cat >>input <<-INPUT_END && + M 644 inline big2 + data $blobsize + INPUT_END + cat expect >>input && + echo >>input && + + git -c fastimport.unpackLimit=0 fast-import --big-file-threshold=1 <input && + + for p in .git/objects/pack/*.pack + do + git verify-pack -v "$p" || return 1 + done >verify && + + git cat-file blob big-file:big1 >actual && + test_cmp_bin expect actual && + a=$(git rev-parse big-file:big1) && + b=$(git rev-parse big-file:big2) && + test $a = $b && + n=$(grep $a verify | wc -l) && + test 1 = $n ) ' -test_expect_success 'R: verify written objects' ' - git --git-dir=R/.git cat-file blob big-file:big1 >actual && - test_cmp_bin expect actual && - a=$(git --git-dir=R/.git rev-parse big-file:big1) && - b=$(git --git-dir=R/.git rev-parse big-file:big2) && - test $a = $b -' - -test_expect_success 'R: blob appears only once' ' - n=$(grep $a verify | wc -l) && - test 1 = $n -' - ### ### series S (mark and path parsing) ###
Signature · 1 line
2.56.GIT
PATCH 10/20 t9300: make the ref update tests self-contained
In reply to Karthik NayakSimilar 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()'.
--- t/t9300-fast-import.sh | 214 +++++++++++++++++++++++++++---------------------- 1 file changed, 119 insertions(+), 95 deletions(-)
t/t9300-fast-import.sh +119 -95
@@ -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 <<COMMIT - losing things already? - COMMIT + setup_two_commit_repo && + ( + cd repo && + old_branch=$(git rev-parse --verify main^0) && + test_tick && + cat >input <<-INPUT_END && + commit refs/heads/main + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <<COMMIT + losing things already? + COMMIT - from refs/heads/branch~1 + from refs/heads/main~1 - reset refs/heads/other - from refs/heads/branch + reset refs/heads/other + from refs/heads/main - INPUT_END + INPUT_END - test_must_fail git fast-import <input && - # branch must remain unaffected - test $old_branch = $(git rev-parse --verify branch^0) -' + test_must_fail git -c fastimport.unpackLimit=0 fast-import <input && + # branch must remain unaffected + test $old_branch = $(git rev-parse --verify main^0) && -test_expect_success 'F: verify pack' ' - verify_packs -' + for p in .git/objects/pack/*.pack + do + git verify-pack "$p" || return 1 + done && -test_expect_success 'F: verify other commit' ' - cat >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 <<COMMIT - losing things already? - COMMIT + setup_two_commit_repo && + ( + cd repo && + old_branch=$(git rev-parse --verify main^0) && + test_tick && + cat >input <<-INPUT_END && + commit refs/heads/main + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <<COMMIT + losing things already? + COMMIT - from refs/heads/branch~1 + from refs/heads/main~1 - INPUT_END - git fast-import --force <input -' + INPUT_END + git -c fastimport.unpackLimit=0 fast-import --force <input && + # branch changed, but logged + test $old_branch != $(git rev-parse --verify main^0) && + test $old_branch = $(git rev-parse --verify main@{1}) && -test_expect_success 'G: verify pack' ' - verify_packs -' - -test_expect_success 'G: branch changed, but logged' ' - test $old_branch != $(git rev-parse --verify branch^0) && - test $old_branch = $(git rev-parse --verify branch@{1}) + for p in .git/objects/pack/*.pack + do + git verify-pack "$p" || return 1 + done + ) ' ###
@@ -1017,42 +1030,50 @@ test_expect_success 'I: verify edge list' ' ### test_expect_success 'J: reset existing branch creates empty commit' ' - cat >input <<-INPUT_END && - commit refs/heads/J - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <<COMMIT - create J - COMMIT + setup_two_commit_repo && + ( + cd repo && + cat >input <<-INPUT_END && + commit refs/heads/J + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <<COMMIT + create J + COMMIT - from refs/heads/branch + from refs/heads/main - reset refs/heads/J + reset refs/heads/J - commit refs/heads/J - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <<COMMIT - initialize J - COMMIT + commit refs/heads/J + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <<COMMIT + initialize J + COMMIT - INPUT_END - git fast-import <input -' -test_expect_success 'J: branch has 1 commit, empty tree' ' - test 1 = $(git rev-list J | wc -l) && - test 0 = $(git ls-tree J | wc -l) + INPUT_END + git fast-import <input && + # branch has 1 commit, empty tree + test 1 = $(git rev-list J | wc -l) && + test 0 = $(git ls-tree J | wc -l) + ) ' test_expect_success 'J: tag must fail on empty branch' ' - cat >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 <<EOF - Tag branch that was reset. - EOF - INPUT_END - test_must_fail git fast-import <input + tag wrong_tag + from refs/heads/J2 + data <<EOF + Tag branch that was reset. + EOF + INPUT_END + test_must_fail git fast-import <input + ) ' ###
@@ -1060,29 +1081,32 @@ test_expect_success 'J: tag must fail on empty branch' ' ### test_expect_success 'K: reinit branch with from' ' - cat >input <<-INPUT_END && - commit refs/heads/K - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <<COMMIT - create K - COMMIT + setup_two_commit_repo && + ( + cd repo && + cat >input <<-INPUT_END && + commit refs/heads/K + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <<COMMIT + create K + COMMIT - from refs/heads/branch + from refs/heads/main - commit refs/heads/K - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <<COMMIT - redo K - COMMIT + commit refs/heads/K + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <<COMMIT + redo K + COMMIT - from refs/heads/branch^1 + from refs/heads/main^1 - INPUT_END - git fast-import <input -' -test_expect_success 'K: verify K^1 = branch^1' ' - test $(git rev-parse --verify branch^1) \ - = $(git rev-parse --verify K^1) + INPUT_END + git fast-import <input && + # K^1 = main^1 + test $(git rev-parse --verify main^1) \ + = $(git rev-parse --verify K^1) + ) ' ###
Signature · 1 line
2.56.GIT
PATCH 11/20 t9300: make the date format tests self-contained
In reply to Karthik NayakSimilar to the previous commits, modify the date format tests to make them independent of state from previous tests.
Fold the 'E: verify pack' and 'E: verify commit' tests into the test performing the import. As 'fastimport.unpackLimit' is no longer set by an earlier test, set it for the import so that a pack is written, and verify the pack with an inline loop in place of 'verify_packs()'.
--- t/t9300-fast-import.sh | 72 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 49 insertions(+), 23 deletions(-)
t/t9300-fast-import.sh +49 -23
@@ -828,37 +828,63 @@ test_expect_success 'D: verify file6' ' ### test_expect_success 'E: rfc2822 date, --date-format=raw' ' - cat >input <<-INPUT_END && - commit refs/heads/branch - author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> Tue Feb 6 11:22:18 2007 -0500 - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> Tue Feb 6 12:35:02 2007 -0500 - data <<COMMIT - RFC 2822 type date - COMMIT + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + test_commit one && - from refs/heads/branch^0 + cat >input <<-INPUT_END && + commit refs/heads/main + author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> Tue Feb 6 11:22:18 2007 -0500 + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> Tue Feb 6 12:35:02 2007 -0500 + data <<COMMIT + RFC 2822 type date + COMMIT - INPUT_END + from refs/heads/main^0 - test_must_fail git fast-import --date-format=raw <input + INPUT_END + + test_must_fail git fast-import --date-format=raw <input + ) ' + test_expect_success 'E: rfc2822 date, --date-format=rfc2822' ' - git fast-import --date-format=rfc2822 <input -' + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + test_commit one && -test_expect_success 'E: verify pack' ' - verify_packs -' + cat >input <<-INPUT_END && + commit refs/heads/main + author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> Tue Feb 6 11:22:18 2007 -0500 + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> Tue Feb 6 12:35:02 2007 -0500 + data <<COMMIT + RFC 2822 type date + COMMIT -test_expect_success 'E: verify commit' ' - cat >expect <<-EOF && - author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> 1170778938 -0500 - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1170783302 -0500 + from refs/heads/main^0 - RFC 2822 type date - EOF - git cat-file commit branch | sed 1,2d >actual && - test_cmp expect actual + INPUT_END + + git -c fastimport.unpackLimit=0 fast-import --date-format=rfc2822 <input && + + cat >expect <<-EOF && + author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> 1170778938 -0500 + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1170783302 -0500 + + RFC 2822 type date + EOF + git cat-file commit main | sed 1,2d >actual && + test_cmp expect actual && + + for p in .git/objects/pack/*.pack + do + git verify-pack "$p" || return 1 + done + ) ' ###
Signature · 1 line
2.56.GIT
PATCH 12/20 t9300: make the pack edges test self-contained
In reply to Karthik NayakSimilar to the previous commits, modify the pack-edges tests to make them independent of state from previous tests.
Fold 'I: verify edge list' into the test creating the edge list, as it can't run on its own. Pack edges are only recorded for packs which are kept, so set 'fastimport.unpackLimit' to 0 for the import.
Create the repository with 'git init -b main', as the import builds on 'main' and t9302, where this test ends up, doesn't set 'GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME'.
--- t/t9300-fast-import.sh | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-)
t/t9300-fast-import.sh +23 -16
@@ -1030,25 +1030,32 @@ test_expect_success 'H: verify file' ' ### test_expect_success 'I: export-pack-edges' ' - cat >input <<-INPUT_END && - commit refs/heads/export-boundary - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <<COMMIT - we have a border. its only 40 characters wide. - COMMIT + test_when_finished "rm -rf repo" && + git init -b main repo && + ( + cd repo && + test_commit one && - from refs/heads/branch + cat >input <<-INPUT_END && + commit refs/heads/export-boundary + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <<COMMIT + we have a border. its only 40 characters wide. + COMMIT - INPUT_END - git fast-import --export-pack-edges=edges.list <input -' + from refs/heads/main -test_expect_success 'I: verify edge list' ' - cat >expect <<-EOF && - .git/objects/pack/pack-.pack: $(git rev-parse --verify export-boundary) - EOF - sed -e s/pack-.*pack/pack-.pack/ edges.list >actual && - test_cmp expect actual + INPUT_END + git -c fastimport.unpackLimit=0 fast-import \ + --export-pack-edges=edges.list <input && + + # verify edge list + cat >expect <<-EOF && + .git/objects/pack/pack-.pack: $(git rev-parse --verify export-boundary) + EOF + sed -e s/pack-.*pack/pack-.pack/ edges.list >actual && + test_cmp expect actual + ) ' ###
Signature · 1 line
2.56.GIT
PATCH 13/20 t9300: make the marks tests self-contained
In reply to Karthik NayakSimilar to the previous commits, modify the marks tests to make them independent of state from previous tests.
Several tests import the marks file written by an earlier test. Add a 'create_marks_file()' function which writes one, with marks for commits and tags too, so each test can invoke it in its own repository.
'R: feature import-marks-if-exists' writes a marks file pointing to a blob it never stores, relying on an earlier test having written it. Write the blob in the test itself. Also run 'A: export marks with large values' in its own repository.
--- t/t9300-fast-import.sh | 512 +++++++++++++++++++++++++++++++------------------ 1 file changed, 322 insertions(+), 190 deletions(-)
t/t9300-fast-import.sh +322 -190
@@ -298,59 +298,65 @@ test_expect_success 'A: verify diff' ' ' test_expect_success 'A: export marks with large values' ' - test_tick && - mt=$(git hash-object --stdin < /dev/null) && - >input.blob && - >marks.exp && - >tree.exp && + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && - cat >input.commit <<-EOF && - commit refs/heads/verify--dump-marks - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <<COMMIT - test the sparse array dumping routines with exponentially growing marks - COMMIT - EOF + test_tick && + mt=$(git hash-object --stdin < /dev/null) && + >input.blob && + >marks.exp && + >tree.exp && - i=0 l=4 m=6 n=7 && - while test "$i" -lt 27 - do - cat >>input.blob <<-EOF && - blob - mark :$l - data 0 - blob - mark :$m - data 0 - blob - mark :$n - data 0 + cat >input.commit <<-EOF && + commit refs/heads/verify--dump-marks + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <<COMMIT + test the sparse array dumping routines with exponentially growing marks + COMMIT EOF - echo "M 100644 :$l l$i" >>input.commit && - echo "M 100644 :$m m$i" >>input.commit && - echo "M 100644 :$n n$i" >>input.commit && - echo ":$l $mt" >>marks.exp && - echo ":$m $mt" >>marks.exp && - echo ":$n $mt" >>marks.exp && + i=0 l=4 m=6 n=7 && + while test "$i" -lt 27 + do + cat >>input.blob <<-EOF && + blob + mark :$l + data 0 + blob + mark :$m + data 0 + blob + mark :$n + data 0 + EOF + echo "M 100644 :$l l$i" >>input.commit && + echo "M 100644 :$m m$i" >>input.commit && + echo "M 100644 :$n n$i" >>input.commit && - printf "100644 blob $mt\tl$i\n" >>tree.exp && - printf "100644 blob $mt\tm$i\n" >>tree.exp && - printf "100644 blob $mt\tn$i\n" >>tree.exp && + echo ":$l $mt" >>marks.exp && + echo ":$m $mt" >>marks.exp && + echo ":$n $mt" >>marks.exp && - l=$(($l + $l)) && - m=$(($m + $m)) && - n=$(($l + $n)) && + printf "100644 blob $mt\tl$i\n" >>tree.exp && + printf "100644 blob $mt\tm$i\n" >>tree.exp && + printf "100644 blob $mt\tn$i\n" >>tree.exp && - i=$((1 + $i)) || return 1 - done && + l=$(($l + $l)) && + m=$(($m + $m)) && + n=$(($l + $n)) && - sort tree.exp > tree.exp_s && + i=$((1 + $i)) || return 1 + done && - cat input.blob input.commit | git fast-import --export-marks=marks.large && - git ls-tree refs/heads/verify--dump-marks >tree.out && - test_cmp tree.exp_s tree.out && - test_cmp marks.exp marks.large + sort tree.exp > tree.exp_s && + + cat input.blob input.commit | git fast-import --export-marks=marks.large && + git ls-tree refs/heads/verify--dump-marks >tree.out && + test_cmp tree.exp_s tree.out && + test_cmp marks.exp marks.large + ) ' ###
@@ -2652,196 +2658,316 @@ test_expect_success 'R: export-marks feature forbidden by default' ' ' test_expect_success 'R: export-marks feature results in a marks file being created' ' - cat >input <<-EOF && - feature export-marks=git.marks - blob - mark :1 - data 3 - hi + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && - EOF + cat >input <<-EOF && + feature export-marks=git.marks + blob + mark :1 + data 3 + hi - git fast-import --allow-unsafe-features <input && - test_grep :1 git.marks + EOF + + git fast-import --allow-unsafe-features <input && + test_grep :1 git.marks + ) ' test_expect_success 'R: export-marks options can be overridden by commandline options' ' - cat >input <<-\EOF && - feature export-marks=feature-sub/git.marks - blob - mark :1 - data 3 - hi + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && - EOF - git fast-import --allow-unsafe-features \ - --export-marks=cmdline-sub/other.marks <input && - test_grep :1 cmdline-sub/other.marks && - test_path_is_missing feature-sub + cat >input <<-\EOF && + feature export-marks=feature-sub/git.marks + blob + mark :1 + data 3 + hi + + EOF + git fast-import --allow-unsafe-features \ + --export-marks=cmdline-sub/other.marks <input && + test_grep :1 cmdline-sub/other.marks && + test_path_is_missing feature-sub + ) ' test_expect_success 'R: catch typo in marks file name' ' - test_must_fail git fast-import --import-marks=nonexistent.marks </dev/null && - echo "feature import-marks=nonexistent.marks" | - test_must_fail git fast-import --allow-unsafe-features + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + + test_must_fail git fast-import --import-marks=nonexistent.marks </dev/null && + echo "feature import-marks=nonexistent.marks" | + test_must_fail git fast-import --allow-unsafe-features + ) ' test_expect_success 'R: import and output marks can be the same file' ' - rm -f io.marks && - blob=$(echo hi | git hash-object --stdin) && - cat >expect <<-EOF && - :1 $blob - :2 $blob - EOF - git fast-import --export-marks=io.marks <<-\EOF && - blob - mark :1 - data 3 - hi + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && - EOF - git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF && - blob - mark :2 - data 3 - hi + rm -f io.marks && + blob=$(echo hi | git hash-object --stdin) && + cat >expect <<-EOF && + :1 $blob + :2 $blob + EOF + git fast-import --export-marks=io.marks <<-\EOF && + blob + mark :1 + data 3 + hi - EOF - test_cmp expect io.marks + EOF + git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF && + blob + mark :2 + data 3 + hi + + EOF + test_cmp expect io.marks + ) ' test_expect_success 'R: --import-marks=foo --output-marks=foo to create foo fails' ' - rm -f io.marks && - test_must_fail git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF - blob - mark :1 - data 3 - hi + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && - EOF + rm -f io.marks && + test_must_fail git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF + blob + mark :1 + data 3 + hi + + EOF + ) ' test_expect_success 'R: --import-marks-if-exists' ' - rm -f io.marks && - blob=$(echo hi | git hash-object --stdin) && - echo ":1 $blob" >expect && - git fast-import --import-marks-if-exists=io.marks --export-marks=io.marks <<-\EOF && - blob - mark :1 - data 3 - hi + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && - EOF - test_cmp expect io.marks + rm -f io.marks && + blob=$(echo hi | git hash-object --stdin) && + echo ":1 $blob" >expect && + git fast-import --import-marks-if-exists=io.marks --export-marks=io.marks <<-\EOF && + blob + mark :1 + data 3 + hi + + EOF + test_cmp expect io.marks + ) ' test_expect_success 'R: feature import-marks-if-exists' ' - rm -f io.marks && + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && - git fast-import --export-marks=io.marks \ - --allow-unsafe-features <<-\EOF && - feature import-marks-if-exists=not_io.marks - EOF - test_must_be_empty io.marks && + rm -f io.marks && - blob=$(echo hi | git hash-object --stdin) && + git fast-import --export-marks=io.marks \ + --allow-unsafe-features <<-\EOF && + feature import-marks-if-exists=not_io.marks + EOF + test_must_be_empty io.marks && - echo ":1 $blob" >io.marks && - echo ":1 $blob" >expect && - echo ":2 $blob" >>expect && + blob=$(echo hi | git hash-object -w --stdin) && - git fast-import --export-marks=io.marks \ - --allow-unsafe-features <<-\EOF && - feature import-marks-if-exists=io.marks - blob - mark :2 - data 3 - hi + echo ":1 $blob" >io.marks && + echo ":1 $blob" >expect && + echo ":2 $blob" >>expect && - EOF - test_cmp expect io.marks && + git fast-import --export-marks=io.marks \ + --allow-unsafe-features <<-\EOF && + feature import-marks-if-exists=io.marks + blob + mark :2 + data 3 + hi - echo ":3 $blob" >>expect && + EOF + test_cmp expect io.marks && - git fast-import --import-marks=io.marks \ - --export-marks=io.marks \ - --allow-unsafe-features <<-\EOF && - feature import-marks-if-exists=not_io.marks - blob - mark :3 - data 3 - hi + echo ":3 $blob" >>expect && - EOF - test_cmp expect io.marks && + git fast-import --import-marks=io.marks \ + --export-marks=io.marks \ + --allow-unsafe-features <<-\EOF && + feature import-marks-if-exists=not_io.marks + blob + mark :3 + data 3 + hi - git fast-import --import-marks-if-exists=not_io.marks \ - --export-marks=io.marks \ - --allow-unsafe-features <<-\EOF && - feature import-marks-if-exists=io.marks - EOF - test_must_be_empty io.marks + EOF + test_cmp expect io.marks && + + git fast-import --import-marks-if-exists=not_io.marks \ + --export-marks=io.marks \ + --allow-unsafe-features <<-\EOF && + feature import-marks-if-exists=io.marks + EOF + test_must_be_empty io.marks + ) ' -test_expect_success 'R: import to output marks works without any content' ' - cat >input <<-EOF && - feature import-marks=marks.out - feature export-marks=marks.new - EOF +create_marks_file () { + git fast-import --export-marks="$1" <<-EOF + blob + mark :1 + data 4 + one - git fast-import --allow-unsafe-features <input && - test_cmp marks.out marks.new + blob + mark :2 + data 4 + two + + blob + mark :3 + data 6 + three + + blob + mark :4 + data 5 + four + + commit refs/heads/marks + mark :5 + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <<COMMIT + commit with a mark + COMMIT + M 100644 :1 one + + tag marks-tag + mark :6 + from :5 + tagger $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <<TAG + tag with a mark + TAG + + EOF +} + +test_expect_success 'R: import to output marks works without any content' ' + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + create_marks_file marks.out && + + cat >input <<-EOF && + feature import-marks=marks.out + feature export-marks=marks.new + EOF + + git fast-import --allow-unsafe-features <input && + test_cmp marks.out marks.new + ) ' test_expect_success 'R: import marks prefers commandline marks file over the stream' ' - cat >input <<-EOF && - feature import-marks=nonexistent.marks - feature export-marks=marks.new - EOF + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + create_marks_file marks.out && - git fast-import --import-marks=marks.out --allow-unsafe-features <input && - test_cmp marks.out marks.new + cat >input <<-EOF && + feature import-marks=nonexistent.marks + feature export-marks=marks.new + EOF + + git fast-import --import-marks=marks.out --allow-unsafe-features <input && + test_cmp marks.out marks.new + ) ' - test_expect_success 'R: multiple --import-marks= should be honoured' ' - cat >input <<-EOF && - feature import-marks=nonexistent.marks - feature export-marks=combined.marks - EOF + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + create_marks_file marks.out && - head -n2 marks.out > one.marks && - tail -n +3 marks.out > two.marks && - git fast-import --import-marks=one.marks --import-marks=two.marks \ - --allow-unsafe-features <input && - test_cmp marks.out combined.marks + cat >input <<-EOF && + feature import-marks=nonexistent.marks + feature export-marks=combined.marks + EOF + + head -n2 marks.out >one.marks && + tail -n +3 marks.out >two.marks && + git fast-import --import-marks=one.marks --import-marks=two.marks \ + --allow-unsafe-features <input && + test_cmp marks.out combined.marks + ) ' test_expect_success 'R: feature relative-marks should be honoured' ' - cat >input <<-EOF && - feature relative-marks - feature import-marks=relative.in - feature export-marks=relative.out - EOF + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + create_marks_file marks.out && - mkdir -p .git/info/fast-import/ && - cp marks.new .git/info/fast-import/relative.in && - git fast-import --allow-unsafe-features <input && - test_cmp marks.new .git/info/fast-import/relative.out + cat >input <<-EOF && + feature relative-marks + feature import-marks=relative.in + feature export-marks=relative.out + EOF + + mkdir -p .git/info/fast-import/ && + cp marks.out .git/info/fast-import/relative.in && + git fast-import --allow-unsafe-features <input && + test_cmp marks.out .git/info/fast-import/relative.out + ) ' test_expect_success 'R: feature no-relative-marks should be honoured' ' - cat >input <<-EOF && - feature relative-marks - feature import-marks=relative.in - feature no-relative-marks - feature export-marks=non-relative.out - EOF + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + create_marks_file marks.out && - git fast-import --allow-unsafe-features <input && - test_cmp marks.new non-relative.out + cat >input <<-EOF && + feature relative-marks + feature import-marks=relative.in + feature no-relative-marks + feature export-marks=non-relative.out + EOF + + mkdir -p .git/info/fast-import/ && + cp marks.out .git/info/fast-import/relative.in && + git fast-import --allow-unsafe-features <input && + test_cmp marks.out non-relative.out + ) ' + test_expect_success 'R: feature ls supported' ' echo "feature ls" | git fast-import
@@ -3187,18 +3313,24 @@ test_expect_success 'R: ignore non-git options' ' ' test_expect_success 'R: corrupt lines do not mess marks file' ' - rm -f io.marks && - blob=$(echo hi | git hash-object --stdin) && - cat >expect <<-EOF && - :3 $ZERO_OID - :1 $blob - :2 $blob - EOF - cp expect io.marks && - test_must_fail git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF && + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && - EOF - test_cmp expect io.marks + rm -f io.marks && + blob=$(echo hi | git hash-object --stdin) && + cat >expect <<-EOF && + :3 $ZERO_OID + :1 $blob + :2 $blob + EOF + cp expect io.marks && + test_must_fail git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF && + + EOF + test_cmp expect io.marks + ) ' ##
Signature · 1 line
2.56.GIT
PATCH 14/20 t9300: make the series Y tests self-contained
In reply to Karthik NayakSimilar to the previous commits, modify the 'series Y' tests to make them independent of state from previous tests.
The 'Y: setup' test only fills the OID cache for 'Y: rewrite submodules', so merge it into that test. Also clean up the repositories created by the tests.
--- t/t9300-fast-import.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
t/t9300-fast-import.sh +4 -5
@@ -4498,14 +4498,12 @@ cat >Y-marks <<\Y_INPUT_END :4 ff729f5e62f72c0c3978207d9a80e5f3a65f14d7 Y_INPUT_END -test_expect_success 'Y: setup' ' - test_oid_cache <<-EOF +test_expect_success 'Y: rewrite submodules' ' + test_when_finished "rm -rf main1" && + test_oid_cache <<-EOF && Ymain sha1:9afed2f9161ddf416c0a1863b8b0725b00070504 Ymain sha256:c0a1010da1df187b2e287654793df01b464bd6f8e3f17fc1481a7dadf84caee3 EOF -' - -test_expect_success 'Y: rewrite submodules' ' git init main1 && ( cd main1 &&
@@ -4525,6 +4523,7 @@ test_expect_success 'Y: reference pending tag or commit' ' pending_tag sha256:85edc5eac315bc680677b2fc71622bd77476f057eb8dc8ed6a497803a24f1f46 EOF + test_when_finished "rm -rf reference-pending" && git init reference-pending && ( cd reference-pending &&
Signature · 1 line
2.56.GIT
PATCH 15/20 t9300: make the cat-blob tests self-contained
In reply to Karthik NayakThe 'R: print' tests and 'R: copy using cat-file' write blobs into the repository of the trash directory, which all other tests share. 'R:
print two blobs to stdout' and 'R: copy using cat-file' also read the 'big' file written by the preceding 'setup: big file' test, so they can't run on their own.
Run each of these tests in a new repository. Convert the setup test to a 'setup_big_file()' function, which writes the file in the repository of the calling test, and invoke it from both tests.
--- t/t9300-fast-import.sh | 428 ++++++++++++++++++++++++++++--------------------- 1 file changed, 242 insertions(+), 186 deletions(-)
t/t9300-fast-import.sh +242 -186
@@ -2983,87 +2983,117 @@ test_expect_success 'R: cat-blob-fd must be a nonnegative integer' ' ' test_expect_success !MINGW 'R: print old blob' ' - blob=$(echo "yes it can" | git hash-object -w --stdin) && - cat >expect <<-EOF && - ${blob} blob 11 - yes it can + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && - EOF - echo "cat-blob $blob" | - git fast-import --cat-blob-fd=6 6>actual && - test_cmp expect actual + blob=$(echo "yes it can" | git hash-object -w --stdin) && + cat >expect <<-EOF && + ${blob} blob 11 + yes it can + + EOF + echo "cat-blob $blob" | + git fast-import --cat-blob-fd=6 6>actual && + test_cmp expect actual + ) ' test_expect_success !MINGW 'R: in-stream cat-blob-fd not respected' ' - echo hello >greeting && - blob=$(git hash-object -w greeting) && - cat >expect <<-EOF && - ${blob} blob 6 - hello + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && - EOF - git fast-import --cat-blob-fd=3 3>actual.3 >actual.1 <<-EOF && - cat-blob $blob - EOF - test_cmp expect actual.3 && - test_must_be_empty actual.1 && - git fast-import 3>actual.3 >actual.1 <<-EOF && - option cat-blob-fd=3 - cat-blob $blob - EOF - test_must_be_empty actual.3 && - test_cmp expect actual.1 + echo hello >greeting && + blob=$(git hash-object -w greeting) && + cat >expect <<-EOF && + ${blob} blob 6 + hello + + EOF + git fast-import --cat-blob-fd=3 3>actual.3 >actual.1 <<-EOF && + cat-blob $blob + EOF + test_cmp expect actual.3 && + test_must_be_empty actual.1 && + git fast-import 3>actual.3 >actual.1 <<-EOF && + option cat-blob-fd=3 + cat-blob $blob + EOF + test_must_be_empty actual.3 && + test_cmp expect actual.1 + ) ' test_expect_success !MINGW 'R: print mark for new blob' ' - echo "effluentish" | git hash-object --stdin >expect && - git fast-import --cat-blob-fd=6 6>actual <<-\EOF && - blob - mark :1 - data <<BLOB_END - effluentish - BLOB_END - get-mark :1 - EOF - test_cmp expect actual + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + + echo "effluentish" | git hash-object --stdin >expect && + git fast-import --cat-blob-fd=6 6>actual <<-\EOF && + blob + mark :1 + data <<BLOB_END + effluentish + BLOB_END + get-mark :1 + EOF + test_cmp expect actual + ) ' test_expect_success !MINGW 'R: print new blob' ' - blob=$(echo "yep yep yep" | git hash-object --stdin) && - cat >expect <<-EOF && - ${blob} blob 12 - yep yep yep + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && - EOF - git fast-import --cat-blob-fd=6 6>actual <<-\EOF && - blob - mark :1 - data <<BLOB_END - yep yep yep - BLOB_END - cat-blob :1 - EOF - test_cmp expect actual + blob=$(echo "yep yep yep" | git hash-object --stdin) && + cat >expect <<-EOF && + ${blob} blob 12 + yep yep yep + + EOF + git fast-import --cat-blob-fd=6 6>actual <<-\EOF && + blob + mark :1 + data <<BLOB_END + yep yep yep + BLOB_END + cat-blob :1 + EOF + test_cmp expect actual + ) ' test_expect_success !MINGW 'R: print new blob by sha1' ' - blob=$(echo "a new blob named by sha1" | git hash-object --stdin) && - cat >expect <<-EOF && - ${blob} blob 25 - a new blob named by sha1 + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && - EOF - git fast-import --cat-blob-fd=6 6>actual <<-EOF && - blob - data <<BLOB_END - a new blob named by sha1 - BLOB_END - cat-blob $blob - EOF - test_cmp expect actual + blob=$(echo "a new blob named by sha1" | git hash-object --stdin) && + cat >expect <<-EOF && + ${blob} blob 25 + a new blob named by sha1 + + EOF + git fast-import --cat-blob-fd=6 6>actual <<-EOF && + blob + data <<BLOB_END + a new blob named by sha1 + BLOB_END + cat-blob $blob + EOF + test_cmp expect actual + ) ' -test_expect_success 'setup: big file' ' +setup_big_file () { ( echo "the quick brown fox jumps over the lazy dog" >big && for i in 1 2 3
@@ -3073,153 +3103,179 @@ test_expect_success 'setup: big file' ' exit done ) -' +} test_expect_success 'R: print two blobs to stdout' ' - blob1=$(git hash-object big) && - blob1_len=$(wc -c <big) && - blob2=$(echo hello | git hash-object --stdin) && - { - echo ${blob1} blob $blob1_len && - cat big && - cat <<-EOF + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && - ${blob2} blob 6 - hello + setup_big_file && + blob1=$(git hash-object big) && + blob1_len=$(wc -c <big) && + blob2=$(echo hello | git hash-object --stdin) && + { + echo ${blob1} blob $blob1_len && + cat big && + cat <<-EOF - EOF - } >expect && - { - cat <<-\END_PART1 && - blob - mark :1 - data <<data_end - END_PART1 - cat big && - cat <<-\EOF - data_end - blob - mark :2 - data <<data_end + ${blob2} blob 6 hello - data_end - cat-blob :1 - cat-blob :2 - EOF - } | - git fast-import >actual && - test_cmp expect actual + + EOF + } >expect && + { + cat <<-\END_PART1 && + blob + mark :1 + data <<data_end + END_PART1 + cat big && + cat <<-\EOF + data_end + blob + mark :2 + data <<data_end + hello + data_end + cat-blob :1 + cat-blob :2 + EOF + } | + git fast-import >actual && + test_cmp expect actual + ) ' test_expect_success PIPE 'R: copy using cat-file' ' - expect_id=$(git hash-object big) && - expect_len=$(wc -c <big) && - echo $expect_id blob $expect_len >expect.response && - - rm -f blobs && - - mkfifo blobs && + test_when_finished "rm -rf repo" && + git init repo && ( - export GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL GIT_COMMITTER_DATE && - cat <<-\EOF && - feature cat-blob - blob - mark :1 - data <<BLOB - EOF - cat big && - cat <<-\EOF && - BLOB - cat-blob :1 - EOF + cd repo && - read blob_id type size <&3 && - echo "$blob_id $type $size" >response && - test_copy_bytes $size >blob <&3 && - read newline <&3 && + setup_big_file && + expect_id=$(git hash-object big) && + expect_len=$(wc -c <big) && + echo $expect_id blob $expect_len >expect.response && - cat <<-EOF && - commit refs/heads/copied - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <<COMMIT - copy big file as file3 - COMMIT - M 644 inline file3 - data <<BLOB - EOF - cat blob && - echo BLOB - ) 3<blobs | - git fast-import --cat-blob-fd=3 3>blobs && - git show copied:file3 >actual && - test_cmp expect.response response && - test_cmp big actual + rm -f blobs && + + mkfifo blobs && + ( + export GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL GIT_COMMITTER_DATE && + cat <<-\EOF && + feature cat-blob + blob + mark :1 + data <<BLOB + EOF + cat big && + cat <<-\EOF && + BLOB + cat-blob :1 + EOF + + read blob_id type size <&3 && + echo "$blob_id $type $size" >response && + test_copy_bytes $size >blob <&3 && + read newline <&3 && + + cat <<-EOF && + commit refs/heads/copied + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <<COMMIT + copy big file as file3 + COMMIT + M 644 inline file3 + data <<BLOB + EOF + cat blob && + echo BLOB + ) 3<blobs | + git fast-import --cat-blob-fd=3 3>blobs && + git show copied:file3 >actual && + test_cmp expect.response response && + test_cmp big actual + ) ' test_expect_success PIPE 'R: print blob mid-commit' ' - rm -f blobs && - echo "A blob from _before_ the commit." >expect && - mkfifo blobs && + test_when_finished "rm -rf repo" && + git init repo && ( - exec 3<blobs && - cat <<-EOF && - feature cat-blob - blob - mark :1 - data <<BLOB - A blob from _before_ the commit. - BLOB - commit refs/heads/temporary - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <<COMMIT - Empty commit - COMMIT - cat-blob :1 - EOF + cd repo && - read blob_id type size <&3 && - test_copy_bytes $size >actual <&3 && - read newline <&3 && + rm -f blobs && + echo "A blob from _before_ the commit." >expect && + mkfifo blobs && + ( + exec 3<blobs && + cat <<-EOF && + feature cat-blob + blob + mark :1 + data <<BLOB + A blob from _before_ the commit. + BLOB + commit refs/heads/temporary + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <<COMMIT + Empty commit + COMMIT + cat-blob :1 + EOF - echo - ) | - git fast-import --cat-blob-fd=3 3>blobs && - test_cmp expect actual + read blob_id type size <&3 && + test_copy_bytes $size >actual <&3 && + read newline <&3 && + + echo + ) | + git fast-import --cat-blob-fd=3 3>blobs && + test_cmp expect actual + ) ' test_expect_success PIPE 'R: print staged blob within commit' ' - rm -f blobs && - echo "A blob from _within_ the commit." >expect && - mkfifo blobs && + test_when_finished "rm -rf repo" && + git init repo && ( - exec 3<blobs && - cat <<-EOF && - feature cat-blob - commit refs/heads/within - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <<COMMIT - Empty commit - COMMIT - M 644 inline within - data <<BLOB - A blob from _within_ the commit. - BLOB - EOF + cd repo && - to_get=$( - echo "A blob from _within_ the commit." | - git hash-object --stdin - ) && - echo "cat-blob $to_get" && + rm -f blobs && + echo "A blob from _within_ the commit." >expect && + mkfifo blobs && + ( + exec 3<blobs && + cat <<-EOF && + feature cat-blob + commit refs/heads/within + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <<COMMIT + Empty commit + COMMIT + M 644 inline within + data <<BLOB + A blob from _within_ the commit. + BLOB + EOF - read blob_id type size <&3 && - test_copy_bytes $size >actual <&3 && - read newline <&3 && + to_get=$( + echo "A blob from _within_ the commit." | + git hash-object --stdin + ) && + echo "cat-blob $to_get" && - echo deleteall - ) | - git fast-import --cat-blob-fd=3 3>blobs && - test_cmp expect actual + read blob_id type size <&3 && + test_copy_bytes $size >actual <&3 && + read newline <&3 && + + echo deleteall + ) | + git fast-import --cat-blob-fd=3 3>blobs && + test_cmp expect actual + ) ' test_expect_success 'R: quiet option results in no stats being output' '
Signature · 1 line
2.56.GIT
PATCH 16/20 t9300: make the feature and option tests self-contained
In reply to Karthik NayakSimilar to the previous commits, modify the tests in 'series R' which check the 'feature' command and the command line options to make them independent of state from previous tests.
--- t/t9300-fast-import.sh | 188 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 136 insertions(+), 52 deletions(-)
t/t9300-fast-import.sh +136 -52
@@ -2607,54 +2607,90 @@ test_expect_success 'Q: deny note on empty branch' ' ### test_expect_success 'R: abort on unsupported feature' ' - cat >input <<-EOF && - feature no-such-feature-exists - EOF + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && - test_must_fail git fast-import <input + cat >input <<-EOF && + feature no-such-feature-exists + EOF + + test_must_fail git fast-import <input + ) ' test_expect_success 'R: supported feature is accepted' ' - cat >input <<-EOF && - feature date-format=now - EOF + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && - git fast-import <input + cat >input <<-EOF && + feature date-format=now + EOF + + git fast-import <input + ) ' test_expect_success 'R: abort on receiving feature after data command' ' - cat >input <<-EOF && - blob - data 3 - hi - feature date-format=now - EOF + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && - test_must_fail git fast-import <input + cat >input <<-EOF && + blob + data 3 + hi + feature date-format=now + EOF + + test_must_fail git fast-import <input + ) ' test_expect_success 'R: import-marks features forbidden by default' ' - >git.marks && - echo "feature import-marks=git.marks" >input && - test_must_fail git fast-import <input && - echo "feature import-marks-if-exists=git.marks" >input && - test_must_fail git fast-import <input + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + + >git.marks && + echo "feature import-marks=git.marks" >input && + test_must_fail git fast-import <input && + echo "feature import-marks-if-exists=git.marks" >input && + test_must_fail git fast-import <input + ) ' test_expect_success 'R: only one import-marks feature allowed per stream' ' - >git.marks && - >git2.marks && - cat >input <<-EOF && - feature import-marks=git.marks - feature import-marks=git2.marks - EOF + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && - test_must_fail git fast-import --allow-unsafe-features <input + >git.marks && + >git2.marks && + cat >input <<-EOF && + feature import-marks=git.marks + feature import-marks=git2.marks + EOF + + test_must_fail git fast-import --allow-unsafe-features <input + ) ' test_expect_success 'R: export-marks feature forbidden by default' ' - echo "feature export-marks=git.marks" >input && - test_must_fail git fast-import <input + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + + echo "feature export-marks=git.marks" >input && + test_must_fail git fast-import <input + ) ' test_expect_success 'R: export-marks feature results in a marks file being created' '
@@ -2969,17 +3005,35 @@ test_expect_success 'R: feature no-relative-marks should be honoured' ' test_expect_success 'R: feature ls supported' ' - echo "feature ls" | - git fast-import + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + + echo "feature ls" | + git fast-import + ) ' test_expect_success 'R: feature cat-blob supported' ' - echo "feature cat-blob" | - git fast-import + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + + echo "feature cat-blob" | + git fast-import + ) ' test_expect_success 'R: cat-blob-fd must be a nonnegative integer' ' - test_must_fail git fast-import --cat-blob-fd=-1 </dev/null + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + + test_must_fail git fast-import --cat-blob-fd=-1 </dev/null + ) ' test_expect_success !MINGW 'R: print old blob' '
@@ -3334,38 +3388,68 @@ test_expect_success 'R: terminating "done" within commit' ' ' test_expect_success 'R: die on unknown option' ' - cat >input <<-EOF && - option git non-existing-option - EOF + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && - test_must_fail git fast-import <input + cat >input <<-EOF && + option git non-existing-option + EOF + + test_must_fail git fast-import <input + ) ' test_expect_success 'R: unknown commandline options are rejected' '\ - test_must_fail git fast-import --non-existing-option < /dev/null + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + + test_must_fail git fast-import --non-existing-option < /dev/null + ) ' test_expect_success 'R: feature-only names are rejected on the command line' ' - for opt in --alias --get-mark --ls --notes - do - test_must_fail git fast-import "$opt" </dev/null || return 1 - done + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + + for opt in --alias --get-mark --ls --notes + do + test_must_fail git fast-import "$opt" </dev/null || return 1 + done + ) ' test_expect_success 'R: die on invalid option argument' ' - echo "option git active-branches=-5" | - test_must_fail git fast-import && - echo "option git depth=" | - test_must_fail git fast-import && - test_must_fail git fast-import --depth="5 elephants" </dev/null + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + + echo "option git active-branches=-5" | + test_must_fail git fast-import && + echo "option git depth=" | + test_must_fail git fast-import && + test_must_fail git fast-import --depth="5 elephants" </dev/null + ) ' test_expect_success 'R: ignore non-git options' ' - cat >input <<-EOF && - option non-existing-vcs non-existing-option - EOF + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && - git fast-import <input + cat >input <<-EOF && + option non-existing-vcs non-existing-option + EOF + + git fast-import <input + ) ' test_expect_success 'R: corrupt lines do not mess marks file' '
Signature · 1 line
2.56.GIT
PATCH 17/20 t9300: make the stream tests self-contained
In reply to Karthik NayakSimilar to the previous commits, modify the tests in 'series R' which check empty and truncated streams, the 'quiet' option and the 'done' feature to make them independent of state from previous tests.
'empty stream succeeds' no longer needs to configure 'fastimport.unpackLimit', as that was moved to the first test needing it by an earlier commit.
--- t/t9300-fast-import.sh | 122 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 79 insertions(+), 43 deletions(-)
t/t9300-fast-import.sh +79 -43
@@ -38,11 +38,23 @@ echo "$@"' ### test_expect_success 'empty stream succeeds' ' - git fast-import </dev/null + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + + git fast-import </dev/null + ) ' test_expect_success 'truncated stream complains' ' - echo "tag foo" | test_must_fail git fast-import + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + + echo "tag foo" | test_must_fail git fast-import + ) ' test_expect_success 'A: create pack from stdin' '
@@ -3333,58 +3345,82 @@ test_expect_success PIPE 'R: print staged blob within commit' ' ' test_expect_success 'R: quiet option results in no stats being output' ' - cat >input <<-EOF && - option git quiet - blob - data 3 - hi + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && - EOF + cat >input <<-EOF && + option git quiet + blob + data 3 + hi - git fast-import 2>output <input && - test_must_be_empty output + EOF + + git fast-import 2>output <input && + test_must_be_empty output + ) ' test_expect_success 'R: feature done means terminating "done" is mandatory' ' - echo feature done | test_must_fail git fast-import && - test_must_fail git fast-import --done </dev/null + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + + echo feature done | test_must_fail git fast-import && + test_must_fail git fast-import --done </dev/null + ) ' test_expect_success 'R: terminating "done" with trailing gibberish is ok' ' - git fast-import <<-\EOF && - feature done - done - trailing gibberish - EOF - git fast-import <<-\EOF - done - more trailing gibberish - EOF + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + + git fast-import <<-\EOF && + feature done + done + trailing gibberish + EOF + git fast-import <<-\EOF + done + more trailing gibberish + EOF + ) ' test_expect_success 'R: terminating "done" within commit' ' - cat >expect <<-\EOF && - OBJID - :000000 100644 OBJID OBJID A hello.c - :000000 100644 OBJID OBJID A hello2.c - EOF - git fast-import <<-EOF && - commit refs/heads/done-ends - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <<EOT - Commit terminated by "done" command - EOT - M 100644 inline hello.c - data <<EOT - Hello, world. - EOT - C hello.c hello2.c - done - EOF - git rev-list done-ends | - git diff-tree -r --stdin --root --always | - sed -e "s/$OID_REGEX/OBJID/g" >actual && - test_cmp expect actual + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + + cat >expect <<-\EOF && + OBJID + :000000 100644 OBJID OBJID A hello.c + :000000 100644 OBJID OBJID A hello2.c + EOF + git fast-import <<-EOF && + commit refs/heads/done-ends + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <<EOT + Commit terminated by "done" command + EOT + M 100644 inline hello.c + data <<EOT + Hello, world. + EOT + C hello.c hello2.c + done + EOF + git rev-list done-ends | + git diff-tree -r --stdin --root --always | + sed -e "s/$OID_REGEX/OBJID/g" >actual && + test_cmp expect actual + ) ' test_expect_success 'R: die on unknown option' '
Signature · 1 line
2.56.GIT
PATCH 18/20 t9300: make the get-mark and encoding tests self-contained
In reply to Karthik NayakSimilar to the previous commits, modify the tests in 'series W' and 'X:
handling encoding' to make them independent of state from previous tests.
The 'W' tests read the 'W-input' file written at the top level of the script, which is not in the new repository. Turn it into a 'w_input()' function which prints the stream.
'X: replace ref that becomes useless is removed' changes its working directory and doesn't change back, so the tests after it, run in that repository. Move the 'cd' into the subshell, and cleanup when the test completes.
--- t/t9300-fast-import.sh | 81 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 57 insertions(+), 24 deletions(-)
t/t9300-fast-import.sh +57 -24
@@ -4503,7 +4503,8 @@ test_expect_success PIPE 'V: checkpoint updates tags after tag' ' ### series W (get-mark and empty orphan commits) ### -cat >>W-input <<-W_INPUT_END +w_input () { + cat <<-W_INPUT_END commit refs/heads/W-branch mark :1 author Full Name <[email protected]> 1000000000 +0100
@@ -4512,28 +4513,53 @@ cat >>W-input <<-W_INPUT_END Intentionally empty commit LFsget-mark :1 W_INPUT_END +} test_expect_success !MINGW 'W: get-mark & empty orphan commit with no newlines' ' - sed -e s/LFs// W-input | tr L "\n" | git fast-import + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + + w_input | sed -e s/LFs// | tr L "\n" | git fast-import + ) ' test_expect_success !MINGW 'W: get-mark & empty orphan commit with one newline' ' - sed -e s/LFs/L/ W-input | tr L "\n" | git fast-import + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + + w_input | sed -e s/LFs/L/ | tr L "\n" | git fast-import + ) ' test_expect_success !MINGW 'W: get-mark & empty orphan commit with ugly second newline' ' - # Technically, this should fail as it has too many linefeeds - # according to the grammar in fast-import.txt. But, for whatever - # reason, it works. Since using the correct number of newlines - # does not work with older (pre-2.22) versions of git, allow apps - # that used this second-newline workaround to keep working by - # checking it with this test... - sed -e s/LFs/LL/ W-input | tr L "\n" | git fast-import + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + + # Technically, this should fail as it has too many linefeeds + # according to the grammar in fast-import.txt. But, for whatever + # reason, it works. Since using the correct number of newlines + # does not work with older (pre-2.22) versions of git, allow apps + # that used this second-newline workaround to keep working by + # checking it with this test... + w_input | sed -e s/LFs/LL/ | tr L "\n" | git fast-import + ) ' test_expect_success !MINGW 'W: get-mark & empty orphan commit with erroneous third newline' ' - # ...but do NOT allow more empty lines than that (see previous test). - sed -e s/LFs/LLL/ W-input | tr L "\n" | test_must_fail git fast-import + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + + # ...but do NOT allow more empty lines than that (see previous test). + w_input | sed -e s/LFs/LLL/ | tr L "\n" | test_must_fail git fast-import + ) ' ###
@@ -4541,25 +4567,32 @@ test_expect_success !MINGW 'W: get-mark & empty orphan commit with erroneous thi ### test_expect_success ICONV 'X: handling encoding' ' - test_tick && - cat >input <<-INPUT_END && - commit refs/heads/encoding - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - encoding iso-8859-7 - data <<COMMIT - INPUT_END + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && - printf "Pi: \360\nCOMMIT\n" >>input && + test_tick && + cat >input <<-INPUT_END && + commit refs/heads/encoding + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + encoding iso-8859-7 + data <<COMMIT + INPUT_END - git fast-import <input && - git cat-file -p encoding | grep $(printf "\360") && - git log -1 --format=%B encoding | grep $(printf "\317\200") + printf "Pi: \360\nCOMMIT\n" >>input && + + git fast-import <input && + git cat-file -p encoding | grep $(printf "\360") && + git log -1 --format=%B encoding | grep $(printf "\317\200") + ) ' test_expect_success 'X: replace ref that becomes useless is removed' ' + test_when_finished "rm -rf testrepo" && git init -qb main testrepo && - cd testrepo && ( + cd testrepo && test_commit test && test_commit msg somename content &&
Signature · 1 line
2.56.GIT
PATCH 19/20 t9300: move self-contained tests into dedicated files
In reply to Karthik NayakThe previous commits worked on making most of the tests within t9300 independent from each other. Now we can move them, as they are, to other files based on what they exercise. Create some new test files:
- t9307-fast-import-validation
- t9308-fast-import-stream
- t9309-fast-import-checkpoint
- t9310-fast-import-submodule
- t9311-fast-import-refs
and move the others to existing test files:
- t9301-fast-import-notes
- t9304-fast-import-marks
Register the new test files in t/meson.build.
The series 'A', 'C', 'D', 'H', 'L', 'M', 'N' and 'U' stay in t9300, as they still depend on each other. The tests are moved without changes, which can be checked with 'git show --color-moved'.
--- t/meson.build | 5 + t/t9300-fast-import.sh | 3565 ------------------------------------- t/t9301-fast-import-notes.sh | 411 +++++ t/t9304-fast-import-marks.sh | 393 ++++ t/t9307-fast-import-validation.sh | 1193 +++++++++++++ t/t9308-fast-import-stream.sh | 822 +++++++++ t/t9309-fast-import-checkpoint.sh | 188 ++ t/t9310-fast-import-submodule.sh | 341 ++++ t/t9311-fast-import-refs.sh | 194 ++ 9 files changed, 3547 insertions(+), 3565 deletions(-)
t/meson.build +5 -0
@@ -1084,6 +1084,11 @@ integration_tests = [ 't9304-fast-import-marks.sh', 't9305-fast-import-signatures.sh', 't9306-fast-import-signed-tags.sh', + 't9307-fast-import-validation.sh', + 't9308-fast-import-stream.sh', + 't9309-fast-import-checkpoint.sh', + 't9310-fast-import-submodule.sh', + 't9311-fast-import-refs.sh', 't9350-fast-export.sh', 't9351-fast-export-anonymize.sh', 't9400-git-cvsserver-server.sh',
t/t9300-fast-import.sh +0 -3565
2,989 lines not on this page · raw message
t/t9301-fast-import-notes.sh +411 -0
411 lines not on this page · raw message
t/t9304-fast-import-marks.sh +393 -0
393 lines not on this page · raw message
t/t9307-fast-import-validation.sh new file +1193 -0
1,193 lines not on this page · raw message
t/t9308-fast-import-stream.sh new file +822 -0
822 lines not on this page · raw message
t/t9309-fast-import-checkpoint.sh new file +188 -0
188 lines not on this page · raw message
t/t9310-fast-import-submodule.sh new file +341 -0
341 lines not on this page · raw message
t/t9311-fast-import-refs.sh new file +194 -0
194 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.56.GIT
Part of the diff is not shown here. View the raw message.
PATCH 20/20 t93xx: drop the series letter from the moved test names
In reply to Karthik NayakIn the previous commits, tests were moved from t9300 to other test files as is. Each of these tests have their descriptions prefixed with their series names. Since they don't hold any value outside of t9300, drop them.
--- t/t9301-fast-import-notes.sh | 42 ++++++++--------- t/t9304-fast-import-marks.sh | 28 ++++++------ t/t9307-fast-import-validation.sh | 96 +++++++++++++++++++-------------------- t/t9308-fast-import-stream.sh | 52 ++++++++++----------- t/t9309-fast-import-checkpoint.sh | 10 ++-- t/t9310-fast-import-submodule.sh | 12 ++--- t/t9311-fast-import-refs.sh | 14 +++--- 7 files changed, 127 insertions(+), 127 deletions(-)
t/t9301-fast-import-notes.sh +21 -21
@@ -860,7 +860,7 @@ echo \"\$@\"" && commit3=$(git -C repo rev-parse notes-test) } -test_expect_success 'Q: verify pack' ' +test_expect_success 'verify pack' ' setup_notes_repo && ( cd repo &&
@@ -871,7 +871,7 @@ test_expect_success 'Q: verify pack' ' ) ' -test_expect_success 'Q: verify first commit' ' +test_expect_success 'verify first commit' ' setup_notes_repo && ( cd repo &&
@@ -886,7 +886,7 @@ test_expect_success 'Q: verify first commit' ' ) ' -test_expect_success 'Q: verify second commit' ' +test_expect_success 'verify second commit' ' setup_notes_repo && ( cd repo &&
@@ -902,7 +902,7 @@ test_expect_success 'Q: verify second commit' ' ) ' -test_expect_success 'Q: verify third commit' ' +test_expect_success 'verify third commit' ' setup_notes_repo && ( cd repo &&
@@ -918,7 +918,7 @@ test_expect_success 'Q: verify third commit' ' ) ' -test_expect_success 'Q: verify first notes commit' ' +test_expect_success 'verify first notes commit' ' setup_notes_repo && ( cd repo &&
@@ -933,7 +933,7 @@ test_expect_success 'Q: verify first notes commit' ' ) ' -test_expect_success 'Q: verify first notes tree' ' +test_expect_success 'verify first notes tree' ' setup_notes_repo && ( cd repo &&
@@ -947,7 +947,7 @@ test_expect_success 'Q: verify first notes tree' ' ) ' -test_expect_success 'Q: verify first note for first commit' ' +test_expect_success 'verify first note for first commit' ' setup_notes_repo && ( cd repo &&
@@ -957,7 +957,7 @@ test_expect_success 'Q: verify first note for first commit' ' ) ' -test_expect_success 'Q: verify first note for second commit' ' +test_expect_success 'verify first note for second commit' ' setup_notes_repo && ( cd repo &&
@@ -967,7 +967,7 @@ test_expect_success 'Q: verify first note for second commit' ' ) ' -test_expect_success 'Q: verify first note for third commit' ' +test_expect_success 'verify first note for third commit' ' setup_notes_repo && ( cd repo &&
@@ -977,7 +977,7 @@ test_expect_success 'Q: verify first note for third commit' ' ) ' -test_expect_success 'Q: verify second notes commit' ' +test_expect_success 'verify second notes commit' ' setup_notes_repo && ( cd repo &&
@@ -993,7 +993,7 @@ test_expect_success 'Q: verify second notes commit' ' ) ' -test_expect_success 'Q: verify second notes tree' ' +test_expect_success 'verify second notes tree' ' setup_notes_repo && ( cd repo &&
@@ -1007,7 +1007,7 @@ test_expect_success 'Q: verify second notes tree' ' ) ' -test_expect_success 'Q: verify second note for first commit' ' +test_expect_success 'verify second note for first commit' ' setup_notes_repo && ( cd repo &&
@@ -1017,7 +1017,7 @@ test_expect_success 'Q: verify second note for first commit' ' ) ' -test_expect_success 'Q: verify first note for second commit' ' +test_expect_success 'verify first note for second commit' ' setup_notes_repo && ( cd repo &&
@@ -1027,7 +1027,7 @@ test_expect_success 'Q: verify first note for second commit' ' ) ' -test_expect_success 'Q: verify first note for third commit' ' +test_expect_success 'verify first note for third commit' ' setup_notes_repo && ( cd repo &&
@@ -1037,7 +1037,7 @@ test_expect_success 'Q: verify first note for third commit' ' ) ' -test_expect_success 'Q: verify third notes commit' ' +test_expect_success 'verify third notes commit' ' setup_notes_repo && ( cd repo &&
@@ -1052,7 +1052,7 @@ test_expect_success 'Q: verify third notes commit' ' ) ' -test_expect_success 'Q: verify third notes tree' ' +test_expect_success 'verify third notes tree' ' setup_notes_repo && ( cd repo &&
@@ -1064,7 +1064,7 @@ test_expect_success 'Q: verify third notes tree' ' ) ' -test_expect_success 'Q: verify third note for first commit' ' +test_expect_success 'verify third note for first commit' ' setup_notes_repo && ( cd repo &&
@@ -1074,7 +1074,7 @@ test_expect_success 'Q: verify third note for first commit' ' ) ' -test_expect_success 'Q: verify fourth notes commit' ' +test_expect_success 'verify fourth notes commit' ' setup_notes_repo && ( cd repo &&
@@ -1090,7 +1090,7 @@ test_expect_success 'Q: verify fourth notes commit' ' ) ' -test_expect_success 'Q: verify fourth notes tree' ' +test_expect_success 'verify fourth notes tree' ' setup_notes_repo && ( cd repo &&
@@ -1102,7 +1102,7 @@ test_expect_success 'Q: verify fourth notes tree' ' ) ' -test_expect_success 'Q: verify second note for second commit' ' +test_expect_success 'verify second note for second commit' ' setup_notes_repo && ( cd repo &&
@@ -1112,7 +1112,7 @@ test_expect_success 'Q: verify second note for second commit' ' ) ' -test_expect_success 'Q: deny note on empty branch' ' +test_expect_success 'deny note on empty branch' ' test_when_finished "rm -rf repo" && git init repo && (
t/t9304-fast-import-marks.sh +14 -14
@@ -79,7 +79,7 @@ test_expect_success 'relative marks are not affected by subdir' ' test_path_is_file deep-relative/.git/info/fast-import/exported-marks ' -test_expect_success 'R: export-marks feature results in a marks file being created' ' +test_expect_success 'export-marks feature results in a marks file being created' ' test_when_finished "rm -rf repo" && git init repo && (
@@ -99,7 +99,7 @@ test_expect_success 'R: export-marks feature results in a marks file being creat ) ' -test_expect_success 'R: export-marks options can be overridden by commandline options' ' +test_expect_success 'export-marks options can be overridden by commandline options' ' test_when_finished "rm -rf repo" && git init repo && (
@@ -120,7 +120,7 @@ test_expect_success 'R: export-marks options can be overridden by commandline op ) ' -test_expect_success 'R: catch typo in marks file name' ' +test_expect_success 'catch typo in marks file name' ' test_when_finished "rm -rf repo" && git init repo && (
@@ -132,7 +132,7 @@ test_expect_success 'R: catch typo in marks file name' ' ) ' -test_expect_success 'R: import and output marks can be the same file' ' +test_expect_success 'import and output marks can be the same file' ' test_when_finished "rm -rf repo" && git init repo && (
@@ -162,7 +162,7 @@ test_expect_success 'R: import and output marks can be the same file' ' ) ' -test_expect_success 'R: --import-marks=foo --output-marks=foo to create foo fails' ' +test_expect_success '--import-marks=foo --output-marks=foo to create foo fails' ' test_when_finished "rm -rf repo" && git init repo && (
@@ -179,7 +179,7 @@ test_expect_success 'R: --import-marks=foo --output-marks=foo to create foo fail ) ' -test_expect_success 'R: --import-marks-if-exists' ' +test_expect_success '--import-marks-if-exists' ' test_when_finished "rm -rf repo" && git init repo && (
@@ -199,7 +199,7 @@ test_expect_success 'R: --import-marks-if-exists' ' ) ' -test_expect_success 'R: feature import-marks-if-exists' ' +test_expect_success 'feature import-marks-if-exists' ' test_when_finished "rm -rf repo" && git init repo && (
@@ -253,7 +253,7 @@ test_expect_success 'R: feature import-marks-if-exists' ' ) ' -test_expect_success 'R: corrupt lines do not mess marks file' ' +test_expect_success 'corrupt lines do not mess marks file' ' test_when_finished "rm -rf repo" && git init repo && (
@@ -315,7 +315,7 @@ create_marks_file () { EOF } -test_expect_success 'R: import to output marks works without any content' ' +test_expect_success 'import to output marks works without any content' ' test_when_finished "rm -rf repo" && git init repo && (
@@ -332,7 +332,7 @@ test_expect_success 'R: import to output marks works without any content' ' ) ' -test_expect_success 'R: import marks prefers commandline marks file over the stream' ' +test_expect_success 'import marks prefers commandline marks file over the stream' ' test_when_finished "rm -rf repo" && git init repo && (
@@ -349,7 +349,7 @@ test_expect_success 'R: import marks prefers commandline marks file over the str ) ' -test_expect_success 'R: multiple --import-marks= should be honoured' ' +test_expect_success 'multiple --import-marks= should be honoured' ' test_when_finished "rm -rf repo" && git init repo && (
@@ -369,7 +369,7 @@ test_expect_success 'R: multiple --import-marks= should be honoured' ' ) ' -test_expect_success 'R: feature relative-marks should be honoured' ' +test_expect_success 'feature relative-marks should be honoured' ' test_when_finished "rm -rf repo" && git init repo && (
@@ -389,7 +389,7 @@ test_expect_success 'R: feature relative-marks should be honoured' ' ) ' -test_expect_success 'R: feature no-relative-marks should be honoured' ' +test_expect_success 'feature no-relative-marks should be honoured' ' test_when_finished "rm -rf repo" && git init repo && (
@@ -410,7 +410,7 @@ test_expect_success 'R: feature no-relative-marks should be honoured' ' ) ' -test_expect_success 'A: export marks with large values' ' +test_expect_success 'export marks with large values' ' test_when_finished "rm -rf repo" && git init repo && (
t/t9307-fast-import-validation.sh +48 -48
384 lines not on this page · raw message
t/t9308-fast-import-stream.sh +26 -26
208 lines not on this page · raw message
t/t9309-fast-import-checkpoint.sh +5 -5
@@ -91,7 +91,7 @@ setup_checkpoint_repo () { INPUT_END } -test_expect_success PIPE 'V: checkpoint helper does not get stuck with extra output' ' +test_expect_success PIPE 'checkpoint helper does not get stuck with extra output' ' setup_checkpoint_repo && cat >repo/input <<-INPUT_END && progress foo
@@ -103,7 +103,7 @@ test_expect_success PIPE 'V: checkpoint helper does not get stuck with extra out background_import_still_running ' -test_expect_success PIPE 'V: checkpoint updates refs after reset' ' +test_expect_success PIPE 'checkpoint updates refs after reset' ' setup_checkpoint_repo && cat >repo/input <<-\INPUT_END && reset refs/heads/V
@@ -116,7 +116,7 @@ test_expect_success PIPE 'V: checkpoint updates refs after reset' ' background_import_still_running ' -test_expect_success PIPE 'V: checkpoint updates refs and marks after commit' ' +test_expect_success PIPE 'checkpoint updates refs and marks after commit' ' setup_checkpoint_repo && cat >repo/input <<-INPUT_END && commit refs/heads/V
@@ -140,7 +140,7 @@ test_expect_success PIPE 'V: checkpoint updates refs and marks after commit' ' # Re-create the exact same commit, but on a different branch: no new object is # created in the database, but the refs and marks still need to be updated. -test_expect_success PIPE 'V: checkpoint updates refs and marks after commit (no new objects)' ' +test_expect_success PIPE 'checkpoint updates refs and marks after commit (no new objects)' ' setup_checkpoint_repo && git -C repo -c fastimport.unpackLimit=0 fast-import <<-INPUT_END && commit refs/heads/V
@@ -170,7 +170,7 @@ test_expect_success PIPE 'V: checkpoint updates refs and marks after commit (no background_import_still_running ' -test_expect_success PIPE 'V: checkpoint updates tags after tag' ' +test_expect_success PIPE 'checkpoint updates tags after tag' ' setup_checkpoint_repo && cat >repo/input <<-INPUT_END && tag Vtag
t/t9310-fast-import-submodule.sh +6 -6
@@ -72,7 +72,7 @@ setup_gitlinks_repo () { ) } -test_expect_success 'P: superproject & submodule mix' ' +test_expect_success 'superproject & submodule mix' ' setup_gitlinks_repo && ( cd repo &&
@@ -91,7 +91,7 @@ test_expect_success 'P: superproject & submodule mix' ' ) ' -test_expect_success 'P: verbatim SHA gitlinks' ' +test_expect_success 'verbatim SHA gitlinks' ' setup_gitlinks_repo && ( cd repo &&
@@ -134,7 +134,7 @@ test_expect_success 'P: verbatim SHA gitlinks' ' ) ' -test_expect_success 'P: fail on inline gitlink' ' +test_expect_success 'fail on inline gitlink' ' setup_gitlinks_repo && ( cd repo &&
@@ -161,7 +161,7 @@ test_expect_success 'P: fail on inline gitlink' ' ) ' -test_expect_success 'P: fail on blob mark in gitlink' ' +test_expect_success 'fail on blob mark in gitlink' ' setup_gitlinks_repo && ( cd repo &&
@@ -277,7 +277,7 @@ cat >Y-marks <<\Y_INPUT_END :4 ff729f5e62f72c0c3978207d9a80e5f3a65f14d7 Y_INPUT_END -test_expect_success 'Y: rewrite submodules' ' +test_expect_success 'rewrite submodules' ' test_when_finished "rm -rf main1" && test_oid_cache <<-EOF && Ymain sha1:9afed2f9161ddf416c0a1863b8b0725b00070504
@@ -294,7 +294,7 @@ test_expect_success 'Y: rewrite submodules' ' ) ' -test_expect_success 'Y: reference pending tag or commit' ' +test_expect_success 'reference pending tag or commit' ' test_oid_cache <<-EOF && pending_commit sha1:85b46dd918355ff17b4109ec738723d42f235a04 pending_commit sha256:17e650f097a4db6fe069c96935360d3ccc9b35c4018728c5f311a4217c2ced3d
t/t9311-fast-import-refs.sh +7 -7
@@ -13,7 +13,7 @@ setup_two_commit_repo () { test_commit -C repo two } -test_expect_success 'F: non-fast-forward update skips' ' +test_expect_success 'non-fast-forward update skips' ' setup_two_commit_repo && ( cd repo &&
@@ -55,7 +55,7 @@ test_expect_success 'F: non-fast-forward update skips' ' ) ' -test_expect_success 'G: non-fast-forward update forced' ' +test_expect_success 'non-fast-forward update forced' ' setup_two_commit_repo && ( cd repo &&
@@ -83,7 +83,7 @@ test_expect_success 'G: non-fast-forward update forced' ' ) ' -test_expect_success 'J: reset existing branch creates empty commit' ' +test_expect_success 'reset existing branch creates empty commit' ' setup_two_commit_repo && ( cd repo &&
@@ -112,7 +112,7 @@ test_expect_success 'J: reset existing branch creates empty commit' ' ) ' -test_expect_success 'J: tag must fail on empty branch' ' +test_expect_success 'tag must fail on empty branch' ' test_when_finished "rm -rf repo" && git init repo && (
@@ -130,7 +130,7 @@ test_expect_success 'J: tag must fail on empty branch' ' ) ' -test_expect_success 'K: reinit branch with from' ' +test_expect_success 'reinit branch with from' ' setup_two_commit_repo && ( cd repo &&
@@ -159,7 +159,7 @@ test_expect_success 'K: reinit branch with from' ' ) ' -test_expect_success 'T: delete branch' ' +test_expect_success 'delete branch' ' test_when_finished "rm -rf repo" && git init repo && (
@@ -175,7 +175,7 @@ test_expect_success 'T: delete branch' ' ) ' -test_expect_success 'T: empty reset doesnt delete branch' ' +test_expect_success 'empty reset doesnt delete branch' ' test_when_finished "rm -rf repo" && git init repo && (
Signature · 1 line
2.56.GIT
Quoted 9 lines · Karthik Nayak
While reading the git-fast-import(1) code, I stumbled upon t9300. The test file is around 4000 LoC and each test has some dependency on the state setup by previous tests.
This long series unwinds some of these tests and moves them into new/existing tests based on what they exercise. This leaves t9300 in a better state. I think we can do more here, but I decided to stop before this series got even longer. Based on the reception of this series, I will follow up with more cleanups.
Wow, cleaning up this script is long overdue. Thanks for tackling it.
Quoted 6 lines · Junio C Hamano
Quoted 4 lines · Karthik Nayak
While reading the git-fast-import(1) code, I stumbled upon t9300. The test file is around 4000 LoC and each test has some dependency on the state setup by previous tests.
Quoted 7 lines
Quoted 5 lines
This long series unwinds some of these tests and moves them into new/existing tests based on what they exercise. This leaves t9300 in a better state. I think we can do more here, but I decided to stop before this series got even longer. Based on the reception of this series, I will follow up with more cleanups.
Wow, cleaning up this script is long overdue. Thanks for tackling it.
Having said that, there are a few topics in flight that touch this age-old script and they are already in 'next'.
(cc/early-scan-options)c2b4099f84 fast-import: use early_scan_options() for --allow-unsafe-features cc4affc5ee parse-options: add early_scan_options()f7fd8656e9 parse-options: extract lookup_long_opt() from parse_long_opt() 6aa1fb2271 parse-options: add parse_options_takes_argument()
(tj/drop-no-parseopt)1db50e0e62 t0012: catch builtins that keep NO_PARSEOPT after conversion 5d735e50ef git.c: drop NO_PARSEOPT from builtins that use parse-options ee68c316a7 parse-options: answer --git-completion-helper before command runs
So you may want to rebase this clean-up on a synthetic base, starting at 1891de46f7 (Sync with Git 2.56.1, 2026-11-09) and merging these two topics on top.
Thanks.
Quoted 30 lines · Junio C Hamano
Quoted 6 lines · Junio C Hamano
Quoted 4 lines · Karthik Nayak
While reading the git-fast-import(1) code, I stumbled upon t9300. The test file is around 4000 LoC and each test has some dependency on the state setup by previous tests.
Quoted 7 lines
Quoted 5 lines
This long series unwinds some of these tests and moves them into new/existing tests based on what they exercise. This leaves t9300 in a better state. I think we can do more here, but I decided to stop before this series got even longer. Based on the reception of this series, I will follow up with more cleanups.
Wow, cleaning up this script is long overdue. Thanks for tackling it.
Having said that, there are a few topics in flight that touch this age-old script and they are already in 'next'.
(cc/early-scan-options)
c2b4099f84fast-import: useearly_scan_options()for --allow-unsafe-featurescc4affc5eeparse-options: addearly_scan_options()f7fd8656e9parse-options: extractlookup_long_opt()fromparse_long_opt()6aa1fb2271parse-options: addparse_options_takes_argument()(tj/drop-no-parseopt)
1db50e0e62t0012: catch builtins that keepNO_PARSEOPTafter conversion5d735e50efgit.c: dropNO_PARSEOPTfrom builtins that use parse-optionsee68c316a7parse-options: answer --git-completion-helper before command runs
Quoted 5 lines
So you may want to rebase this clean-up on a synthetic base, starting at
1891de46f7(Sync with Git 2.56.1, 2026-11-09) and merging these two topics on top.Thanks.
Ah, that's something I missed checking. I will rebase and check for conflicts. Will give it a day or two, since reviews can still happen on this version.
Thanks,
Karthik