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
v2 cover t9300: group and move tests to other files
In reply to Karthik NayakWhile 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.
---
Changes in v2:
- Rebased on top master: 1891de46f7 (Sync with Git 2.56.1, 2026-11-09)
- Merged in and resolved conflicts from the topics in next:
- cc/early-scan-options
- tj/drop-no-parseopt
- Did some small cleanups
- Link to v1: https://patch.msgid.link/[email protected]
---
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 | 2884 +------------------------------------ t/t9301-fast-import-notes.sh | 400 +++++ t/t9304-fast-import-marks.sh | 393 +++++ t/t9307-fast-import-validation.sh | 1262 ++++++++++++++++ t/t9308-fast-import-stream.sh | 890 ++++++++++++ t/t9309-fast-import-checkpoint.sh | 188 +++ t/t9310-fast-import-submodule.sh | 385 +++++ t/t9311-fast-import-refs.sh | 194 +++ 9 files changed, 3718 insertions(+), 2883 deletions(-)
Range-diff versus v1:
1: 45b5b440f4 = 1: e3f2bfcc69 t9300: move 'fastimport.unpackLimit' to the required test 2: 130034d57d = 2: 649260b54d t9300: make the series B tests self-contained 3: 9fe75bdaf2 = 3: 7b134f184d t9300: make the series T tests self-contained 4: a9c1bd2483 ! 4: b401701e1e t9300: make the series S tests self-contained
@@ Commit message
## t/t9300-fast-import.sh ##
-@@ t/t9300-fast-import.sh: test_expect_success 'R: blob appears only once' '
+@@ t/t9300-fast-import.sh: test_expect_success 'R: --git-completion-helper-all does not read from stdin' '
#
# invalid dataref ..
#
5: a8b7bf3aa4 = 5: 18ffcfcfd9 t9300: make the series V tests self-contained
6: 73f94d5790 ! 6: b81ec42557 t9300: make the series Q tests self-contained
@@ Commit message
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.
+ each test can invoke it.
- Also stop using the 'verify_packs()' function, to make it easier to move
- these tests to another file.
+ Drop 'Q: verify pack', as other tests already verify the packs written
+ by fast-import.
Signed-off-by: Karthik Nayak <[email protected]>
@@ t/t9300-fast-import.sh: test_expect_success 'Q: commit notes' '
- git fast-import <input &&
- git log --raw notes-test
-'
-+ git -C repo -c fastimport.unpackLimit=0 fast-import <repo/input &&
+-
+-test_expect_success 'Q: verify pack' '
+- verify_packs
+-'
++ git -C repo 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^) &&
7: 65951bf97e = 7: 4265ae48a9 t9300: make the series P tests self-contained
8: 8c277ecdfe = 8: 19b4d8b559 t9300: make the series O tests self-contained
9: 2e1f122a03 ! 9: 3af6c83f5c t9300: make the big blob tests self-contained @@ t/t9300-fast-import.sh: test_expect_success 'R: corrupt lines do not mess marks
- test 1 = $n
-'
-
- ###
- ### series S (mark and path parsing)
- ###
+ test_expect_success 'R: --git-completion-helper does not read from stdin' '
+ find .git/objects/pack -name "tmp_pack_*" >before &&
+ echo garbage | git fast-import --git-completion-helper >out &&
10: 178e01d022 ! 10: 6104474191 t9300: make the ref update tests self-contained
@@ Commit message
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
@@ t/t9300-fast-import.sh: test_expect_success 'F: verify other commit' '
'
###
-@@ t/t9300-fast-import.sh: test_expect_success 'I: verify edge list' ' +@@ t/t9300-fast-import.sh: test_expect_success 'I: export-pack-edges via stdin' '
###
test_expect_success 'J: reset existing branch creates empty commit' '
11: d94431d13c = 11: 6c1b12057c t9300: make the date format tests self-contained
12: 44d3602cbc ! 12: 5d1e8cada1 t9300: make the pack edges test self-contained
@@ Commit message
Similar 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.
+ 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
@@ t/t9300-fast-import.sh
@@ t/t9300-fast-import.sh: test_expect_success 'H: verify file' '
###
+ test_expect_success 'I: export-pack-edges option forbidden by default' '
+- echo "option git export-pack-edges=edges.list" >input &&
+- test_must_fail git fast-import <input 2>err &&
+- test_grep "option ${SQ}export-pack-edges${SQ} forbidden in input without --allow-unsafe-features" err
++ test_when_finished "rm -rf repo" &&
++ git init repo &&
++ (
++ cd repo &&
++ echo "option git export-pack-edges=edges.list" >input &&
++ test_must_fail git fast-import <input 2>err &&
++ test_grep "option ${SQ}export-pack-edges${SQ} forbidden in input without --allow-unsafe-features" err
++ )
+ '
+
test_expect_success 'I: export-pack-edges' '
+- test_when_finished "rm edges.list" &&
- cat >input <<-INPUT_END &&
- commit refs/heads/export-boundary
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
@@ t/t9300-fast-import.sh: test_expect_success 'H: verify file' '
+ COMMIT
- INPUT_END
-- git fast-import --export-pack-edges=edges.list <input
--'
-+ from refs/heads/main
-
--test_expect_success 'I: verify edge list' '
+- git fast-import --export-pack-edges=edges.list <input &&
- 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
++ from refs/heads/main
++
+ INPUT_END
+ git -c fastimport.unpackLimit=0 fast-import \
+ --export-pack-edges=edges.list <input &&
@@ t/t9300-fast-import.sh: test_expect_success 'H: verify file' '
+ )
'
+ test_expect_success 'I: export-pack-edges via stdin' '
+- test_when_finished "rm edges.list" &&
+- cat >input <<-INPUT_END &&
+- option git export-pack-edges=edges.list
+- commit refs/heads/export-boundary-2
+- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+- data <<COMMIT
+- one more similar commit
+- 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 &&
++ option git export-pack-edges=edges.list
++ commit refs/heads/export-boundary
++ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
++ data <<COMMIT
++ one more similar commit
++ COMMIT
+
+- INPUT_END
+- git fast-import --allow-unsafe-features <input &&
+- cat >expect <<-EOF &&
+- .git/objects/pack/pack-.pack: $(git rev-parse --verify export-boundary-2)
+- EOF
+- sed -e s/pack-.*pack/pack-.pack/ edges.list >actual &&
+- test_cmp expect actual
++ from refs/heads/main
++
++ INPUT_END
++
++ git -c fastimport.unpackLimit=0 fast-import \
++ --allow-unsafe-features <input &&
++ 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
++ )
+ '
+
###13: 54f456a8b3 ! 13: 80552f9997 t9300: make the marks tests self-contained
@@ t/t9300-fast-import.sh: test_expect_success 'R: export-marks feature forbidden b
+ )
'
+ test_expect_success 'R: --allow-unsafe-features found after a value' '
+@@ t/t9300-fast-import.sh: test_expect_success 'R: --allow-unsafe-features after a non-option' '
+ '
+
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" |
14: 19b51b871b < -: ---------- t9300: make the series Y tests self-contained -: ---------- > 14: 7d3e0b60f1 t9300: make the series Y tests self-contained 15: dd62943ca0 ! 15: 935ae34fbf t9300: make the cat-blob tests self-contained
@@ Metadata
## Commit message ##
t9300: make the cat-blob tests self-contained
- The '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.
+ Similar to the previous commits, modify the cat-blog tests to make
+ them independent of state from previous tests.
16: 25609c8979 ! 16: 405057430f t9300: make the feature and option tests self-contained
@@ t/t9300-fast-import.sh: test_expect_success 'Q: deny note on empty branch' '
'
test_expect_success 'R: export-marks feature results in a marks file being created' '
+@@ t/t9300-fast-import.sh: test_expect_success 'R: export-marks options can be overridden by commandline op
+ '
+
+ test_expect_success 'R: --allow-unsafe-features found after a value' '
+- echo "feature import-marks-if-exists=nonexistent.marks" >input &&
+- git fast-import --allow-unsafe-features <input &&
+- git fast-import --depth=5 --allow-unsafe-features <input &&
+- git fast-import --depth 5 --allow-unsafe-features <input &&
+- git fast-import --date-format raw --allow-unsafe-features <input
++ test_when_finished "rm -rf repo" &&
++ git init repo &&
++ (
++ cd repo &&
++
++ echo "feature import-marks-if-exists=nonexistent.marks" >input &&
++ git fast-import --allow-unsafe-features <input &&
++ git fast-import --depth=5 --allow-unsafe-features <input &&
++ git fast-import --depth 5 --allow-unsafe-features <input &&
++ git fast-import --date-format raw --allow-unsafe-features <input
++ )
+ '
+
+ test_expect_success 'R: --allow-unsafe-features can be abbreviated' '
+- echo "feature import-marks-if-exists=nonexistent.marks" >input &&
+- GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS=false \
+- git fast-import --allow-unsafe <input
++ test_when_finished "rm -rf repo" &&
++ git init repo &&
++ (
++ cd repo &&
++
++ echo "feature import-marks-if-exists=nonexistent.marks" >input &&
++ GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS=false \
++ git fast-import --allow-unsafe <input
++ )
+ '
+
+ test_expect_success 'R: disallowed abbreviation of --allow-unsafe-features' '
+- echo "feature import-marks-if-exists=nonexistent.marks" >input &&
+- test_must_fail env GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS=true \
+- git fast-import --allow-unsafe <input 2>err &&
+- test_grep "forbidden in input without --allow-unsafe-features" err
++ test_when_finished "rm -rf repo" &&
++ git init repo &&
++ (
++ cd repo &&
++
++ echo "feature import-marks-if-exists=nonexistent.marks" >input &&
++ test_must_fail env GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS=true \
++ git fast-import --allow-unsafe <input 2>err &&
++ test_grep "forbidden in input without --allow-unsafe-features" err
++ )
+ '
+
+ test_expect_success 'R: --allow-unsafe-features as the value of an abbreviation' '
+- echo "feature import-marks-if-exists=nonexistent.marks" >input &&
+- test_must_fail env GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS=false \
+- git fast-import --quiet --export-pack \
+- --allow-unsafe-features <input 2>err &&
+- test_grep "forbidden in input without --allow-unsafe-features" err
++ test_when_finished "rm -rf repo" &&
++ git init repo &&
++ (
++ cd repo &&
++
++ echo "feature import-marks-if-exists=nonexistent.marks" >input &&
++ test_must_fail env GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS=false \
++ git fast-import --quiet --export-pack \
++ --allow-unsafe-features <input 2>err &&
++ test_grep "forbidden in input without --allow-unsafe-features" err
++ )
+ '
+
+ test_expect_success 'R: --allow-unsafe-features after a non-option' '
+- echo "feature import-marks-if-exists=nonexistent.marks" >input &&
+- test_must_fail git fast-import --depth 5 extra \
+- --allow-unsafe-features <input 2>err &&
+- test_grep "forbidden in input without --allow-unsafe-features" err
++ test_when_finished "rm -rf repo" &&
++ git init repo &&
++ (
++ cd repo &&
++
++ echo "feature import-marks-if-exists=nonexistent.marks" >input &&
++ test_must_fail git fast-import --depth 5 extra \
++ --allow-unsafe-features <input 2>err &&
++ test_grep "forbidden in input without --allow-unsafe-features" err
++ )
+ '
+
+ test_expect_success 'R: catch typo in marks file name' '
@@ t/t9300-fast-import.sh: test_expect_success 'R: feature no-relative-marks should be honoured' '17: 7573e1381d ! 17: bafacc9dd4 t9300: make the stream tests self-contained
@@ t/t9300-fast-import.sh: test_expect_success PIPE 'R: print staged blob within co
'
test_expect_success 'R: die on unknown option' '
+@@ t/t9300-fast-import.sh: test_expect_success 'R: blob bigger than threshold' '
+ '
+
+ test_expect_success 'R: --git-completion-helper does not read from stdin' '
+- find .git/objects/pack -name "tmp_pack_*" >before &&
+- echo garbage | git fast-import --git-completion-helper >out &&
+- test_grep -e "--date-format=" out &&
+- find .git/objects/pack -name "tmp_pack_*" >after &&
+- test_cmp before after
++ test_when_finished "rm -rf repo" &&
++ git init repo &&
++ (
++ cd repo &&
++
++ find .git/objects/pack -name "tmp_pack_*" >before &&
++ echo garbage | git fast-import --git-completion-helper >out &&
++ test_grep -e "--date-format=" out &&
++ find .git/objects/pack -name "tmp_pack_*" >after &&
++ test_cmp before after
++ )
+ '
+
+ test_expect_success 'R: --git-completion-helper-all does not read from stdin' '
+- find .git/objects/pack -name "tmp_pack_*" >before &&
+- echo garbage | git fast-import --git-completion-helper-all >all &&
+- test_grep -e "--allow-unsafe-features" all &&
+- find .git/objects/pack -name "tmp_pack_*" >after &&
+- test_cmp before after
++ test_when_finished "rm -rf repo" &&
++ git init repo &&
++ (
++ cd repo &&
++
++ find .git/objects/pack -name "tmp_pack_*" >before &&
++ echo garbage | git fast-import --git-completion-helper-all >all &&
++ test_grep -e "--allow-unsafe-features" all &&
++ find .git/objects/pack -name "tmp_pack_*" >after &&
++ test_cmp before after
++ )
+ '
+
+ ###
18: fb94ca9bc4 = 18: 100ad72f13 t9300: make the get-mark and encoding tests self-contained
19: 29df1daba9 ! 19: f3c7d85bd9 t9300: move self-contained tests into dedicated files
@@ t/t9300-fast-import.sh: test_expect_success 'H: verify file' '
-### series I
-###
-
+-test_expect_success 'I: export-pack-edges option forbidden by default' '
+- test_when_finished "rm -rf repo" &&
+- git init repo &&
+- (
+- cd repo &&
+- echo "option git export-pack-edges=edges.list" >input &&
+- test_must_fail git fast-import <input 2>err &&
+- test_grep "option ${SQ}export-pack-edges${SQ} forbidden in input without --allow-unsafe-features" err
+- )
+-'
+-
-test_expect_success 'I: export-pack-edges' '
- test_when_finished "rm -rf repo" &&
- git init -b main repo &&
@@ t/t9300-fast-import.sh: test_expect_success 'H: verify file' '
- )
-'
-
+-test_expect_success 'I: export-pack-edges via stdin' '
+- test_when_finished "rm -rf repo" &&
+- git init -b main repo &&
+- (
+- cd repo &&
+- test_commit one &&
+-
+- cat >input <<-INPUT_END &&
+- option git export-pack-edges=edges.list
+- commit refs/heads/export-boundary
+- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+- data <<COMMIT
+- one more similar commit
+- COMMIT
+-
+- from refs/heads/main
+-
+- INPUT_END
+-
+- git -c fastimport.unpackLimit=0 fast-import \
+- --allow-unsafe-features <input &&
+- 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
+- )
+-'
+-
-###
-### series J
-###
@@ t/t9300-fast-import.sh: do
-###
-### series O
-###
--
+
-setup_import_repo () {
- test_when_finished "rm -rf repo" &&
- git init repo &&
@@ t/t9300-fast-import.sh: do
-
- INPUT_END
-
-- git -C repo -c fastimport.unpackLimit=0 fast-import <repo/input &&
+- git -C repo 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' '
-- 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' '
- setup_notes_repo &&
- (
@@ t/t9300-fast-import.sh: do
- )
-'
-
+-test_expect_success 'R: --allow-unsafe-features found after a value' '
+- test_when_finished "rm -rf repo" &&
+- git init repo &&
+- (
+- cd repo &&
+-
+- echo "feature import-marks-if-exists=nonexistent.marks" >input &&
+- git fast-import --allow-unsafe-features <input &&
+- git fast-import --depth=5 --allow-unsafe-features <input &&
+- git fast-import --depth 5 --allow-unsafe-features <input &&
+- git fast-import --date-format raw --allow-unsafe-features <input
+- )
+-'
+-
+-test_expect_success 'R: --allow-unsafe-features can be abbreviated' '
+- test_when_finished "rm -rf repo" &&
+- git init repo &&
+- (
+- cd repo &&
+-
+- echo "feature import-marks-if-exists=nonexistent.marks" >input &&
+- GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS=false \
+- git fast-import --allow-unsafe <input
+- )
+-'
+-
+-test_expect_success 'R: disallowed abbreviation of --allow-unsafe-features' '
+- test_when_finished "rm -rf repo" &&
+- git init repo &&
+- (
+- cd repo &&
+-
+- echo "feature import-marks-if-exists=nonexistent.marks" >input &&
+- test_must_fail env GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS=true \
+- git fast-import --allow-unsafe <input 2>err &&
+- test_grep "forbidden in input without --allow-unsafe-features" err
+- )
+-'
+-
+-test_expect_success 'R: --allow-unsafe-features as the value of an abbreviation' '
+- test_when_finished "rm -rf repo" &&
+- git init repo &&
+- (
+- cd repo &&
+-
+- echo "feature import-marks-if-exists=nonexistent.marks" >input &&
+- test_must_fail env GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS=false \
+- git fast-import --quiet --export-pack \
+- --allow-unsafe-features <input 2>err &&
+- test_grep "forbidden in input without --allow-unsafe-features" err
+- )
+-'
+-
+-test_expect_success 'R: --allow-unsafe-features after a non-option' '
+- test_when_finished "rm -rf repo" &&
+- git init repo &&
+- (
+- cd repo &&
+-
+- echo "feature import-marks-if-exists=nonexistent.marks" >input &&
+- test_must_fail git fast-import --depth 5 extra \
+- --allow-unsafe-features <input 2>err &&
+- test_grep "forbidden in input without --allow-unsafe-features" err
+- )
+-'
+-
-test_expect_success 'R: catch typo in marks file name' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
@@ t/t9300-fast-import.sh: do
- )
-'
-
+-test_expect_success 'R: --git-completion-helper does not read from stdin' '
+- test_when_finished "rm -rf repo" &&
+- git init repo &&
+- (
+- cd repo &&
+-
+- find .git/objects/pack -name "tmp_pack_*" >before &&
+- echo garbage | git fast-import --git-completion-helper >out &&
+- test_grep -e "--date-format=" out &&
+- find .git/objects/pack -name "tmp_pack_*" >after &&
+- test_cmp before after
+- )
+-'
+-
+-test_expect_success 'R: --git-completion-helper-all does not read from stdin' '
+- test_when_finished "rm -rf repo" &&
+- git init repo &&
+- (
+- cd repo &&
+-
+- find .git/objects/pack -name "tmp_pack_*" >before &&
+- echo garbage | git fast-import --git-completion-helper-all >all &&
+- test_grep -e "--allow-unsafe-features" all &&
+- find .git/objects/pack -name "tmp_pack_*" >after &&
+- test_cmp before after
+- )
+-'
+-
-###
-### series S (mark and path parsing)
-###
@@ t/t9300-fast-import.sh: do
- git rev-parse --verify refs/heads/not-to-delete
- )
-'
--
+
###
### series U (filedelete)
- ###
@@ t/t9300-fast-import.sh: do
'
done
@@ t/t9300-fast-import.sh: do
-:4 ff729f5e62f72c0c3978207d9a80e5f3a65f14d7
-Y_INPUT_END
-
+-test_expect_success 'Y: rewrite-submodules-to feature forbidden by default' '
+- test_when_finished "rm -rf repo" &&
+- git init repo &&
+- (
+- cd repo &&
+- echo "feature rewrite-submodules-to=sub:sub2-marks" >input &&
+- test_must_fail git fast-import <input 2>err &&
+- test_grep "feature ${SQ}rewrite-submodules-to${SQ} forbidden in input without --allow-unsafe-features" err
+- )
+-'
+-
+-test_expect_success 'Y: rewrite-submodules-from feature forbidden by default' '
+- test_when_finished "rm -rf repo" &&
+- git init repo &&
+- (
+- cd repo &&
+- echo "feature rewrite-submodules-from=sub:../Y-marks" >input &&
+- test_must_fail git fast-import <input 2>err &&
+- test_grep "feature ${SQ}rewrite-submodules-from${SQ} forbidden in input without --allow-unsafe-features" err
+- )
+-'
+-
-test_expect_success 'Y: rewrite submodules' '
- test_when_finished "rm -rf main1" &&
- test_oid_cache <<-EOF &&
- Ymain sha1:9afed2f9161ddf416c0a1863b8b0725b00070504
- Ymain sha256:c0a1010da1df187b2e287654793df01b464bd6f8e3f17fc1481a7dadf84caee3
- EOF
+-
- git init main1 &&
- (
- cd main1 &&
@@ t/t9300-fast-import.sh: do
- EOF
- )
-'
+-
+-test_expect_success 'Y: rewrite submodules via stdin' '
+- test_when_finished "rm -rf main1" &&
+- test_oid_cache <<-EOF &&
+- Ymain sha1:9afed2f9161ddf416c0a1863b8b0725b00070504
+- Ymain sha256:c0a1010da1df187b2e287654793df01b464bd6f8e3f17fc1481a7dadf84caee3
+- EOF
+-
+- git init main1 &&
+- (
+- cd main1 &&
+- git init sub2 &&
+- git -C sub2 fast-import --export-marks=../sub2-marks <../Y-sub-input &&
+- {
+- echo "feature rewrite-submodules-to=sub:sub2-marks" &&
+- echo "feature rewrite-submodules-from=sub:../Y-marks" &&
+- cat ../Y-main-input
+- } | git fast-import --allow-unsafe-features &&
+- test "$(git rev-parse main)" = "$(test_oid Ymain)"
+- )
+-'
-
test_done
@@ t/t9301-fast-import-notes.sh: test_expect_success "add notes to $num_commits com
+
+ INPUT_END
+
-+ git -C repo -c fastimport.unpackLimit=0 fast-import <repo/input &&
++ git -C repo 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' '
-+ 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' '
+ setup_notes_repo &&
+ (
@@ t/t9307-fast-import-validation.sh (new)
+ )
+'
+
++###
++### series S (mark and path parsing)
++###
+#
+# Make sure missing spaces and EOLs after mark references
+# cause errors.
@@ t/t9307-fast-import-validation.sh (new)
+ )
+'
+
++test_expect_success 'R: --allow-unsafe-features found after a value' '
++ test_when_finished "rm -rf repo" &&
++ git init repo &&
++ (
++ cd repo &&
++
++ echo "feature import-marks-if-exists=nonexistent.marks" >input &&
++ git fast-import --allow-unsafe-features <input &&
++ git fast-import --depth=5 --allow-unsafe-features <input &&
++ git fast-import --depth 5 --allow-unsafe-features <input &&
++ git fast-import --date-format raw --allow-unsafe-features <input
++ )
++'
++
++test_expect_success 'R: --allow-unsafe-features can be abbreviated' '
++ test_when_finished "rm -rf repo" &&
++ git init repo &&
++ (
++ cd repo &&
++
++ echo "feature import-marks-if-exists=nonexistent.marks" >input &&
++ GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS=false \
++ git fast-import --allow-unsafe <input
++ )
++'
++
++test_expect_success 'R: disallowed abbreviation of --allow-unsafe-features' '
++ test_when_finished "rm -rf repo" &&
++ git init repo &&
++ (
++ cd repo &&
++
++ echo "feature import-marks-if-exists=nonexistent.marks" >input &&
++ test_must_fail env GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS=true \
++ git fast-import --allow-unsafe <input 2>err &&
++ test_grep "forbidden in input without --allow-unsafe-features" err
++ )
++'
++
++test_expect_success 'R: --allow-unsafe-features as the value of an abbreviation' '
++ test_when_finished "rm -rf repo" &&
++ git init repo &&
++ (
++ cd repo &&
++
++ echo "feature import-marks-if-exists=nonexistent.marks" >input &&
++ test_must_fail env GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS=false \
++ git fast-import --quiet --export-pack \
++ --allow-unsafe-features <input 2>err &&
++ test_grep "forbidden in input without --allow-unsafe-features" err
++ )
++'
++
++test_expect_success 'R: --allow-unsafe-features after a non-option' '
++ test_when_finished "rm -rf repo" &&
++ git init repo &&
++ (
++ cd repo &&
++
++ echo "feature import-marks-if-exists=nonexistent.marks" >input &&
++ test_must_fail git fast-import --depth 5 extra \
++ --allow-unsafe-features <input 2>err &&
++ test_grep "forbidden in input without --allow-unsafe-features" err
++ )
++'
++
+test_done
## t/t9308-fast-import-stream.sh (new) ##
@@ t/t9308-fast-import-stream.sh (new)
+ )
+'
+
++test_expect_success 'I: export-pack-edges option forbidden by default' '
++ test_when_finished "rm -rf repo" &&
++ git init repo &&
++ (
++ cd repo &&
++ echo "option git export-pack-edges=edges.list" >input &&
++ test_must_fail git fast-import <input 2>err &&
++ test_grep "option ${SQ}export-pack-edges${SQ} forbidden in input without --allow-unsafe-features" err
++ )
++'
++
++test_expect_success 'I: export-pack-edges via stdin' '
++ test_when_finished "rm -rf repo" &&
++ git init -b main repo &&
++ (
++ cd repo &&
++ test_commit one &&
++
++ cat >input <<-INPUT_END &&
++ option git export-pack-edges=edges.list
++ commit refs/heads/export-boundary
++ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
++ data <<COMMIT
++ one more similar commit
++ COMMIT
++
++ from refs/heads/main
++
++ INPUT_END
++
++ git -c fastimport.unpackLimit=0 fast-import \
++ --allow-unsafe-features <input &&
++ 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
++ )
++'
++
++test_expect_success 'R: --git-completion-helper does not read from stdin' '
++ test_when_finished "rm -rf repo" &&
++ git init repo &&
++ (
++ cd repo &&
++
++ find .git/objects/pack -name "tmp_pack_*" >before &&
++ echo garbage | git fast-import --git-completion-helper >out &&
++ test_grep -e "--date-format=" out &&
++ find .git/objects/pack -name "tmp_pack_*" >after &&
++ test_cmp before after
++ )
++'
++
++test_expect_success 'R: --git-completion-helper-all does not read from stdin' '
++ test_when_finished "rm -rf repo" &&
++ git init repo &&
++ (
++ cd repo &&
++
++ find .git/objects/pack -name "tmp_pack_*" >before &&
++ echo garbage | git fast-import --git-completion-helper-all >all &&
++ test_grep -e "--allow-unsafe-features" all &&
++ find .git/objects/pack -name "tmp_pack_*" >after &&
++ test_cmp before after
++ )
++'
++
+test_done
## t/t9309-fast-import-checkpoint.sh (new) ##
@@ t/t9310-fast-import-submodule.sh (new)
+ Ymain sha1:9afed2f9161ddf416c0a1863b8b0725b00070504
+ Ymain sha256:c0a1010da1df187b2e287654793df01b464bd6f8e3f17fc1481a7dadf84caee3
+ EOF
++
+ git init main1 &&
+ (
+ cd main1 &&
@@ t/t9310-fast-import-submodule.sh (new)
+ )
+'
+
++test_expect_success 'Y: rewrite-submodules-to feature forbidden by default' '
++ test_when_finished "rm -rf repo" &&
++ git init repo &&
++ (
++ cd repo &&
++ echo "feature rewrite-submodules-to=sub:sub2-marks" >input &&
++ test_must_fail git fast-import <input 2>err &&
++ test_grep "feature ${SQ}rewrite-submodules-to${SQ} forbidden in input without --allow-unsafe-features" err
++ )
++'
++
++test_expect_success 'Y: rewrite-submodules-from feature forbidden by default' '
++ test_when_finished "rm -rf repo" &&
++ git init repo &&
++ (
++ cd repo &&
++ echo "feature rewrite-submodules-from=sub:../Y-marks" >input &&
++ test_must_fail git fast-import <input 2>err &&
++ test_grep "feature ${SQ}rewrite-submodules-from${SQ} forbidden in input without --allow-unsafe-features" err
++ )
++'
++
++test_expect_success 'Y: rewrite submodules via stdin' '
++ test_when_finished "rm -rf main1" &&
++ test_oid_cache <<-EOF &&
++ Ymain sha1:9afed2f9161ddf416c0a1863b8b0725b00070504
++ Ymain sha256:c0a1010da1df187b2e287654793df01b464bd6f8e3f17fc1481a7dadf84caee3
++ EOF
++
++ git init main1 &&
++ (
++ cd main1 &&
++ git init sub2 &&
++ git -C sub2 fast-import --export-marks=../sub2-marks <../Y-sub-input &&
++ {
++ echo "feature rewrite-submodules-to=sub:sub2-marks" &&
++ echo "feature rewrite-submodules-from=sub:../Y-marks" &&
++ cat ../Y-main-input
++ } | git fast-import --allow-unsafe-features &&
++ test "$(git rev-parse main)" = "$(test_oid Ymain)"
++ )
++'
++
+test_done
## t/t9311-fast-import-refs.sh (new) ##20: 80524815fd ! 20: 26f81a22b7 t93xx: drop the series letter from the moved test names
@@ t/t9301-fast-import-notes.sh: 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 &&
-@@ t/t9301-fast-import-notes.sh: test_expect_success 'Q: verify pack' '
- )
- '
-
-test_expect_success 'Q: verify first commit' '
+test_expect_success 'verify first commit' '
setup_notes_repo &&
@@ t/t9307-fast-import-validation.sh: test_expect_success 'E: rfc2822 date, --date-
test_when_finished "rm -rf repo" &&
git init repo &&
(
+@@ t/t9307-fast-import-validation.sh: test_expect_success 'E: rfc2822 date, --date-format=rfc2822' '
+ )
+ '
+
+-test_expect_success 'R: --allow-unsafe-features found after a value' '
++test_expect_success '--allow-unsafe-features found after a value' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+@@ t/t9307-fast-import-validation.sh: test_expect_success 'R: --allow-unsafe-features found after a value' '
+ )
+ '
+
+-test_expect_success 'R: --allow-unsafe-features can be abbreviated' '
++test_expect_success '--allow-unsafe-features can be abbreviated' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+@@ t/t9307-fast-import-validation.sh: test_expect_success 'R: --allow-unsafe-features can be abbreviated' '
+ )
+ '
+
+-test_expect_success 'R: disallowed abbreviation of --allow-unsafe-features' ' ++test_expect_success 'disallowed abbreviation of --allow-unsafe-features' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+@@ t/t9307-fast-import-validation.sh: test_expect_success 'R: disallowed abbreviation of --allow-unsafe-features' '
+ )
+ '
+
+-test_expect_success 'R: --allow-unsafe-features as the value of an abbreviation' ' ++test_expect_success '--allow-unsafe-features as the value of an abbreviation' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+@@ t/t9307-fast-import-validation.sh: test_expect_success 'R: --allow-unsafe-features as the value of an abbreviation'
+ )
+ '
+
+-test_expect_success 'R: --allow-unsafe-features after a non-option' '
++test_expect_success '--allow-unsafe-features after a non-option' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
## t/t9308-fast-import-stream.sh ##
@@ t/t9308-fast-import-stream.sh: test_expect_success 'truncated stream complains' '
@@ t/t9308-fast-import-stream.sh: do
test_when_finished "rm -rf repo" &&
git init -b main repo &&
(
+@@ t/t9308-fast-import-stream.sh: test_expect_success 'I: export-pack-edges' '
+ )
+ '
+
+-test_expect_success 'I: export-pack-edges option forbidden by default' ' ++test_expect_success 'export-pack-edges option forbidden by default' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+@@ t/t9308-fast-import-stream.sh: test_expect_success 'I: export-pack-edges option forbidden by default' '
+ )
+ '
+
+-test_expect_success 'I: export-pack-edges via stdin' '
++test_expect_success 'export-pack-edges via stdin' '
+ test_when_finished "rm -rf repo" &&
+ git init -b main repo &&
+ (
+@@ t/t9308-fast-import-stream.sh: test_expect_success 'I: export-pack-edges via stdin' '
+ )
+ '
+
+-test_expect_success 'R: --git-completion-helper does not read from stdin' ' ++test_expect_success '--git-completion-helper does not read from stdin' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+@@ t/t9308-fast-import-stream.sh: test_expect_success 'R: --git-completion-helper does not read from stdin' '
+ )
+ '
+
+-test_expect_success 'R: --git-completion-helper-all does not read from stdin' ' ++test_expect_success '--git-completion-helper-all does not read from stdin' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
## t/t9309-fast-import-checkpoint.sh ##
@@ t/t9309-fast-import-checkpoint.sh: setup_checkpoint_repo () {
@@ t/t9310-fast-import-submodule.sh: test_expect_success 'Y: rewrite submodules' '
test_oid_cache <<-EOF &&
pending_commit sha1:85b46dd918355ff17b4109ec738723d42f235a04
pending_commit sha256:17e650f097a4db6fe069c96935360d3ccc9b35c4018728c5f311a4217c2ced3d
+@@ t/t9310-fast-import-submodule.sh: test_expect_success 'Y: reference pending tag or commit' '
+ )
+ '
+
+-test_expect_success 'Y: rewrite-submodules-to feature forbidden by default' ' ++test_expect_success 'rewrite-submodules-to feature forbidden by default' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+@@ t/t9310-fast-import-submodule.sh: test_expect_success 'Y: rewrite-submodules-to feature forbidden by default' '
+ )
+ '
+
+-test_expect_success 'Y: rewrite-submodules-from feature forbidden by default' ' ++test_expect_success 'rewrite-submodules-from feature forbidden by default' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+@@ t/t9310-fast-import-submodule.sh: test_expect_success 'Y: rewrite-submodules-from feature forbidden by default' '
+ )
+ '
+
+-test_expect_success 'Y: rewrite submodules via stdin' '
++test_expect_success 'rewrite submodules via stdin' '
+ test_when_finished "rm -rf main1" &&
+ test_oid_cache <<-EOF &&
+ Ymain sha1:9afed2f9161ddf416c0a1863b8b0725b00070504
## t/t9311-fast-import-refs.sh ##
@@ t/t9311-fast-import-refs.sh: setup_two_commit_repo () {
---
base-commit: faeb455a72c105b44c92ebedae5e771bad5bc853
change-id: 20261102-kn-fast-import-tests-1-03de57101c3b
Thanks
- Karthik
PATCH v2 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
Re: [PATCH v2 01/20] t9300: move 'fastimport.unpackLimit' to the required test
Quoted 11 lines · Karthik Nayak
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'.
This makes me wonder if there is another patch later in this series to turn the 'git config fastimport.unpackLimit' into one that uses test_config instead to make the tests more self contained. Or may be it is planned in the follow-up the cover letter mentions.
I'll see about it. In any case, I think it may be worth a noting in the commit message your thoughts about a change that turns the 'git config' into a test_config one.
Quoted 19 lines
Signed-off-by Karthik Nayak <[email protected]>--- t/t9300-fast-import.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)t/t9300-fast-import.sh +0
-1@@ -38,7 +38,6 @@ echo "$@"' ### test_expect_success 'empty stream succeeds' ' - git config fastimport.unpackLimit 0 && git fast-import </dev/null '
t/t9300-fast-import.sh test_expect_success 'truncated stream complains' ' · line 52
Quoted 7 lines
t/t9300-fast-import.sh +1
-0@@ -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
Change itself looks good to me.
Signature · 1 line
Sivaraam
Re: [PATCH v2 01/20] t9300: move 'fastimport.unpackLimit' to the required test
Quoted 13 lines · Kaartic Sivaraam
Quoted 11 lines · Karthik Nayak
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'.
Quoted 9 lines
This makes me wonder if there is another patch later in this series to turn the 'git config fastimport.unpackLimit' into one that uses
test_configinstead to make the tests more self contained. Or may be it is planned in the follow-up the cover letter mentions.I'll see about it. In any case, I think it may be worth a noting in the commit message your thoughts about a change that turns the 'git config' into a
test_configone.
The commit already states why it doesn't use 'test_config', Since we don't tackle that in this series. I would leave it and not make too many promises ;)
[snip]
PATCH v2 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
Re: [PATCH v2 02/20] t9300: make the series B tests self-contained
Quoted 36 lines · Karthik Nayak
The '
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.
Signed-off-by Karthik Nayak <[email protected]>--- t/t9300-fast-import.sh | 472 ++++++++++++++++++++++++++++--------------------- 1 file changed, 275 insertions(+), 197 deletions(-)t/t9300-fast-import.sh +0
-3@@ -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
t/t9300-fast-import.sh test_expect_success 'A: export marks with large values' ' · line 365
Quoted 10 lines
t/t9300-fast-import.sh +5
-5- 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 &&
I suppose we need this test_commit after making wrapping this in a subshell since we can't lean on the commit created by the previous test. This is just the commit message mentions it. Makes sense.
Quoted 7 lines
t/t9300-fast-import.sh +4
-2- 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
t/t9300-fast-import.sh test_expect_success 'A: export marks with large values' ' · line 375
Quoted 10 lines
t/t9300-fast-import.sh +6
-2+ 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_*" &&
I suppose we're also losing this because the 'repo' itself would cease to exist after this change.
Quoted 8 lines
t/t9300-fast-import.sh +4
-1- 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 &&
t/t9300-fast-import.sh test_expect_success 'A: export marks with large values' ' · line 390
Quoted 10 lines
t/t9300-fast-import.sh +5
-5- 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 &&
I think this additional test_commit is deserved, too.
Quoted 17 lines
t/t9300-fast-import.sh +4
-11test_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
t/t9300-fast-import.sh test_expect_success 'A: export marks with large values' ' · line 462
Quoted 10 lines
t/t9300-fast-import.sh +10
-0+ 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 &&
We're losing the '-C invalid-timezone' here since we are already in a repo created specifically for this test. Looks good.
Quoted 37 lines
t/t9300-fast-import.sh +15
-15+ test_grep "1234567890 [+]051800" out + ) ' 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
t/t9300-fast-import.sh test_expect_success 'A: export marks with large values' ' · line 709
Quoted 10 lines
t/t9300-fast-import.sh +7
-0+ Commit Message + COMMIT + M 120000 :1 .gitmodules + INPUT_END + + test_must_fail git fast-import <input + ) ' ###
An --ignore-all-space diff helped me grok that most of this change is just the existing test getting their own repository and the test code indented to put them within a subshell.
I just wonder how much additional time or work this has resulted in 16 additional repos being created and torn down.
Signature · 1 line
Sivaraam
Re: [PATCH v2 02/20] t9300: make the series B tests self-contained
Kaartic Sivaraam <[email protected]> writes:
[snip]
Quoted 45 lines
Quoted 45 lines
t/t9300-fast-import.sh +22
-15+ test_grep "1234567890 [+]051800" out + ) ' 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 + ) '
Quoted 8 lines
Quoted 2 lines
###
An --ignore-all-space diff helped me grok that most of this change is just the existing test getting their own repository and the test code indented to put them within a subshell.
Yeah that's probably the best way to review this as most of the changes are just moving to subshell to ensure we don't have any dependencies.
Quoted 5 lines
I just wonder how much additional time or work this has resulted in 16 additional repos being created and torn down.
--
Sivaraam
I haven't actually tested, but moving them to different files also increases the parallelism of tests plus significant readability improvements.
Re: [PATCH v2 02/20] t9300: make the series B tests self-contained
Hi Karthik,
Quoted 3 lines · Karthik Nayak
I haven't actually tested, but moving them to different files also increases the parallelism of tests plus significant readability improvements.
I measured it out of curiosity. On my machine (4 cores), all the fast-import test scripts went from 17.8s to 21.1s when run one after another, and from 11.0s to 11.9s with prove -j4. So the split doesn't quite win the time back at -j4, but the readability is worth it.
Thanks,
Tanga
PATCH v2 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
@@ -3602,38 +3602,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
Re: [PATCH v2 03/20] t9300: make the series T tests self-contained
Quoted 25 lines · Karthik Nayak
t/t9300-fast-import.sh +8
-9@@ -3602,38 +3602,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
t/t9300-fast-import.sh test_path_eol_quoted_fail 'ls (without dataref in commit)' 'ls ' path · line 3626
Quoted 10 lines
t/t9300-fast-import.sh +7
-0+ EOF + sha1=$(git rev-parse --verify HEAD) && + git fast-import <<-EOF >actual && + ls $sha1 $root + EOF + test_cmp expect actual + ) ' done
We lose the --import-marks dependency from series S as the commit message indicated.
Quoted 16 lines
t/t9300-fast-import.sh +6
-6test_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 && +
t/t9300-fast-import.sh test_path_eol_quoted_fail 'ls (without dataref in commit)' 'ls ' path · line 3659
Quoted 10 lines
t/t9300-fast-import.sh +7
-0+ 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 + ) ' ###
The rest is just wrapping of test body within a subshell to make them get their own repository.
Looks good to me.
Signature · 1 line
Sivaraam
PATCH v2 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
@@ -3100,10 +3100,12 @@ test_expect_success 'R: --git-completion-helper-all does not read from stdin' ' # # invalid dataref .. # -test_expect_success 'S: initialize for S tests' ' +setup_marks_repo () { + test_when_finished "rm -rf repo" && + git init repo && test_tick && - cat >input <<-INPUT_END && + cat >repo/input <<-INPUT_END && commit refs/heads/S mark :301 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
@@ -3140,142 +3142,168 @@ test_expect_success 'S: initialize for S tests' ' BLOB INPUT_END - git fast-import --export-marks=marks <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 + ) '
@@ -3283,61 +3311,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
Re: [PATCH v2 04/20] t9300: make the series S tests self-contained
Quoted 36 lines · Karthik Nayak
Similar to the previous commits, modify the tests in 'series S' to make them independent of state from previous tests.
Replace the 'S: initialize for S tests' test with a '
setup_marks_repo()' function, so each test can invoke it to setup its own repo and tear it down when the test completes.'S: from with garbage after mark must fail' used to create the 'S2' commit which 'S: merge with garbage after mark must fail' needs. Create that commit in the merge test instead.
Signed-off-by Karthik Nayak <[email protected]>--- t/t9300-fast-import.sh | 332 +++++++++++++++++++++++++++++-------------------- 1 file changed, 198 insertions(+), 134 deletions(-)t/t9300-fast-import.sh +4
-2@@ -3100,10 +3100,12 @@ test_expect_success 'R: --git-completion-helper-all does not read from stdin' ' # # invalid dataref .. # -test_expect_success 'S: initialize for S tests' ' +setup_marks_repo () { + test_when_finished "rm -rf repo" && + git init repo && test_tick && - cat >input <<-INPUT_END && + cat >repo/input <<-INPUT_END && commit refs/heads/S mark :301 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
t/t9300-fast-import.sh test_expect_success 'S: initialize for S tests' ' · line 3147
Quoted 8 lines
t/t9300-fast-import.sh +2
-2@@ -3140,142 +3142,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 +}
Ok. So, the setup needed for the 'S' series is a bit more involved and it was done once initially before all tests. So, turning this into a function and calling it from every place that needs it makes sense.
The rest of the patch looks good just as the commit describes it to be.
Signature · 1 line
Sivaraam
PATCH v2 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
@@ -3854,7 +3854,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 $?"
@@ -3906,80 +3906,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
Re: [PATCH v2 05/20] t9300: make the series V tests self-contained
Quoted 12 lines · Karthik Nayak
Similar 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.
May be also mention that it sets fi_pid that background_import_still_running_ expects?
Quoted 19 lines
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.
Signed-off-by Karthik Nayak <[email protected]>---
test_expect_successPIPE 'V: checkpoint updates tags after tag' 't/t9300-fast-import.sh +3
-2- 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
t/t9300-fast-import.sh background_import_still_running () { · line 4014
Quoted 10 lines
t/t9300-fast-import.sh +2
-2data 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 '
The way this test series is refactored is different but it is consistent with how the commit message describes it to be.
LGTM.
Signature · 1 line
Sivaraam
Re: [PATCH v2 05/20] t9300: make the series V tests self-contained
Quoted 9 lines · Kaartic Sivaraam
Quoted 8 lines · Karthik Nayak
Similar 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'.
Quoted 8 lines
Quoted 4 lines
'
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.May be also mention that it sets
fi_pidthatbackground_import_still_running_expects?
True, I'll add it in, but will avoid re-rolling just for it.
Quoted 33 lines
Quoted 19 lines
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.
Signed-off-by Karthik Nayak <[email protected]>---
test_expect_successPIPE 'V: checkpoint updates tags after tag' 't/t9300-fast-import.sh +3
-2- 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_DATEt/t9300-fast-import.sh background_import_still_running () { · line 4014
Quoted 10 lines
t/t9300-fast-import.sh +2
-2data 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 'The way this test series is refactored is different but it is consistent with how the commit message describes it to be.
Quoted 1 line
LGTM.
Thanks for your review :)
PATCH v2 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.
Drop 'Q: verify pack', as other tests already verify the packs written by fast-import.
--- t/t9300-fast-import.sh | 339 +++++++++++++++++++++++++++++++------------------ 1 file changed, 212 insertions(+), 127 deletions(-)
t/t9300-fast-import.sh +212 -127
@@ -2048,7 +2048,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" &&
@@ -2057,7 +2067,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
@@ -2168,199 +2178,274 @@ test_expect_success 'Q: commit notes' ' INPUT_END - git fast-import <input && - git log --raw notes-test -' - -test_expect_success 'Q: verify pack' ' - verify_packs -' + git -C repo 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 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 v2 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
@@ -1891,157 +1891,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 v2 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
@@ -1748,143 +1748,216 @@ done ### series O ### -test_expect_success 'O: comments are all skipped' ' - cat >input <<-INPUT_END && - #we will - commit refs/heads/O1 - # -- ignore all of this text +setup_import_repo () { + test_when_finished "rm -rf repo" && + git init repo && + git -C repo config fastimport.unpackLimit 0 && + mkdir repo/file2 && + echo abcd >repo/file2/file4 && + git -C repo add file2/file4 && + test_tick && + git -C repo commit -m base +} + +import_reference_commit () { + git fast-import <<-INPUT_END + commit refs/heads/$1 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <<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 v2 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
@@ -3198,51 +3198,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 -' - test_expect_success 'R: --git-completion-helper does not read from stdin' ' find .git/objects/pack -name "tmp_pack_*" >before && echo garbage | git fast-import --git-completion-helper >out &&
Signature · 1 line
2.56.GIT
Re: [PATCH v2 09/20] t9300: make the big blob tests self-contained
Quoted 3 lines · Karthik Nayak
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.
The same loop ends up in four places, in t9307, t9308 and t9311. Maybe verify_packs() could move into a small shared file instead, if more tests leave t9300 later.
Thanks,
Tanga
PATCH v2 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.
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 + ) ' ###
@@ -1042,42 +1055,50 @@ test_expect_success 'I: export-pack-edges via stdin' ' ### 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 + ) ' ###
@@ -1085,29 +1106,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 v2 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 v2 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.
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 | 90 +++++++++++++++++++++++++++++++------------------- 1 file changed, 56 insertions(+), 34 deletions(-)
t/t9300-fast-import.sh +56 -34
@@ -1030,50 +1030,72 @@ test_expect_success 'H: verify file' ' ### test_expect_success 'I: export-pack-edges option forbidden by default' ' - echo "option git export-pack-edges=edges.list" >input && - test_must_fail git fast-import <input 2>err && - test_grep "option ${SQ}export-pack-edges${SQ} forbidden in input without --allow-unsafe-features" err + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + echo "option git export-pack-edges=edges.list" >input && + test_must_fail git fast-import <input 2>err && + test_grep "option ${SQ}export-pack-edges${SQ} forbidden in input without --allow-unsafe-features" err + ) ' test_expect_success 'I: export-pack-edges' ' - test_when_finished "rm edges.list" && - 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 && - 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 + from refs/heads/main + + 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 + ) ' test_expect_success 'I: export-pack-edges via stdin' ' - test_when_finished "rm edges.list" && - cat >input <<-INPUT_END && - option git export-pack-edges=edges.list - commit refs/heads/export-boundary-2 - committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE - data <<COMMIT - one more similar commit - 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 && + option git export-pack-edges=edges.list + commit refs/heads/export-boundary + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <<COMMIT + one more similar commit + COMMIT - INPUT_END - git fast-import --allow-unsafe-features <input && - cat >expect <<-EOF && - .git/objects/pack/pack-.pack: $(git rev-parse --verify export-boundary-2) - EOF - sed -e s/pack-.*pack/pack-.pack/ edges.list >actual && - test_cmp expect actual + from refs/heads/main + + INPUT_END + + git -c fastimport.unpackLimit=0 fast-import \ + --allow-unsafe-features <input && + 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 v2 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 + ) ' ###
@@ -2681,32 +2687,44 @@ 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: --allow-unsafe-features found after a value' '
@@ -2746,167 +2764,275 @@ test_expect_success 'R: --allow-unsafe-features after a non-option' ' ' 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
@@ -3252,18 +3378,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 v2 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 | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-)
t/t9300-fast-import.sh +27 -13
@@ -4579,27 +4579,35 @@ cat >Y-marks <<\Y_INPUT_END :4 ff729f5e62f72c0c3978207d9a80e5f3a65f14d7 Y_INPUT_END -test_expect_success 'Y: setup' ' - test_oid_cache <<-EOF - Ymain sha1:9afed2f9161ddf416c0a1863b8b0725b00070504 - Ymain sha256:c0a1010da1df187b2e287654793df01b464bd6f8e3f17fc1481a7dadf84caee3 - EOF -' - test_expect_success 'Y: rewrite-submodules-to feature forbidden by default' ' - echo "feature rewrite-submodules-to=sub:sub2-marks" >input && - test_must_fail git fast-import <input 2>err && - test_grep "feature ${SQ}rewrite-submodules-to${SQ} forbidden in input without --allow-unsafe-features" err + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + echo "feature rewrite-submodules-to=sub:sub2-marks" >input && + test_must_fail git fast-import <input 2>err && + test_grep "feature ${SQ}rewrite-submodules-to${SQ} forbidden in input without --allow-unsafe-features" err + ) ' test_expect_success 'Y: rewrite-submodules-from feature forbidden by default' ' - echo "feature rewrite-submodules-from=sub:../Y-marks" >input && - test_must_fail git fast-import <input 2>err && - test_grep "feature ${SQ}rewrite-submodules-from${SQ} forbidden in input without --allow-unsafe-features" err + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + echo "feature rewrite-submodules-from=sub:../Y-marks" >input && + test_must_fail git fast-import <input 2>err && + test_grep "feature ${SQ}rewrite-submodules-from${SQ} forbidden in input without --allow-unsafe-features" err + ) ' test_expect_success 'Y: rewrite submodules' ' test_when_finished "rm -rf main1" && + test_oid_cache <<-EOF && + Ymain sha1:9afed2f9161ddf416c0a1863b8b0725b00070504 + Ymain sha256:c0a1010da1df187b2e287654793df01b464bd6f8e3f17fc1481a7dadf84caee3 + EOF + git init main1 && ( cd main1 &&
@@ -4619,6 +4627,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 &&
@@ -4656,6 +4665,11 @@ test_expect_success 'Y: reference pending tag or commit' ' test_expect_success 'Y: rewrite submodules via stdin' ' test_when_finished "rm -rf main1" && + test_oid_cache <<-EOF && + Ymain sha1:9afed2f9161ddf416c0a1863b8b0725b00070504 + Ymain sha256:c0a1010da1df187b2e287654793df01b464bd6f8e3f17fc1481a7dadf84caee3 + EOF + git init main1 && ( cd main1 &&
Signature · 1 line
2.56.GIT
PATCH v2 15/20 t9300: make the cat-blob tests self-contained
In reply to Karthik NayakSimilar to the previous commits, modify the cat-blog tests to make them independent of state from previous tests.
--- t/t9300-fast-import.sh | 428 ++++++++++++++++++++++++++++--------------------- 1 file changed, 242 insertions(+), 186 deletions(-)
t/t9300-fast-import.sh +242 -186
@@ -3048,87 +3048,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
@@ -3138,153 +3168,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 v2 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 | 260 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 187 insertions(+), 73 deletions(-)
t/t9300-fast-import.sh +187 -73
@@ -2636,54 +2636,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' '
@@ -2728,39 +2764,69 @@ test_expect_success 'R: export-marks options can be overridden by commandline op ' test_expect_success 'R: --allow-unsafe-features found after a value' ' - echo "feature import-marks-if-exists=nonexistent.marks" >input && - git fast-import --allow-unsafe-features <input && - git fast-import --depth=5 --allow-unsafe-features <input && - git fast-import --depth 5 --allow-unsafe-features <input && - git fast-import --date-format raw --allow-unsafe-features <input + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + + echo "feature import-marks-if-exists=nonexistent.marks" >input && + git fast-import --allow-unsafe-features <input && + git fast-import --depth=5 --allow-unsafe-features <input && + git fast-import --depth 5 --allow-unsafe-features <input && + git fast-import --date-format raw --allow-unsafe-features <input + ) ' test_expect_success 'R: --allow-unsafe-features can be abbreviated' ' - echo "feature import-marks-if-exists=nonexistent.marks" >input && - GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS=false \ - git fast-import --allow-unsafe <input + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + + echo "feature import-marks-if-exists=nonexistent.marks" >input && + GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS=false \ + git fast-import --allow-unsafe <input + ) ' test_expect_success 'R: disallowed abbreviation of --allow-unsafe-features' ' - echo "feature import-marks-if-exists=nonexistent.marks" >input && - test_must_fail env GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS=true \ - git fast-import --allow-unsafe <input 2>err && - test_grep "forbidden in input without --allow-unsafe-features" err + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + + echo "feature import-marks-if-exists=nonexistent.marks" >input && + test_must_fail env GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS=true \ + git fast-import --allow-unsafe <input 2>err && + test_grep "forbidden in input without --allow-unsafe-features" err + ) ' test_expect_success 'R: --allow-unsafe-features as the value of an abbreviation' ' - echo "feature import-marks-if-exists=nonexistent.marks" >input && - test_must_fail env GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS=false \ - git fast-import --quiet --export-pack \ - --allow-unsafe-features <input 2>err && - test_grep "forbidden in input without --allow-unsafe-features" err + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + + echo "feature import-marks-if-exists=nonexistent.marks" >input && + test_must_fail env GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS=false \ + git fast-import --quiet --export-pack \ + --allow-unsafe-features <input 2>err && + test_grep "forbidden in input without --allow-unsafe-features" err + ) ' test_expect_success 'R: --allow-unsafe-features after a non-option' ' - echo "feature import-marks-if-exists=nonexistent.marks" >input && - test_must_fail git fast-import --depth 5 extra \ - --allow-unsafe-features <input 2>err && - test_grep "forbidden in input without --allow-unsafe-features" err + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + + echo "feature import-marks-if-exists=nonexistent.marks" >input && + test_must_fail git fast-import --depth 5 extra \ + --allow-unsafe-features <input 2>err && + test_grep "forbidden in input without --allow-unsafe-features" err + ) ' test_expect_success 'R: catch typo in marks file name' '
@@ -3034,17 +3100,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' '
@@ -3399,38 +3483,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 v2 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 | 154 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 101 insertions(+), 53 deletions(-)
t/t9300-fast-import.sh +101 -53
@@ -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' '
@@ -3428,58 +3440,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' '
@@ -3615,19 +3651,31 @@ test_expect_success 'R: blob bigger than threshold' ' ' test_expect_success 'R: --git-completion-helper does not read from stdin' ' - find .git/objects/pack -name "tmp_pack_*" >before && - echo garbage | git fast-import --git-completion-helper >out && - test_grep -e "--date-format=" out && - find .git/objects/pack -name "tmp_pack_*" >after && - test_cmp before after + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + + find .git/objects/pack -name "tmp_pack_*" >before && + echo garbage | git fast-import --git-completion-helper >out && + test_grep -e "--date-format=" out && + find .git/objects/pack -name "tmp_pack_*" >after && + test_cmp before after + ) ' test_expect_success 'R: --git-completion-helper-all does not read from stdin' ' - find .git/objects/pack -name "tmp_pack_*" >before && - echo garbage | git fast-import --git-completion-helper-all >all && - test_grep -e "--allow-unsafe-features" all && - find .git/objects/pack -name "tmp_pack_*" >after && - test_cmp before after + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + + find .git/objects/pack -name "tmp_pack_*" >before && + echo garbage | git fast-import --git-completion-helper-all >all && + test_grep -e "--allow-unsafe-features" all && + find .git/objects/pack -name "tmp_pack_*" >after && + test_cmp before after + ) ' ###
Signature · 1 line
2.56.GIT
PATCH v2 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
@@ -4626,7 +4626,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
@@ -4635,28 +4636,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 + ) ' ###
@@ -4664,25 +4690,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 v2 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 | 3730 ------------------------------------- t/t9301-fast-import-notes.sh | 400 ++++ t/t9304-fast-import-marks.sh | 393 ++++ t/t9307-fast-import-validation.sh | 1262 +++++++++++++ t/t9308-fast-import-stream.sh | 890 +++++++++ t/t9309-fast-import-checkpoint.sh | 188 ++ t/t9310-fast-import-submodule.sh | 385 ++++ t/t9311-fast-import-refs.sh | 194 ++ 9 files changed, 3717 insertions(+), 3730 deletions(-)
t/meson.build +5 -0
@@ -1086,6 +1086,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 -3730
2,989 lines not on this page · raw message
t/t9301-fast-import-notes.sh +400 -0
400 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 +1262 -0
1,262 lines not on this page · raw message
t/t9308-fast-import-stream.sh new file +890 -0
890 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 +385 -0
385 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 v2 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 | 40 +++++++------- t/t9304-fast-import-marks.sh | 28 +++++----- t/t9307-fast-import-validation.sh | 106 +++++++++++++++++++------------------- t/t9308-fast-import-stream.sh | 60 ++++++++++----------- t/t9309-fast-import-checkpoint.sh | 10 ++-- t/t9310-fast-import-submodule.sh | 18 +++---- t/t9311-fast-import-refs.sh | 14 ++--- 7 files changed, 138 insertions(+), 138 deletions(-)
t/t9301-fast-import-notes.sh +20 -20
@@ -860,7 +860,7 @@ echo \"\$@\"" && commit3=$(git -C repo rev-parse notes-test) } -test_expect_success 'Q: verify first commit' ' +test_expect_success 'verify first commit' ' setup_notes_repo && ( cd repo &&
@@ -875,7 +875,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 &&
@@ -891,7 +891,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 &&
@@ -907,7 +907,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 &&
@@ -922,7 +922,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 &&
@@ -936,7 +936,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 &&
@@ -946,7 +946,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 &&
@@ -956,7 +956,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 &&
@@ -966,7 +966,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 &&
@@ -982,7 +982,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 &&
@@ -996,7 +996,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 &&
@@ -1006,7 +1006,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 &&
@@ -1016,7 +1016,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 &&
@@ -1026,7 +1026,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 &&
@@ -1041,7 +1041,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 &&
@@ -1053,7 +1053,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 &&
@@ -1063,7 +1063,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 &&
@@ -1079,7 +1079,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 &&
@@ -1091,7 +1091,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 &&
@@ -1101,7 +1101,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 +53 -53
424 lines not on this page · raw message
t/t9308-fast-import-stream.sh +30 -30
240 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 +9 -9
@@ -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
@@ -295,7 +295,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
@@ -339,7 +339,7 @@ test_expect_success 'Y: reference pending tag or commit' ' ) ' -test_expect_success 'Y: rewrite-submodules-to feature forbidden by default' ' +test_expect_success 'rewrite-submodules-to feature forbidden by default' ' test_when_finished "rm -rf repo" && git init repo && (
@@ -350,7 +350,7 @@ test_expect_success 'Y: rewrite-submodules-to feature forbidden by default' ' ) ' -test_expect_success 'Y: rewrite-submodules-from feature forbidden by default' ' +test_expect_success 'rewrite-submodules-from feature forbidden by default' ' test_when_finished "rm -rf repo" && git init repo && (
@@ -361,7 +361,7 @@ test_expect_success 'Y: rewrite-submodules-from feature forbidden by default' ' ) ' -test_expect_success 'Y: rewrite submodules via stdin' ' +test_expect_success 'rewrite submodules via stdin' ' test_when_finished "rm -rf main1" && test_oid_cache <<-EOF && Ymain sha1:9afed2f9161ddf416c0a1863b8b0725b00070504
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