* [PATCH 01/20] t9300: move 'fastimport.unpackLimit' to the required test
2026-11-10 11:49 [PATCH 00/20] t9300: group and move tests to other files Karthik Nayak
@ 2026-11-10 11:49 ` Karthik Nayak
2026-11-10 11:49 ` [PATCH 02/20] t9300: make the series B tests self-contained Karthik Nayak
` (20 subsequent siblings)
21 siblings, 0 replies; 45+ messages in thread
From: Karthik Nayak @ 2026-11-10 11:49 UTC (permalink / raw)
To: git; +Cc: 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'.
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
t/t9300-fast-import.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 73c6e3d448..fb23492202 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -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
--
2.56.GIT
^ permalink raw reply related [flat|nested] 45+ messages in thread* [PATCH 02/20] t9300: make the series B tests self-contained
2026-11-10 11:49 [PATCH 00/20] t9300: group and move tests to other files Karthik Nayak
2026-11-10 11:49 ` [PATCH 01/20] t9300: move 'fastimport.unpackLimit' to the required test Karthik Nayak
@ 2026-11-10 11:49 ` Karthik Nayak
2026-11-10 11:49 ` [PATCH 03/20] t9300: make the series T " Karthik Nayak
` (19 subsequent siblings)
21 siblings, 0 replies; 45+ messages in thread
From: Karthik Nayak @ 2026-11-10 11:49 UTC (permalink / raw)
To: git; +Cc: 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 <karthik.188@gmail.com>
---
t/t9300-fast-import.sh | 472 ++++++++++++++++++++++++++++---------------------
1 file changed, 275 insertions(+), 197 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index fb23492202..1b34f6491c 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -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 <a@b.com> $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 <a@b.com> $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
+ )
'
###
--
2.56.GIT
^ permalink raw reply related [flat|nested] 45+ messages in thread* [PATCH 03/20] t9300: make the series T tests self-contained
2026-11-10 11:49 [PATCH 00/20] t9300: group and move tests to other files Karthik Nayak
2026-11-10 11:49 ` [PATCH 01/20] t9300: move 'fastimport.unpackLimit' to the required test Karthik Nayak
2026-11-10 11:49 ` [PATCH 02/20] t9300: make the series B tests self-contained Karthik Nayak
@ 2026-11-10 11:49 ` Karthik Nayak
2026-11-10 11:49 ` [PATCH 04/20] t9300: make the series S " Karthik Nayak
` (18 subsequent siblings)
21 siblings, 0 replies; 45+ messages in thread
From: Karthik Nayak @ 2026-11-10 11:49 UTC (permalink / raw)
To: git; +Cc: Karthik Nayak
Similar 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.
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
t/t9300-fast-import.sh | 62 +++++++++++++++++++++++++++++++++-----------------
1 file changed, 41 insertions(+), 21 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 1b34f6491c..76cc9504eb 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -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
+ )
'
###
--
2.56.GIT
^ permalink raw reply related [flat|nested] 45+ messages in thread* [PATCH 04/20] t9300: make the series S tests self-contained
2026-11-10 11:49 [PATCH 00/20] t9300: group and move tests to other files Karthik Nayak
` (2 preceding siblings ...)
2026-11-10 11:49 ` [PATCH 03/20] t9300: make the series T " Karthik Nayak
@ 2026-11-10 11:49 ` Karthik Nayak
2026-11-10 11:49 ` [PATCH 05/20] t9300: make the series V " Karthik Nayak
` (17 subsequent siblings)
21 siblings, 0 replies; 45+ messages in thread
From: Karthik Nayak @ 2026-11-10 11:49 UTC (permalink / raw)
To: git; +Cc: 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 <karthik.188@gmail.com>
---
t/t9300-fast-import.sh | 332 +++++++++++++++++++++++++++++--------------------
1 file changed, 198 insertions(+), 134 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 76cc9504eb..14af91cffd 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -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
+ )
'
#
--
2.56.GIT
^ permalink raw reply related [flat|nested] 45+ messages in thread* [PATCH 05/20] t9300: make the series V tests self-contained
2026-11-10 11:49 [PATCH 00/20] t9300: group and move tests to other files Karthik Nayak
` (3 preceding siblings ...)
2026-11-10 11:49 ` [PATCH 04/20] t9300: make the series S " Karthik Nayak
@ 2026-11-10 11:49 ` Karthik Nayak
2026-11-10 11:49 ` [PATCH 06/20] t9300: make the series Q " Karthik Nayak
` (16 subsequent siblings)
21 siblings, 0 replies; 45+ messages in thread
From: Karthik Nayak @ 2026-11-10 11:49 UTC (permalink / raw)
To: git; +Cc: 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.
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 <karthik.188@gmail.com>
---
t/t9300-fast-import.sh | 80 ++++++++++++++++++++++++++++++++++----------------
1 file changed, 55 insertions(+), 25 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 14af91cffd..8124983409 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -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
'
--
2.56.GIT
^ permalink raw reply related [flat|nested] 45+ messages in thread* [PATCH 06/20] t9300: make the series Q tests self-contained
2026-11-10 11:49 [PATCH 00/20] t9300: group and move tests to other files Karthik Nayak
` (4 preceding siblings ...)
2026-11-10 11:49 ` [PATCH 05/20] t9300: make the series V " Karthik Nayak
@ 2026-11-10 11:49 ` Karthik Nayak
2026-11-10 11:49 ` [PATCH 07/20] t9300: make the series P " Karthik Nayak
` (15 subsequent siblings)
21 siblings, 0 replies; 45+ messages in thread
From: Karthik Nayak @ 2026-11-10 11:49 UTC (permalink / raw)
To: git; +Cc: Karthik Nayak
Similar 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.
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
t/t9300-fast-import.sh | 344 +++++++++++++++++++++++++++++++------------------
1 file changed, 220 insertions(+), 124 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 8124983409..9b1827bae2 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -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
+ )
'
###
--
2.56.GIT
^ permalink raw reply related [flat|nested] 45+ messages in thread* [PATCH 07/20] t9300: make the series P tests self-contained
2026-11-10 11:49 [PATCH 00/20] t9300: group and move tests to other files Karthik Nayak
` (5 preceding siblings ...)
2026-11-10 11:49 ` [PATCH 06/20] t9300: make the series Q " Karthik Nayak
@ 2026-11-10 11:49 ` Karthik Nayak
2026-11-10 11:49 ` [PATCH 08/20] t9300: make the series O " Karthik Nayak
` (14 subsequent siblings)
21 siblings, 0 replies; 45+ messages in thread
From: Karthik Nayak @ 2026-11-10 11:49 UTC (permalink / raw)
To: git; +Cc: Karthik Nayak
Similar 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.
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
t/t9300-fast-import.sh | 290 +++++++++++++++++++++++++++----------------------
1 file changed, 161 insertions(+), 129 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 9b1827bae2..480ae2c47f 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -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
+ )
'
###
--
2.56.GIT
^ permalink raw reply related [flat|nested] 45+ messages in thread* [PATCH 08/20] t9300: make the series O tests self-contained
2026-11-10 11:49 [PATCH 00/20] t9300: group and move tests to other files Karthik Nayak
` (6 preceding siblings ...)
2026-11-10 11:49 ` [PATCH 07/20] t9300: make the series P " Karthik Nayak
@ 2026-11-10 11:49 ` Karthik Nayak
2026-11-10 11:49 ` [PATCH 09/20] t9300: make the big blob " Karthik Nayak
` (13 subsequent siblings)
21 siblings, 0 replies; 45+ messages in thread
From: Karthik Nayak @ 2026-11-10 11:49 UTC (permalink / raw)
To: git; +Cc: Karthik Nayak
Similar 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.
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
t/t9300-fast-import.sh | 291 +++++++++++++++++++++++++++++++------------------
1 file changed, 182 insertions(+), 109 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 480ae2c47f..75c2de46ed 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -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
+ )
'
###
--
2.56.GIT
^ permalink raw reply related [flat|nested] 45+ messages in thread* [PATCH 09/20] t9300: make the big blob tests self-contained
2026-11-10 11:49 [PATCH 00/20] t9300: group and move tests to other files Karthik Nayak
` (7 preceding siblings ...)
2026-11-10 11:49 ` [PATCH 08/20] t9300: make the series O " Karthik Nayak
@ 2026-11-10 11:49 ` Karthik Nayak
2026-11-10 11:49 ` [PATCH 10/20] t9300: make the ref update " Karthik Nayak
` (12 subsequent siblings)
21 siblings, 0 replies; 45+ messages in thread
From: Karthik Nayak @ 2026-11-10 11:49 UTC (permalink / raw)
To: git; +Cc: Karthik Nayak
Similar 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.
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
t/t9300-fast-import.sh | 79 ++++++++++++++++++++++++--------------------------
1 file changed, 38 insertions(+), 41 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 75c2de46ed..9f4aea09dd 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -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)
###
--
2.56.GIT
^ permalink raw reply related [flat|nested] 45+ messages in thread* [PATCH 10/20] t9300: make the ref update tests self-contained
2026-11-10 11:49 [PATCH 00/20] t9300: group and move tests to other files Karthik Nayak
` (8 preceding siblings ...)
2026-11-10 11:49 ` [PATCH 09/20] t9300: make the big blob " Karthik Nayak
@ 2026-11-10 11:49 ` Karthik Nayak
2026-11-10 11:49 ` [PATCH 11/20] t9300: make the date format " Karthik Nayak
` (11 subsequent siblings)
21 siblings, 0 replies; 45+ messages in thread
From: Karthik Nayak @ 2026-11-10 11:49 UTC (permalink / raw)
To: git; +Cc: Karthik Nayak
Similar to the previous commits, modify the reference update tests in
series 'F', 'G', 'J' and 'K' to make them independent of state from
previous tests. Add a 'setup_two_commit_repo()' function which creates
a repository with two commits on 'main', so each test can invoke it.
The tests used to build on the 'branch' branch of earlier tests.
Fold the tests which only check the result of an import into the tests
performing it, as they can't run on their own. As
'fastimport.unpackLimit' is no longer set by an earlier test, set it for
the 'F' and 'G' imports so that a pack is written, and verify it with an
inline loop in place of 'verify_packs()'.
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
t/t9300-fast-import.sh | 214 +++++++++++++++++++++++++++----------------------
1 file changed, 119 insertions(+), 95 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 9f4aea09dd..9576df78a1 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -865,43 +865,53 @@ test_expect_success 'E: verify commit' '
### series F
###
+setup_two_commit_repo () {
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ test_commit -C repo one &&
+ test_commit -C repo two
+}
+
test_expect_success 'F: non-fast-forward update skips' '
- old_branch=$(git rev-parse --verify branch^0) &&
- test_tick &&
- cat >input <<-INPUT_END &&
- commit refs/heads/branch
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<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)
+ )
'
###
--
2.56.GIT
^ permalink raw reply related [flat|nested] 45+ messages in thread* [PATCH 11/20] t9300: make the date format tests self-contained
2026-11-10 11:49 [PATCH 00/20] t9300: group and move tests to other files Karthik Nayak
` (9 preceding siblings ...)
2026-11-10 11:49 ` [PATCH 10/20] t9300: make the ref update " Karthik Nayak
@ 2026-11-10 11:49 ` Karthik Nayak
2026-11-10 11:49 ` [PATCH 12/20] t9300: make the pack edges test self-contained Karthik Nayak
` (10 subsequent siblings)
21 siblings, 0 replies; 45+ messages in thread
From: Karthik Nayak @ 2026-11-10 11:49 UTC (permalink / raw)
To: git; +Cc: Karthik Nayak
Similar 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()'.
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
t/t9300-fast-import.sh | 72 ++++++++++++++++++++++++++++++++++----------------
1 file changed, 49 insertions(+), 23 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 9576df78a1..5b0101700d 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -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
+ )
'
###
--
2.56.GIT
^ permalink raw reply related [flat|nested] 45+ messages in thread* [PATCH 12/20] t9300: make the pack edges test self-contained
2026-11-10 11:49 [PATCH 00/20] t9300: group and move tests to other files Karthik Nayak
` (10 preceding siblings ...)
2026-11-10 11:49 ` [PATCH 11/20] t9300: make the date format " Karthik Nayak
@ 2026-11-10 11:49 ` Karthik Nayak
2026-11-10 11:49 ` [PATCH 13/20] t9300: make the marks tests self-contained Karthik Nayak
` (9 subsequent siblings)
21 siblings, 0 replies; 45+ messages in thread
From: Karthik Nayak @ 2026-11-10 11:49 UTC (permalink / raw)
To: git; +Cc: Karthik Nayak
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.
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'.
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
t/t9300-fast-import.sh | 39 +++++++++++++++++++++++----------------
1 file changed, 23 insertions(+), 16 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 5b0101700d..f55604bb87 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -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
+ )
'
###
--
2.56.GIT
^ permalink raw reply related [flat|nested] 45+ messages in thread* [PATCH 13/20] t9300: make the marks tests self-contained
2026-11-10 11:49 [PATCH 00/20] t9300: group and move tests to other files Karthik Nayak
` (11 preceding siblings ...)
2026-11-10 11:49 ` [PATCH 12/20] t9300: make the pack edges test self-contained Karthik Nayak
@ 2026-11-10 11:49 ` Karthik Nayak
2026-11-10 11:49 ` [PATCH 14/20] t9300: make the series Y " Karthik Nayak
` (8 subsequent siblings)
21 siblings, 0 replies; 45+ messages in thread
From: Karthik Nayak @ 2026-11-10 11:49 UTC (permalink / raw)
To: git; +Cc: Karthik Nayak
Similar 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.
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
t/t9300-fast-import.sh | 512 +++++++++++++++++++++++++++++++------------------
1 file changed, 322 insertions(+), 190 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index f55604bb87..82348c65cc 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -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
+ )
'
##
--
2.56.GIT
^ permalink raw reply related [flat|nested] 45+ messages in thread* [PATCH 14/20] t9300: make the series Y tests self-contained
2026-11-10 11:49 [PATCH 00/20] t9300: group and move tests to other files Karthik Nayak
` (12 preceding siblings ...)
2026-11-10 11:49 ` [PATCH 13/20] t9300: make the marks tests self-contained Karthik Nayak
@ 2026-11-10 11:49 ` Karthik Nayak
2026-11-10 11:50 ` [PATCH 15/20] t9300: make the cat-blob " Karthik Nayak
` (7 subsequent siblings)
21 siblings, 0 replies; 45+ messages in thread
From: Karthik Nayak @ 2026-11-10 11:49 UTC (permalink / raw)
To: git; +Cc: Karthik Nayak
Similar 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.
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
t/t9300-fast-import.sh | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 82348c65cc..04c3bfe0c1 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -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 &&
--
2.56.GIT
^ permalink raw reply related [flat|nested] 45+ messages in thread* [PATCH 15/20] t9300: make the cat-blob tests self-contained
2026-11-10 11:49 [PATCH 00/20] t9300: group and move tests to other files Karthik Nayak
` (13 preceding siblings ...)
2026-11-10 11:49 ` [PATCH 14/20] t9300: make the series Y " Karthik Nayak
@ 2026-11-10 11:50 ` Karthik Nayak
2026-11-10 11:50 ` [PATCH 16/20] t9300: make the feature and option " Karthik Nayak
` (6 subsequent siblings)
21 siblings, 0 replies; 45+ messages in thread
From: Karthik Nayak @ 2026-11-10 11:50 UTC (permalink / raw)
To: git; +Cc: Karthik Nayak
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.
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
t/t9300-fast-import.sh | 428 ++++++++++++++++++++++++++++---------------------
1 file changed, 242 insertions(+), 186 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 04c3bfe0c1..3f0e7b8b1f 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -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' '
--
2.56.GIT
^ permalink raw reply related [flat|nested] 45+ messages in thread* [PATCH 16/20] t9300: make the feature and option tests self-contained
2026-11-10 11:49 [PATCH 00/20] t9300: group and move tests to other files Karthik Nayak
` (14 preceding siblings ...)
2026-11-10 11:50 ` [PATCH 15/20] t9300: make the cat-blob " Karthik Nayak
@ 2026-11-10 11:50 ` Karthik Nayak
2026-11-10 11:50 ` [PATCH 17/20] t9300: make the stream " Karthik Nayak
` (5 subsequent siblings)
21 siblings, 0 replies; 45+ messages in thread
From: Karthik Nayak @ 2026-11-10 11:50 UTC (permalink / raw)
To: git; +Cc: Karthik Nayak
Similar 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.
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
t/t9300-fast-import.sh | 188 +++++++++++++++++++++++++++++++++++--------------
1 file changed, 136 insertions(+), 52 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 3f0e7b8b1f..cf00e4faf9 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -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' '
--
2.56.GIT
^ permalink raw reply related [flat|nested] 45+ messages in thread* [PATCH 17/20] t9300: make the stream tests self-contained
2026-11-10 11:49 [PATCH 00/20] t9300: group and move tests to other files Karthik Nayak
` (15 preceding siblings ...)
2026-11-10 11:50 ` [PATCH 16/20] t9300: make the feature and option " Karthik Nayak
@ 2026-11-10 11:50 ` Karthik Nayak
2026-11-10 11:50 ` [PATCH 18/20] t9300: make the get-mark and encoding " Karthik Nayak
` (4 subsequent siblings)
21 siblings, 0 replies; 45+ messages in thread
From: Karthik Nayak @ 2026-11-10 11:50 UTC (permalink / raw)
To: git; +Cc: Karthik Nayak
Similar 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.
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
t/t9300-fast-import.sh | 122 ++++++++++++++++++++++++++++++++-----------------
1 file changed, 79 insertions(+), 43 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index cf00e4faf9..c719b2115e 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -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' '
--
2.56.GIT
^ permalink raw reply related [flat|nested] 45+ messages in thread* [PATCH 18/20] t9300: make the get-mark and encoding tests self-contained
2026-11-10 11:49 [PATCH 00/20] t9300: group and move tests to other files Karthik Nayak
` (16 preceding siblings ...)
2026-11-10 11:50 ` [PATCH 17/20] t9300: make the stream " Karthik Nayak
@ 2026-11-10 11:50 ` Karthik Nayak
2026-11-10 11:50 ` [PATCH 19/20] t9300: move self-contained tests into dedicated files Karthik Nayak
` (3 subsequent siblings)
21 siblings, 0 replies; 45+ messages in thread
From: Karthik Nayak @ 2026-11-10 11:50 UTC (permalink / raw)
To: git; +Cc: Karthik Nayak
Similar 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.
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
t/t9300-fast-import.sh | 81 +++++++++++++++++++++++++++++++++++---------------
1 file changed, 57 insertions(+), 24 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index c719b2115e..09cd2c5bf3 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -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 <user@company.tld> 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 &&
--
2.56.GIT
^ permalink raw reply related [flat|nested] 45+ messages in thread* [PATCH 19/20] t9300: move self-contained tests into dedicated files
2026-11-10 11:49 [PATCH 00/20] t9300: group and move tests to other files Karthik Nayak
` (17 preceding siblings ...)
2026-11-10 11:50 ` [PATCH 18/20] t9300: make the get-mark and encoding " Karthik Nayak
@ 2026-11-10 11:50 ` Karthik Nayak
2026-11-10 11:50 ` [PATCH 20/20] t93xx: drop the series letter from the moved test names Karthik Nayak
` (2 subsequent siblings)
21 siblings, 0 replies; 45+ messages in thread
From: Karthik Nayak @ 2026-11-10 11:50 UTC (permalink / raw)
To: git; +Cc: Karthik Nayak
The 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'.
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
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(-)
diff --git a/t/meson.build b/t/meson.build
index 11b3752f00..caf0a76c2d 100644
--- a/t/meson.build
+++ b/t/meson.build
@@ -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',
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 09cd2c5bf3..48c2913b87 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -37,26 +37,6 @@ echo "$@"'
### series A
###
-test_expect_success 'empty stream succeeds' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- git fast-import </dev/null
- )
-'
-
-test_expect_success 'truncated stream complains' '
- 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' '
git config fastimport.unpackLimit 0 &&
test_tick &&
@@ -309,421 +289,6 @@ test_expect_success 'A: verify diff' '
= $(git rev-parse --verify verify--import-marks:copy-of-file2)
'
-test_expect_success 'A: export marks with large values' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- test_tick &&
- mt=$(git hash-object --stdin < /dev/null) &&
- >input.blob &&
- >marks.exp &&
- >tree.exp &&
-
- 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
-
- 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 &&
-
- echo ":$l $mt" >>marks.exp &&
- echo ":$m $mt" >>marks.exp &&
- echo ":$n $mt" >>marks.exp &&
-
- 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 &&
-
- l=$(($l + $l)) &&
- m=$(($m + $m)) &&
- n=$(($l + $n)) &&
-
- i=$((1 + $i)) || return 1
- done &&
-
- 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
- )
-'
-
-###
-### series B
-###
-
-test_expect_success 'B: fail on invalid blob sha1' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
- test_commit base &&
-
- 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
-
- from refs/heads/main
- M 755 $(echo $ZERO_OID | sed -e "s/0$/1/") zero1
-
- INPUT_END
-
- test_must_fail git fast-import <input
- )
-'
-
-test_expect_success 'B: accept branch name "TEMP_TAG"' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
- test_commit new &&
-
- cat >input <<-INPUT_END &&
- commit TEMP_TAG
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<COMMIT
- tag base
- COMMIT
-
- from refs/heads/main
-
- 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' '
- 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
-
- git fast-import <input &&
- out=$(git fsck) &&
- echo "$out" &&
- test -z "$out"
- )
-'
-
-test_expect_success 'B: reject invalid timezone' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
- cat >input <<-INPUT_END &&
- commit refs/heads/empty-committer-2
- committer <a@b.com> $GIT_COMMITTER_DATE
- data <<COMMIT
- empty commit
- COMMIT
- INPUT_END
-
- git fast-import <input &&
- out=$(git fsck) &&
- echo "$out" &&
- test -z "$out"
- )
-'
-
-test_expect_success 'B: fail on invalid committer (1)' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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)' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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)' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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)' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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)' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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 ..' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- cat >input <<-INPUT_END &&
- blob
- mark :1
- data <<EOF
- File contents
- EOF
-
- 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 .' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- cat >input <<-INPUT_END &&
- blob
- mark :1
- data <<EOF
- File contents
- EOF
-
- commit refs/heads/badpath
- committer Name <email> $GIT_COMMITTER_DATE
- data <<COMMIT
- Good path
- COMMIT
- M 100644 :1 ok-path
-
- 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:' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- cat >input <<-INPUT_END &&
- blob
- mark :1
- data <<EOF
- File contents
- EOF
-
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- cat >input <<-INPUT_END &&
- blob
- mark :1
- data <<EOF
- File contents
- EOF
-
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- cat >input <<-INPUT_END &&
- blob
- mark :1
- data <<EOF
- File contents
- EOF
-
- 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
- )
-'
-
###
### series C
###
@@ -841,155 +406,6 @@ test_expect_success 'D: verify file6' '
test_cmp expect actual
'
-###
-### series E
-###
-
-test_expect_success 'E: rfc2822 date, --date-format=raw' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
- test_commit one &&
-
- 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
-
- from refs/heads/main^0
-
- INPUT_END
-
- test_must_fail git fast-import --date-format=raw <input
- )
-'
-
-test_expect_success 'E: rfc2822 date, --date-format=rfc2822' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
- test_commit one &&
-
- 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
-
- from refs/heads/main^0
-
- 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
- )
-'
-
-###
-### 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' '
- 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/main~1
-
- reset refs/heads/other
- from refs/heads/main
-
- INPUT_END
-
- test_must_fail git -c fastimport.unpackLimit=0 fast-import <input &&
- # branch must remain unaffected
- test $old_branch = $(git rev-parse --verify main^0) &&
-
- for p in .git/objects/pack/*.pack
- do
- git verify-pack "$p" || return 1
- done &&
-
- 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
- )
-'
-
-###
-### series G
-###
-
-test_expect_success 'G: non-fast-forward update forced' '
- 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/main~1
-
- 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}) &&
-
- for p in .git/objects/pack/*.pack
- do
- git verify-pack "$p" || return 1
- done
- )
-'
-
###
### series H
###
@@ -1043,123 +459,6 @@ test_expect_success 'H: verify file' '
test_cmp expect actual
'
-###
-### series I
-###
-
-test_expect_success 'I: export-pack-edges' '
- test_when_finished "rm -rf repo" &&
- git init -b main repo &&
- (
- cd repo &&
- test_commit one &&
-
- 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
-
- 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
- )
-'
-
-###
-### series J
-###
-
-test_expect_success 'J: reset existing branch creates empty 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/main
-
- reset refs/heads/J
-
- 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 &&
- # 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' '
- 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
- )
-'
-
-###
-### series K
-###
-
-test_expect_success 'K: reinit branch with from' '
- 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/main
-
- commit refs/heads/K
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<COMMIT
- redo K
- COMMIT
-
- from refs/heads/main^1
-
- INPUT_END
- git fast-import <input &&
- # K^1 = main^1
- test $(git rev-parse --verify main^1) \
- = $(git rev-parse --verify K^1)
- )
-'
-
###
### series L
###
@@ -1794,2418 +1093,6 @@ do
'
done
-###
-### series O
-###
-
-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
-
- 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
-
- INPUT_END
-}
-
-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' '
- setup_import_repo &&
- (
- cd repo &&
-
- 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
-
- 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 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' '
- setup_import_repo &&
- (
- cd repo &&
- git repack -a -d &&
-
- 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
-
- 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' '
- 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
- )
-'
-
-###
-### series P (gitlinks)
-###
-
-setup_gitlinks_repo () {
- test_when_finished "rm -rf repo" &&
- git init repo &&
- test_commit -C repo base &&
- (
- 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' '
- setup_gitlinks_repo &&
- (
- cd repo &&
-
- SUBLAST=$(git rev-parse --verify sub) &&
- SUBPREV=$(git rev-parse --verify sub^) &&
-
- cat >input <<-INPUT_END &&
- blob
- mark :1
- data <<DATAEND
- [submodule "sub"]
- path = sub
- url = "$(pwd)/sub"
- DATAEND
-
- 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
-
- 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
-
- 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' '
- setup_gitlinks_repo &&
- (
- cd repo &&
-
- 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
-
- from refs/heads/subuse1
- M 160000 inline sub
- data <<DATA
- $SUBPREV
- DATA
-
- INPUT_END
-
- test_must_fail git fast-import <input
- )
-'
-
-test_expect_success 'P: fail on blob mark in gitlink' '
- setup_gitlinks_repo &&
- (
- cd repo &&
-
- SUBPREV=$(git rev-parse --verify sub^) &&
- test_tick &&
- cat >input <<-INPUT_END &&
- blob
- mark :1
- data <<DATA
- $SUBPREV
- DATA
-
- commit refs/heads/subuse3
- mark :2
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<COMMIT
- corrupt
- COMMIT
-
- from refs/heads/subuse1
- M 160000 :1 sub
-
- INPUT_END
-
- test_must_fail git fast-import <input
- )
-'
-
-###
-### series Q (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" &&
- note1b_data="The second note for the first commit" &&
- note1c_data="The third note for the first commit" &&
- note2b_data="The second note for the second commit" &&
-
- test_tick &&
- cat >repo/input <<-INPUT_END &&
- blob
- mark :2
- data <<EOF
- $file2_data
- EOF
-
- commit refs/heads/notes-test
- mark :3
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<COMMIT
- first (:3)
- COMMIT
-
- M 644 :2 file2
-
- blob
- mark :4
- data $file4_len
- $file4_data
- commit refs/heads/notes-test
- mark :5
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<COMMIT
- second (:5)
- COMMIT
-
- M 644 :4 file4
-
- commit refs/heads/notes-test
- mark :6
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<COMMIT
- third (:6)
- COMMIT
-
- M 644 inline file5
- data <<EOF
- $file5_data
- EOF
-
- M 755 inline file6
- data <<EOF
- $file6_data
- EOF
-
- blob
- mark :7
- data <<EOF
- $note1_data
- EOF
-
- blob
- mark :8
- data <<EOF
- $note2_data
- EOF
-
- commit refs/notes/foobar
- mark :9
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<COMMIT
- notes (:9)
- COMMIT
-
- N :7 :3
- N :8 :5
- N inline :6
- data <<EOF
- $note3_data
- EOF
-
- commit refs/notes/foobar
- mark :10
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<COMMIT
- notes (:10)
- COMMIT
-
- N inline :3
- data <<EOF
- $note1b_data
- EOF
-
- commit refs/notes/foobar2
- mark :11
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<COMMIT
- notes (:11)
- COMMIT
-
- N inline :3
- data <<EOF
- $note1c_data
- EOF
-
- commit refs/notes/foobar
- mark :12
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<COMMIT
- notes (:12)
- COMMIT
-
- deleteall
- N inline :5
- data <<EOF
- $note2b_data
- EOF
-
- INPUT_END
-
- 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' '
- 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 &&
- (
- 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
-
- first (:3)
- EOF
- git cat-file commit notes-test~2 | sed 1d >actual &&
- test_cmp expect actual
- )
-'
-
-test_expect_success 'Q: verify second commit' '
- 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
- )
-'
-
-test_expect_success 'Q: verify third commit' '
- 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
- )
-'
-
-test_expect_success 'Q: verify first notes commit' '
- 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
- )
-'
-
-test_expect_success 'Q: verify first notes tree' '
- 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' '
- 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' '
- 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' '
- 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' '
- 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
- )
-'
-
-test_expect_success 'Q: verify second notes tree' '
- 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' '
- 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' '
- 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' '
- 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' '
- 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
- )
-'
-
-test_expect_success 'Q: verify third notes tree' '
- 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' '
- 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' '
- 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
- )
-'
-
-test_expect_success 'Q: verify fourth notes tree' '
- 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' '
- 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' '
- 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
-
- N inline refs/heads/Q0
- data <<NOTE
- some note
- NOTE
- EOF
- test_must_fail git fast-import <input
- )
-'
-
-###
-### series R (feature and option)
-###
-
-test_expect_success 'R: abort on unsupported feature' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- cat >input <<-EOF &&
- feature no-such-feature-exists
- EOF
-
- test_must_fail git fast-import <input
- )
-'
-
-test_expect_success 'R: supported feature is accepted' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- cat >input <<-EOF &&
- feature date-format=now
- EOF
-
- git fast-import <input
- )
-'
-
-test_expect_success 'R: abort on receiving feature after data command' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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' '
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- >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' '
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- cat >input <<-EOF &&
- feature export-marks=git.marks
- blob
- mark :1
- data 3
- hi
-
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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_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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- rm -f io.marks &&
-
- 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 &&
-
- blob=$(echo hi | git hash-object -w --stdin) &&
-
- echo ":1 $blob" >io.marks &&
- echo ":1 $blob" >expect &&
- echo ":2 $blob" >>expect &&
-
- git fast-import --export-marks=io.marks \
- --allow-unsafe-features <<-\EOF &&
- feature import-marks-if-exists=io.marks
- blob
- mark :2
- data 3
- hi
-
- EOF
- test_cmp expect io.marks &&
-
- echo ":3 $blob" >>expect &&
-
- 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
-
- 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
- )
-'
-
-create_marks_file () {
- git fast-import --export-marks="$1" <<-EOF
- blob
- mark :1
- data 4
- one
-
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
- create_marks_file marks.out &&
-
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
- create_marks_file marks.out &&
-
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
- create_marks_file marks.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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
- create_marks_file marks.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' '
- 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' '
- 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_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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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' '
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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
- )
-'
-
-setup_big_file () {
- (
- echo "the quick brown fox jumps over the lazy dog" >big &&
- for i in 1 2 3
- do
- cat big big big big >bigger &&
- cat bigger bigger bigger bigger >big ||
- exit
- done
- )
-}
-
-test_expect_success 'R: print two blobs to stdout' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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
-
- ${blob2} blob 6
- hello
-
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- setup_big_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 &&
- (
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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
-
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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
-
- to_get=$(
- echo "A blob from _within_ the commit." |
- git hash-object --stdin
- ) &&
- echo "cat-blob $to_get" &&
-
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- cat >input <<-EOF &&
- option git quiet
- blob
- data 3
- hi
-
- EOF
-
- git fast-import 2>output <input &&
- test_must_be_empty output
- )
-'
-
-test_expect_success 'R: feature done means terminating "done" is mandatory' '
- 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' '
- 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' '
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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_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' '
- 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' '
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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
- )
-'
-
-##
-## R: very large blobs
-##
-test_expect_success 'R: blob bigger than threshold' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- 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
- )
-'
-
-###
-### series S (mark and path parsing)
-###
-#
-# Make sure missing spaces and EOLs after mark references
-# cause errors.
-#
-# Setup:
-#
-# 1--2--4
-# \ /
-# -3-
-#
-# commit marks: 301, 302, 303, 304
-# blob marks: 403, 404, resp.
-# note mark: 202
-#
-# The error message when a space is missing not at the
-# end of the line is:
-#
-# missing space after ..
-#
-# or when extra characters come after the mark at the end
-# of the line:
-#
-# garbage after ..
-#
-# or when the dataref is neither "inline " or a known SHA1,
-#
-# invalid dataref ..
-#
-setup_marks_repo () {
- test_when_finished "rm -rf repo" &&
- git init repo &&
- test_tick &&
-
- cat >repo/input <<-INPUT_END &&
- commit refs/heads/S
- mark :301
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<COMMIT
- commit 1
- COMMIT
- M 100644 inline hello.c
- data <<BLOB
- blob 1
- BLOB
-
- commit refs/heads/S
- mark :302
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<COMMIT
- commit 2
- COMMIT
- from :301
- M 100644 inline hello.c
- data <<BLOB
- blob 2
- BLOB
-
- blob
- mark :403
- data <<BLOB
- blob 3
- BLOB
-
- blob
- mark :202
- data <<BLOB
- note 2
- BLOB
- INPUT_END
-
- git -C repo fast-import --export-marks=marks <repo/input
-}
-
-#
-# filemodify, three datarefs
-#
-test_expect_success 'S: filemodify with garbage after mark must fail' '
- 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' '
- 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' '
- 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' '
- 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' '
- 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' '
- 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' '
- 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' '
- 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
-
- test_grep "after mark" err
- )
-'
-
-
-#
-# merge
-#
-test_expect_success 'S: merge with garbage after mark must fail' '
- 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' '
- 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' '
- 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' '
- 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' '
- 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
- )
-'
-
-#
-# Path parsing
-#
-# There are two sorts of ways a path can be parsed, depending on whether it is
-# the last field on the line. Additionally, ls without a <dataref> has a special
-# case. Test every occurrence of <path> in the grammar against every error case.
-# Paths for the root (empty strings) are tested elsewhere.
-#
-
-#
-# Valid paths at the end of a line: filemodify, filedelete, filecopy (dest),
-# filerename (dest), and ls.
-#
-# commit :301 from root -- modify hello.c (for setup)
-# commit :302 from :301 -- modify $path
-# commit :303 from :302 -- delete $path
-# commit :304 from :301 -- copy hello.c $path
-# commit :305 from :301 -- rename hello.c $path
-# ls :305 $path
-#
-test_path_eol_success () {
- local test="$1" path="$2" unquoted_path="$3"
- test_expect_success "S: paths at EOL with $test must work" '
- test_when_finished "git branch -D S-path-eol" &&
-
- git -c core.protectNTFS=false fast-import --export-marks=marks.out <<-EOF >out 2>err &&
- blob
- mark :401
- data <<BLOB
- hello world
- BLOB
-
- blob
- mark :402
- data <<BLOB
- hallo welt
- BLOB
-
- commit refs/heads/S-path-eol
- mark :301
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<COMMIT
- initial commit
- COMMIT
- M 100644 :401 hello.c
-
- commit refs/heads/S-path-eol
- mark :302
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<COMMIT
- commit filemodify
- COMMIT
- from :301
- M 100644 :402 $path
-
- commit refs/heads/S-path-eol
- mark :303
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<COMMIT
- commit filedelete
- COMMIT
- from :302
- D $path
-
- commit refs/heads/S-path-eol
- mark :304
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<COMMIT
- commit filecopy dest
- COMMIT
- from :301
- C hello.c $path
-
- commit refs/heads/S-path-eol
- mark :305
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<COMMIT
- commit filerename dest
- COMMIT
- from :301
- R hello.c $path
-
- ls :305 $path
- EOF
-
- commit_m=$(grep :302 marks.out | cut -d\ -f2) &&
- commit_d=$(grep :303 marks.out | cut -d\ -f2) &&
- commit_c=$(grep :304 marks.out | cut -d\ -f2) &&
- commit_r=$(grep :305 marks.out | cut -d\ -f2) &&
- blob1=$(grep :401 marks.out | cut -d\ -f2) &&
- blob2=$(grep :402 marks.out | cut -d\ -f2) &&
-
- (
- printf "100644 blob $blob2\t$unquoted_path\n" &&
- printf "100644 blob $blob1\thello.c\n"
- ) | sort >tree_m.exp &&
- git ls-tree $commit_m | sort >tree_m.out &&
- test_cmp tree_m.exp tree_m.out &&
-
- printf "100644 blob $blob1\thello.c\n" >tree_d.exp &&
- git ls-tree $commit_d >tree_d.out &&
- test_cmp tree_d.exp tree_d.out &&
-
- (
- printf "100644 blob $blob1\t$unquoted_path\n" &&
- printf "100644 blob $blob1\thello.c\n"
- ) | sort >tree_c.exp &&
- git ls-tree $commit_c | sort >tree_c.out &&
- test_cmp tree_c.exp tree_c.out &&
-
- printf "100644 blob $blob1\t$unquoted_path\n" >tree_r.exp &&
- git ls-tree $commit_r >tree_r.out &&
- test_cmp tree_r.exp tree_r.out &&
-
- test_cmp out tree_r.exp
- '
-}
-
-test_path_eol_success 'quoted spaces' '" hello world.c "' ' hello world.c '
-test_path_eol_success 'unquoted spaces' ' hello world.c ' ' hello world.c '
-test_path_eol_success 'octal escapes' '"\150\151\056\143"' 'hi.c'
-
-#
-# Valid paths before a space: filecopy (source) and filerename (source).
-#
-# commit :301 from root -- modify $path (for setup)
-# commit :302 from :301 -- copy $path hello2.c
-# commit :303 from :301 -- rename $path hello2.c
-#
-test_path_space_success () {
- local test="$1" path="$2" unquoted_path="$3"
- test_expect_success "S: paths before space with $test must work" '
- test_when_finished "git branch -D S-path-space" &&
-
- git -c core.protectNTFS=false fast-import --export-marks=marks.out <<-EOF 2>err &&
- blob
- mark :401
- data <<BLOB
- hello world
- BLOB
-
- commit refs/heads/S-path-space
- mark :301
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<COMMIT
- initial commit
- COMMIT
- M 100644 :401 $path
-
- commit refs/heads/S-path-space
- mark :302
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<COMMIT
- commit filecopy source
- COMMIT
- from :301
- C $path hello2.c
-
- commit refs/heads/S-path-space
- mark :303
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<COMMIT
- commit filerename source
- COMMIT
- from :301
- R $path hello2.c
-
- EOF
-
- commit_c=$(grep :302 marks.out | cut -d\ -f2) &&
- commit_r=$(grep :303 marks.out | cut -d\ -f2) &&
- blob=$(grep :401 marks.out | cut -d\ -f2) &&
-
- (
- printf "100644 blob $blob\t$unquoted_path\n" &&
- printf "100644 blob $blob\thello2.c\n"
- ) | sort >tree_c.exp &&
- git ls-tree $commit_c | sort >tree_c.out &&
- test_cmp tree_c.exp tree_c.out &&
-
- printf "100644 blob $blob\thello2.c\n" >tree_r.exp &&
- git ls-tree $commit_r >tree_r.out &&
- test_cmp tree_r.exp tree_r.out
- '
-}
-
-test_path_space_success 'quoted spaces' '" hello world.c "' ' hello world.c '
-test_path_space_success 'no unquoted spaces' 'hello_world.c' 'hello_world.c'
-test_path_space_success 'octal escapes' '"\150\151\056\143"' 'hi.c'
-
-#
-# Test a single commit change with an invalid path. Run it with all occurrences
-# of <path> in the grammar against all error kinds.
-#
-test_path_fail () {
- local change="$1" what="$2" prefix="$3" path="$4" suffix="$5" err_grep="$6"
- test_expect_success "S: $change with $what must fail" '
- test_must_fail git fast-import <<-EOF 2>err &&
- blob
- mark :1
- data <<BLOB
- hello world
- BLOB
-
- commit refs/heads/S-path-fail
- mark :2
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<COMMIT
- commit setup
- COMMIT
- M 100644 :1 hello.c
-
- commit refs/heads/S-path-fail
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<COMMIT
- commit with bad path
- COMMIT
- from :2
- $prefix$path$suffix
- EOF
-
- test_grep "$err_grep" err
- '
-}
-
-test_path_base_fail () {
- local change="$1" prefix="$2" field="$3" suffix="$4"
- test_path_fail "$change" 'unclosed " in '"$field" "$prefix" '"hello.c' "$suffix" "invalid $field"
- test_path_fail "$change" "invalid escape in quoted $field" "$prefix" '"hello\xff"' "$suffix" "invalid $field"
- test_path_fail "$change" "escaped NUL in quoted $field" "$prefix" '"hello\000"' "$suffix" "NUL in $field"
-}
-test_path_eol_quoted_fail () {
- local change="$1" prefix="$2" field="$3"
- test_path_base_fail "$change" "$prefix" "$field" ''
- test_path_fail "$change" "garbage after quoted $field" "$prefix" '"hello.c"' 'x' "garbage after $field"
- test_path_fail "$change" "space after quoted $field" "$prefix" '"hello.c"' ' ' "garbage after $field"
-}
-test_path_eol_fail () {
- local change="$1" prefix="$2" field="$3"
- test_path_eol_quoted_fail "$change" "$prefix" "$field"
-}
-test_path_space_fail () {
- local change="$1" prefix="$2" field="$3"
- test_path_base_fail "$change" "$prefix" "$field" ' world.c'
- test_path_fail "$change" "missing space after quoted $field" "$prefix" '"hello.c"' 'x world.c' "missing space after $field"
- test_path_fail "$change" "missing space after unquoted $field" "$prefix" 'hello.c' '' "missing space after $field"
-}
-
-test_path_eol_fail filemodify 'M 100644 :1 ' path
-test_path_eol_fail filedelete 'D ' path
-test_path_space_fail filecopy 'C ' source
-test_path_eol_fail filecopy 'C hello.c ' dest
-test_path_space_fail filerename 'R ' source
-test_path_eol_fail filerename 'R hello.c ' dest
-test_path_eol_fail 'ls (in commit)' 'ls :2 ' path
-
-# When 'ls' has no <dataref>, the <path> must be quoted.
-test_path_eol_quoted_fail 'ls (without dataref in commit)' 'ls ' path
-
-###
-### series T (ls)
-###
-
-for root in '""' ''
-do
- test_expect_success "T: ls root ($root) tree" '
- 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' '
- 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' '
- 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
- )
-'
-
###
### series U (filedelete)
###
@@ -4316,456 +1203,4 @@ do
'
done
-###
-### series V (checkpoint)
-###
-
-# The commands in input_file should not produce any output on the file
-# descriptor set with --cat-blob-fd (or stdout if unspecified).
-#
-# To make sure you're observing the side effects of checkpoint *before*
-# fast-import terminates (and thus writes out its state), check that the
-# fast-import process is still running using background_import_still_running
-# *after* evaluating the test conditions.
-background_import_then_checkpoint () {
- options=$1
- input_file=$2
-
- mkfifo V.input
- exec 8<>V.input
- rm V.input
-
- mkfifo V.output
- exec 9<>V.output
- rm V.output
-
- (
- git -C repo fast-import $options <&8 >&9 &
- echo $! >&9
- wait $!
- echo >&2 "background fast-import terminated too early with exit code $?"
- # Un-block the read loop in the main shell process.
- echo >&9 UNEXPECTED
- ) &
- sh_pid=$!
- read fi_pid <&9
- # We don't mind if fast-import has already died by the time the test
- # ends.
- test_when_finished "
- exec 8>&-; exec 9>&-;
- kill $sh_pid && wait $sh_pid
- kill $fi_pid && wait $fi_pid
- true"
-
- # Start in the background to ensure we adhere strictly to (blocking)
- # pipes writing sequence. We want to assume that the write below could
- # block, e.g. if fast-import blocks writing its own output to &9
- # because there is no reader on &9 yet.
- (
- cat "$input_file"
- echo "checkpoint"
- echo "progress checkpoint"
- ) >&8 &
-
- last=$(
- while read output <&9
- do
- if test "$output" = "progress checkpoint" || test "$output" = "UNEXPECTED"
- then
- echo "$output"
- break
- else
- # otherwise ignore cruft
- echo >&2 "cruft: $output"
- fi
- done
- )
-
- test "$last" = "progress checkpoint"
-}
-
-background_import_still_running () {
- if ! kill -0 "$fi_pid"
- then
- echo >&2 "background fast-import terminated too early"
- false
- 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' '
- setup_checkpoint_repo &&
- cat >repo/input <<-INPUT_END &&
- progress foo
- progress bar
-
- INPUT_END
-
- background_import_then_checkpoint "" repo/input &&
- background_import_still_running
-'
-
-test_expect_success PIPE 'V: checkpoint updates refs after reset' '
- setup_checkpoint_repo &&
- cat >repo/input <<-\INPUT_END &&
- reset refs/heads/V
- from refs/heads/base
-
- INPUT_END
-
- 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' '
- 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/base
-
- INPUT_END
-
- background_import_then_checkpoint "--export-marks=marks.actual" repo/input &&
- (
- cd repo &&
- echo ":1 $(git rev-parse --verify V)" >marks.expected &&
-
- 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)' '
- 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/base
-
- INPUT_END
-
- background_import_then_checkpoint "--export-marks=marks.actual" repo/input &&
- (
- cd repo &&
- 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
- ) &&
- background_import_still_running
-'
-
-test_expect_success PIPE 'V: checkpoint updates tags after tag' '
- setup_checkpoint_repo &&
- cat >repo/input <<-INPUT_END &&
- tag Vtag
- from refs/heads/base
- tagger $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data 0
-
- INPUT_END
-
- background_import_then_checkpoint "" repo/input &&
- git -C repo show-ref -d Vtag &&
- background_import_still_running
-'
-
-###
-### series W (get-mark and empty orphan commits)
-###
-
-w_input () {
- cat <<-W_INPUT_END
- commit refs/heads/W-branch
- mark :1
- author Full Name <user@company.tld> 1000000000 +0100
- committer Full Name <user@company.tld> 1000000000 +0100
- data 27
- Intentionally empty commit
- LFsget-mark :1
- W_INPUT_END
-}
-
-test_expect_success !MINGW 'W: get-mark & empty orphan commit with no newlines' '
- 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' '
- 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' '
- 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' '
- 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
- )
-'
-
-###
-### series X (other new features)
-###
-
-test_expect_success ICONV 'X: handling encoding' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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
-
- 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 &&
- test_commit test &&
-
- test_commit msg somename content &&
-
- git mv somename othername &&
- NEW_TREE=$(git write-tree) &&
- MSG="$(git log -1 --format=%B HEAD)" &&
- NEW_COMMIT=$(git commit-tree -p HEAD^1 -m "$MSG" $NEW_TREE) &&
- git replace main $NEW_COMMIT &&
-
- echo more >>othername &&
- git add othername &&
- git commit -qm more &&
-
- git fast-export --all >tmp &&
- sed -e s/othername/somename/ tmp >tmp2 &&
- git fast-import --force <tmp2 2>msgs &&
-
- test_grep "dropping.*since it would point to itself" msgs &&
- git show-ref >refs &&
- test_grep ! refs/replace refs
- )
-'
-
-###
-### series Y (submodules and hash algorithms)
-###
-
-cat >Y-sub-input <<\Y_INPUT_END
-blob
-mark :1
-data 4
-foo
-
-reset refs/heads/main
-commit refs/heads/main
-mark :2
-author Full Name <user@company.tld> 1000000000 +0100
-committer Full Name <user@company.tld> 1000000000 +0100
-data 24
-Test submodule commit 1
-M 100644 :1 file
-
-blob
-mark :3
-data 8
-foo
-bar
-
-commit refs/heads/main
-mark :4
-author Full Name <user@company.tld> 1000000001 +0100
-committer Full Name <user@company.tld> 1000000001 +0100
-data 24
-Test submodule commit 2
-from :2
-M 100644 :3 file
-Y_INPUT_END
-
-# Note that the submodule object IDs are intentionally not translated.
-cat >Y-main-input <<\Y_INPUT_END
-blob
-mark :1
-data 4
-foo
-
-reset refs/heads/main
-commit refs/heads/main
-mark :2
-author Full Name <user@company.tld> 2000000000 +0100
-committer Full Name <user@company.tld> 2000000000 +0100
-data 14
-Test commit 1
-M 100644 :1 file
-
-blob
-mark :3
-data 73
-[submodule "sub1"]
- path = sub1
- url = https://void.example.com/main.git
-
-commit refs/heads/main
-mark :4
-author Full Name <user@company.tld> 2000000001 +0100
-committer Full Name <user@company.tld> 2000000001 +0100
-data 14
-Test commit 2
-from :2
-M 100644 :3 .gitmodules
-M 160000 0712c5be7cf681388e355ef47525aaf23aee1a6d sub1
-
-blob
-mark :5
-data 8
-foo
-bar
-
-commit refs/heads/main
-mark :6
-author Full Name <user@company.tld> 2000000002 +0100
-committer Full Name <user@company.tld> 2000000002 +0100
-data 14
-Test commit 3
-from :4
-M 100644 :5 file
-M 160000 ff729f5e62f72c0c3978207d9a80e5f3a65f14d7 sub1
-Y_INPUT_END
-
-cat >Y-marks <<\Y_INPUT_END
-:2 0712c5be7cf681388e355ef47525aaf23aee1a6d
-:4 ff729f5e62f72c0c3978207d9a80e5f3a65f14d7
-Y_INPUT_END
-
-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 &&
- git init sub2 &&
- git -C sub2 fast-import --export-marks=../sub2-marks <../Y-sub-input &&
- git fast-import --rewrite-submodules-from=sub:../Y-marks \
- --rewrite-submodules-to=sub:sub2-marks <../Y-main-input &&
- test "$(git rev-parse main)" = "$(test_oid Ymain)"
- )
-'
-
-test_expect_success 'Y: reference pending tag or commit' '
- test_oid_cache <<-EOF &&
- pending_commit sha1:85b46dd918355ff17b4109ec738723d42f235a04
- pending_commit sha256:17e650f097a4db6fe069c96935360d3ccc9b35c4018728c5f311a4217c2ced3d
- pending_tag sha1:ec6c4db71feb5f66615214dad2324ce030e777a7
- pending_tag sha256:85edc5eac315bc680677b2fc71622bd77476f057eb8dc8ed6a497803a24f1f46
- EOF
-
- test_when_finished "rm -rf reference-pending" &&
- git init reference-pending &&
- (
- cd reference-pending &&
- git fast-import <<-EOF
- commit refs/heads/main
- committer A U Thor <author@example.com> 1712563200 +0000
- data 14
- commit message
- M 644 inline test file
- data 14
- dummy content
-
- tag newtag
- from $(test_oid pending_commit)
- tagger A U Thor <author@example.com> 1712563300 +0000
- data 11
- tag message
- # no emty line after tag data!
- reset refs/heads/other
- from $(test_oid pending_tag)
-
- commit refs/heads/further
- committer A U Thor <author@example.com> 1712563400 +0000
- data 21
- what about 2nd commit
- from $(test_oid pending_commit)
- M 644 inline other test file
- data 19
- more dummy content
-
- done
- EOF
- )
-'
-
test_done
diff --git a/t/t9301-fast-import-notes.sh b/t/t9301-fast-import-notes.sh
index e62173cf1f..5d43a523d0 100755
--- a/t/t9301-fast-import-notes.sh
+++ b/t/t9301-fast-import-notes.sh
@@ -724,4 +724,415 @@ test_expect_success "add notes to $num_commits commits in each of $num_notes_ref
'
+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" &&
+ note1b_data="The second note for the first commit" &&
+ note1c_data="The third note for the first commit" &&
+ note2b_data="The second note for the second commit" &&
+
+ test_tick &&
+ cat >repo/input <<-INPUT_END &&
+ blob
+ mark :2
+ data <<EOF
+ $file2_data
+ EOF
+
+ commit refs/heads/notes-test
+ mark :3
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ first (:3)
+ COMMIT
+
+ M 644 :2 file2
+
+ blob
+ mark :4
+ data $file4_len
+ $file4_data
+ commit refs/heads/notes-test
+ mark :5
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ second (:5)
+ COMMIT
+
+ M 644 :4 file4
+
+ commit refs/heads/notes-test
+ mark :6
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ third (:6)
+ COMMIT
+
+ M 644 inline file5
+ data <<EOF
+ $file5_data
+ EOF
+
+ M 755 inline file6
+ data <<EOF
+ $file6_data
+ EOF
+
+ blob
+ mark :7
+ data <<EOF
+ $note1_data
+ EOF
+
+ blob
+ mark :8
+ data <<EOF
+ $note2_data
+ EOF
+
+ commit refs/notes/foobar
+ mark :9
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ notes (:9)
+ COMMIT
+
+ N :7 :3
+ N :8 :5
+ N inline :6
+ data <<EOF
+ $note3_data
+ EOF
+
+ commit refs/notes/foobar
+ mark :10
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ notes (:10)
+ COMMIT
+
+ N inline :3
+ data <<EOF
+ $note1b_data
+ EOF
+
+ commit refs/notes/foobar2
+ mark :11
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ notes (:11)
+ COMMIT
+
+ N inline :3
+ data <<EOF
+ $note1c_data
+ EOF
+
+ commit refs/notes/foobar
+ mark :12
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ notes (:12)
+ COMMIT
+
+ deleteall
+ N inline :5
+ data <<EOF
+ $note2b_data
+ EOF
+
+ INPUT_END
+
+ 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' '
+ 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 &&
+ (
+ 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
+
+ first (:3)
+ EOF
+ git cat-file commit notes-test~2 | sed 1d >actual &&
+ test_cmp expect actual
+ )
+'
+
+test_expect_success 'Q: verify second commit' '
+ 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
+ )
+'
+
+test_expect_success 'Q: verify third commit' '
+ 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
+ )
+'
+
+test_expect_success 'Q: verify first notes commit' '
+ 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
+ )
+'
+
+test_expect_success 'Q: verify first notes tree' '
+ 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' '
+ 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' '
+ 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' '
+ 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' '
+ 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
+ )
+'
+
+test_expect_success 'Q: verify second notes tree' '
+ 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' '
+ 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' '
+ 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' '
+ 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' '
+ 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
+ )
+'
+
+test_expect_success 'Q: verify third notes tree' '
+ 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' '
+ 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' '
+ 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
+ )
+'
+
+test_expect_success 'Q: verify fourth notes tree' '
+ 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' '
+ 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' '
+ 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
+
+ N inline refs/heads/Q0
+ data <<NOTE
+ some note
+ NOTE
+ EOF
+ test_must_fail git fast-import <input
+ )
+'
+
test_done
diff --git a/t/t9304-fast-import-marks.sh b/t/t9304-fast-import-marks.sh
index 6c50adca00..437f9016fa 100755
--- a/t/t9304-fast-import-marks.sh
+++ b/t/t9304-fast-import-marks.sh
@@ -79,4 +79,397 @@ 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_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ cat >input <<-EOF &&
+ feature export-marks=git.marks
+ blob
+ mark :1
+ data 3
+ hi
+
+ 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' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ 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_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' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ 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
+ 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' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ 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' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ 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' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ rm -f io.marks &&
+
+ 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 &&
+
+ blob=$(echo hi | git hash-object -w --stdin) &&
+
+ echo ":1 $blob" >io.marks &&
+ echo ":1 $blob" >expect &&
+ echo ":2 $blob" >>expect &&
+
+ git fast-import --export-marks=io.marks \
+ --allow-unsafe-features <<-\EOF &&
+ feature import-marks-if-exists=io.marks
+ blob
+ mark :2
+ data 3
+ hi
+
+ EOF
+ test_cmp expect io.marks &&
+
+ echo ":3 $blob" >>expect &&
+
+ 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
+
+ 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: corrupt lines do not mess marks file' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ 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
+ )
+'
+
+create_marks_file () {
+ git fast-import --export-marks="$1" <<-EOF
+ blob
+ mark :1
+ data 4
+ one
+
+ 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' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+ create_marks_file marks.out &&
+
+ 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' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+ create_marks_file marks.out &&
+
+ 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' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+ create_marks_file marks.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' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+ create_marks_file marks.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 'A: export marks with large values' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ test_tick &&
+ mt=$(git hash-object --stdin < /dev/null) &&
+ >input.blob &&
+ >marks.exp &&
+ >tree.exp &&
+
+ 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
+
+ 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 &&
+
+ echo ":$l $mt" >>marks.exp &&
+ echo ":$m $mt" >>marks.exp &&
+ echo ":$n $mt" >>marks.exp &&
+
+ 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 &&
+
+ l=$(($l + $l)) &&
+ m=$(($m + $m)) &&
+ n=$(($l + $n)) &&
+
+ i=$((1 + $i)) || return 1
+ done &&
+
+ 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
+ )
+'
+
test_done
diff --git a/t/t9307-fast-import-validation.sh b/t/t9307-fast-import-validation.sh
new file mode 100755
index 0000000000..e52ae3326f
--- /dev/null
+++ b/t/t9307-fast-import-validation.sh
@@ -0,0 +1,1193 @@
+#!/bin/sh
+
+test_description='git fast-import validation'
+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+
+. ./test-lib.sh
+
+test_expect_success 'B: fail on invalid blob sha1' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+ test_commit base &&
+
+ 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
+
+ from refs/heads/main
+ M 755 $(echo $ZERO_OID | sed -e "s/0$/1/") zero1
+
+ INPUT_END
+
+ test_must_fail git fast-import <input
+ )
+'
+
+test_expect_success 'B: accept branch name "TEMP_TAG"' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+ test_commit new &&
+
+ cat >input <<-INPUT_END &&
+ commit TEMP_TAG
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ tag base
+ COMMIT
+
+ from refs/heads/main
+
+ 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' '
+ 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
+
+ git fast-import <input &&
+ out=$(git fsck) &&
+ echo "$out" &&
+ test -z "$out"
+ )
+'
+
+test_expect_success 'B: reject invalid timezone' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ 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' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ 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' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+ cat >input <<-INPUT_END &&
+ commit refs/heads/empty-committer-2
+ committer <a@b.com> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ empty commit
+ COMMIT
+ INPUT_END
+
+ git fast-import <input &&
+ out=$(git fsck) &&
+ echo "$out" &&
+ test -z "$out"
+ )
+'
+
+test_expect_success 'B: fail on invalid committer (1)' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ 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)' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ 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)' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ 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)' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ 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)' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ 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 ..' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ cat >input <<-INPUT_END &&
+ blob
+ mark :1
+ data <<EOF
+ File contents
+ EOF
+
+ 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 .' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ cat >input <<-INPUT_END &&
+ blob
+ mark :1
+ data <<EOF
+ File contents
+ EOF
+
+ commit refs/heads/badpath
+ committer Name <email> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ Good path
+ COMMIT
+ M 100644 :1 ok-path
+
+ 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:' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ cat >input <<-INPUT_END &&
+ blob
+ mark :1
+ data <<EOF
+ File contents
+ EOF
+
+ 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' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ cat >input <<-INPUT_END &&
+ blob
+ mark :1
+ data <<EOF
+ File contents
+ EOF
+
+ 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' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ cat >input <<-INPUT_END &&
+ blob
+ mark :1
+ data <<EOF
+ File contents
+ EOF
+
+ 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
+ )
+'
+
+test_expect_success 'R: abort on unsupported feature' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ cat >input <<-EOF &&
+ feature no-such-feature-exists
+ EOF
+
+ test_must_fail git fast-import <input
+ )
+'
+
+test_expect_success 'R: supported feature is accepted' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ cat >input <<-EOF &&
+ feature date-format=now
+ EOF
+
+ git fast-import <input
+ )
+'
+
+test_expect_success 'R: abort on receiving feature after data command' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ 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' '
+ 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' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ >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' '
+ 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: feature ls supported' '
+ 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' '
+ 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_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 'R: die on unknown option' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ 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_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' '
+ 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' '
+ 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' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ cat >input <<-EOF &&
+ option non-existing-vcs non-existing-option
+ EOF
+
+ git fast-import <input
+ )
+'
+
+#
+# Make sure missing spaces and EOLs after mark references
+# cause errors.
+#
+# Setup:
+#
+# 1--2--4
+# \ /
+# -3-
+#
+# commit marks: 301, 302, 303, 304
+# blob marks: 403, 404, resp.
+# note mark: 202
+#
+# The error message when a space is missing not at the
+# end of the line is:
+#
+# missing space after ..
+#
+# or when extra characters come after the mark at the end
+# of the line:
+#
+# garbage after ..
+#
+# or when the dataref is neither "inline " or a known SHA1,
+#
+# invalid dataref ..
+#
+setup_marks_repo () {
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ test_tick &&
+
+ cat >repo/input <<-INPUT_END &&
+ commit refs/heads/S
+ mark :301
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ commit 1
+ COMMIT
+ M 100644 inline hello.c
+ data <<BLOB
+ blob 1
+ BLOB
+
+ commit refs/heads/S
+ mark :302
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ commit 2
+ COMMIT
+ from :301
+ M 100644 inline hello.c
+ data <<BLOB
+ blob 2
+ BLOB
+
+ blob
+ mark :403
+ data <<BLOB
+ blob 3
+ BLOB
+
+ blob
+ mark :202
+ data <<BLOB
+ note 2
+ BLOB
+ INPUT_END
+
+ git -C repo fast-import --export-marks=marks <repo/input
+}
+
+#
+# filemodify, three datarefs
+#
+test_expect_success 'S: filemodify with garbage after mark must fail' '
+ 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' '
+ 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' '
+ 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' '
+ 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' '
+ 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' '
+ 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' '
+ 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' '
+ 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
+
+ test_grep "after mark" err
+ )
+'
+
+
+#
+# merge
+#
+test_expect_success 'S: merge with garbage after mark must fail' '
+ 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' '
+ 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' '
+ 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' '
+ 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' '
+ 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
+ )
+'
+
+#
+# Path parsing
+#
+# There are two sorts of ways a path can be parsed, depending on whether it is
+# the last field on the line. Additionally, ls without a <dataref> has a special
+# case. Test every occurrence of <path> in the grammar against every error case.
+# Paths for the root (empty strings) are tested elsewhere.
+#
+
+#
+# Valid paths at the end of a line: filemodify, filedelete, filecopy (dest),
+# filerename (dest), and ls.
+#
+# commit :301 from root -- modify hello.c (for setup)
+# commit :302 from :301 -- modify $path
+# commit :303 from :302 -- delete $path
+# commit :304 from :301 -- copy hello.c $path
+# commit :305 from :301 -- rename hello.c $path
+# ls :305 $path
+#
+test_path_eol_success () {
+ local test="$1" path="$2" unquoted_path="$3"
+ test_expect_success "S: paths at EOL with $test must work" '
+ test_when_finished "git branch -D S-path-eol" &&
+
+ git -c core.protectNTFS=false fast-import --export-marks=marks.out <<-EOF >out 2>err &&
+ blob
+ mark :401
+ data <<BLOB
+ hello world
+ BLOB
+
+ blob
+ mark :402
+ data <<BLOB
+ hallo welt
+ BLOB
+
+ commit refs/heads/S-path-eol
+ mark :301
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ initial commit
+ COMMIT
+ M 100644 :401 hello.c
+
+ commit refs/heads/S-path-eol
+ mark :302
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ commit filemodify
+ COMMIT
+ from :301
+ M 100644 :402 $path
+
+ commit refs/heads/S-path-eol
+ mark :303
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ commit filedelete
+ COMMIT
+ from :302
+ D $path
+
+ commit refs/heads/S-path-eol
+ mark :304
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ commit filecopy dest
+ COMMIT
+ from :301
+ C hello.c $path
+
+ commit refs/heads/S-path-eol
+ mark :305
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ commit filerename dest
+ COMMIT
+ from :301
+ R hello.c $path
+
+ ls :305 $path
+ EOF
+
+ commit_m=$(grep :302 marks.out | cut -d\ -f2) &&
+ commit_d=$(grep :303 marks.out | cut -d\ -f2) &&
+ commit_c=$(grep :304 marks.out | cut -d\ -f2) &&
+ commit_r=$(grep :305 marks.out | cut -d\ -f2) &&
+ blob1=$(grep :401 marks.out | cut -d\ -f2) &&
+ blob2=$(grep :402 marks.out | cut -d\ -f2) &&
+
+ (
+ printf "100644 blob $blob2\t$unquoted_path\n" &&
+ printf "100644 blob $blob1\thello.c\n"
+ ) | sort >tree_m.exp &&
+ git ls-tree $commit_m | sort >tree_m.out &&
+ test_cmp tree_m.exp tree_m.out &&
+
+ printf "100644 blob $blob1\thello.c\n" >tree_d.exp &&
+ git ls-tree $commit_d >tree_d.out &&
+ test_cmp tree_d.exp tree_d.out &&
+
+ (
+ printf "100644 blob $blob1\t$unquoted_path\n" &&
+ printf "100644 blob $blob1\thello.c\n"
+ ) | sort >tree_c.exp &&
+ git ls-tree $commit_c | sort >tree_c.out &&
+ test_cmp tree_c.exp tree_c.out &&
+
+ printf "100644 blob $blob1\t$unquoted_path\n" >tree_r.exp &&
+ git ls-tree $commit_r >tree_r.out &&
+ test_cmp tree_r.exp tree_r.out &&
+
+ test_cmp out tree_r.exp
+ '
+}
+
+test_path_eol_success 'quoted spaces' '" hello world.c "' ' hello world.c '
+test_path_eol_success 'unquoted spaces' ' hello world.c ' ' hello world.c '
+test_path_eol_success 'octal escapes' '"\150\151\056\143"' 'hi.c'
+
+#
+# Valid paths before a space: filecopy (source) and filerename (source).
+#
+# commit :301 from root -- modify $path (for setup)
+# commit :302 from :301 -- copy $path hello2.c
+# commit :303 from :301 -- rename $path hello2.c
+#
+test_path_space_success () {
+ local test="$1" path="$2" unquoted_path="$3"
+ test_expect_success "S: paths before space with $test must work" '
+ test_when_finished "git branch -D S-path-space" &&
+
+ git -c core.protectNTFS=false fast-import --export-marks=marks.out <<-EOF 2>err &&
+ blob
+ mark :401
+ data <<BLOB
+ hello world
+ BLOB
+
+ commit refs/heads/S-path-space
+ mark :301
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ initial commit
+ COMMIT
+ M 100644 :401 $path
+
+ commit refs/heads/S-path-space
+ mark :302
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ commit filecopy source
+ COMMIT
+ from :301
+ C $path hello2.c
+
+ commit refs/heads/S-path-space
+ mark :303
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ commit filerename source
+ COMMIT
+ from :301
+ R $path hello2.c
+
+ EOF
+
+ commit_c=$(grep :302 marks.out | cut -d\ -f2) &&
+ commit_r=$(grep :303 marks.out | cut -d\ -f2) &&
+ blob=$(grep :401 marks.out | cut -d\ -f2) &&
+
+ (
+ printf "100644 blob $blob\t$unquoted_path\n" &&
+ printf "100644 blob $blob\thello2.c\n"
+ ) | sort >tree_c.exp &&
+ git ls-tree $commit_c | sort >tree_c.out &&
+ test_cmp tree_c.exp tree_c.out &&
+
+ printf "100644 blob $blob\thello2.c\n" >tree_r.exp &&
+ git ls-tree $commit_r >tree_r.out &&
+ test_cmp tree_r.exp tree_r.out
+ '
+}
+
+test_path_space_success 'quoted spaces' '" hello world.c "' ' hello world.c '
+test_path_space_success 'no unquoted spaces' 'hello_world.c' 'hello_world.c'
+test_path_space_success 'octal escapes' '"\150\151\056\143"' 'hi.c'
+
+#
+# Test a single commit change with an invalid path. Run it with all occurrences
+# of <path> in the grammar against all error kinds.
+#
+test_path_fail () {
+ local change="$1" what="$2" prefix="$3" path="$4" suffix="$5" err_grep="$6"
+ test_expect_success "S: $change with $what must fail" '
+ test_must_fail git fast-import <<-EOF 2>err &&
+ blob
+ mark :1
+ data <<BLOB
+ hello world
+ BLOB
+
+ commit refs/heads/S-path-fail
+ mark :2
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ commit setup
+ COMMIT
+ M 100644 :1 hello.c
+
+ commit refs/heads/S-path-fail
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ commit with bad path
+ COMMIT
+ from :2
+ $prefix$path$suffix
+ EOF
+
+ test_grep "$err_grep" err
+ '
+}
+
+test_path_base_fail () {
+ local change="$1" prefix="$2" field="$3" suffix="$4"
+ test_path_fail "$change" 'unclosed " in '"$field" "$prefix" '"hello.c' "$suffix" "invalid $field"
+ test_path_fail "$change" "invalid escape in quoted $field" "$prefix" '"hello\xff"' "$suffix" "invalid $field"
+ test_path_fail "$change" "escaped NUL in quoted $field" "$prefix" '"hello\000"' "$suffix" "NUL in $field"
+}
+test_path_eol_quoted_fail () {
+ local change="$1" prefix="$2" field="$3"
+ test_path_base_fail "$change" "$prefix" "$field" ''
+ test_path_fail "$change" "garbage after quoted $field" "$prefix" '"hello.c"' 'x' "garbage after $field"
+ test_path_fail "$change" "space after quoted $field" "$prefix" '"hello.c"' ' ' "garbage after $field"
+}
+test_path_eol_fail () {
+ local change="$1" prefix="$2" field="$3"
+ test_path_eol_quoted_fail "$change" "$prefix" "$field"
+}
+test_path_space_fail () {
+ local change="$1" prefix="$2" field="$3"
+ test_path_base_fail "$change" "$prefix" "$field" ' world.c'
+ test_path_fail "$change" "missing space after quoted $field" "$prefix" '"hello.c"' 'x world.c' "missing space after $field"
+ test_path_fail "$change" "missing space after unquoted $field" "$prefix" 'hello.c' '' "missing space after $field"
+}
+
+test_path_eol_fail filemodify 'M 100644 :1 ' path
+test_path_eol_fail filedelete 'D ' path
+test_path_space_fail filecopy 'C ' source
+test_path_eol_fail filecopy 'C hello.c ' dest
+test_path_space_fail filerename 'R ' source
+test_path_eol_fail filerename 'R hello.c ' dest
+test_path_eol_fail 'ls (in commit)' 'ls :2 ' path
+
+# When 'ls' has no <dataref>, the <path> must be quoted.
+test_path_eol_quoted_fail 'ls (without dataref in commit)' 'ls ' path
+
+test_expect_success 'E: rfc2822 date, --date-format=raw' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+ test_commit one &&
+
+ 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
+
+ from refs/heads/main^0
+
+ INPUT_END
+
+ test_must_fail git fast-import --date-format=raw <input
+ )
+'
+
+test_expect_success 'E: rfc2822 date, --date-format=rfc2822' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+ test_commit one &&
+
+ 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
+
+ from refs/heads/main^0
+
+ 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
+ )
+'
+
+test_done
diff --git a/t/t9308-fast-import-stream.sh b/t/t9308-fast-import-stream.sh
new file mode 100755
index 0000000000..f8743cbfa4
--- /dev/null
+++ b/t/t9308-fast-import-stream.sh
@@ -0,0 +1,822 @@
+#!/bin/sh
+
+test_description='test fast-import stream handling and output'
+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+
+. ./test-lib.sh
+
+test_expect_success 'empty stream succeeds' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ git fast-import </dev/null
+ )
+'
+
+test_expect_success 'truncated stream complains' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ echo "tag foo" | test_must_fail git fast-import
+ )
+'
+
+test_expect_success !MINGW 'R: print old blob' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ 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' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ 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' '
+ 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' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ 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' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ 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
+ )
+'
+
+setup_big_file () {
+ (
+ echo "the quick brown fox jumps over the lazy dog" >big &&
+ for i in 1 2 3
+ do
+ cat big big big big >bigger &&
+ cat bigger bigger bigger bigger >big ||
+ exit
+ done
+ )
+}
+
+test_expect_success 'R: print two blobs to stdout' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ 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
+
+ ${blob2} blob 6
+ hello
+
+ 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' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ setup_big_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 &&
+ (
+ 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' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ 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
+
+ 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' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ 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
+
+ to_get=$(
+ echo "A blob from _within_ the commit." |
+ git hash-object --stdin
+ ) &&
+ echo "cat-blob $to_get" &&
+
+ 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' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ cat >input <<-EOF &&
+ option git quiet
+ blob
+ data 3
+ hi
+
+ EOF
+
+ git fast-import 2>output <input &&
+ test_must_be_empty output
+ )
+'
+
+test_expect_success 'R: feature done means terminating "done" is mandatory' '
+ 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' '
+ 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' '
+ 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
+ )
+'
+
+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
+
+ 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
+
+ INPUT_END
+}
+
+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' '
+ setup_import_repo &&
+ (
+ cd repo &&
+
+ 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
+
+ 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 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' '
+ setup_import_repo &&
+ (
+ cd repo &&
+ git repack -a -d &&
+
+ 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
+
+ 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' '
+ 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
+ )
+'
+
+##
+## R: very large blobs
+##
+test_expect_success 'R: blob bigger than threshold' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ 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
+ )
+'
+
+w_input () {
+ cat <<-W_INPUT_END
+ commit refs/heads/W-branch
+ mark :1
+ author Full Name <user@company.tld> 1000000000 +0100
+ committer Full Name <user@company.tld> 1000000000 +0100
+ data 27
+ Intentionally empty commit
+ LFsget-mark :1
+ W_INPUT_END
+}
+
+test_expect_success !MINGW 'W: get-mark & empty orphan commit with no newlines' '
+ 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' '
+ 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' '
+ 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' '
+ 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
+ )
+'
+
+test_expect_success ICONV 'X: handling encoding' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ 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
+
+ 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 &&
+ test_commit test &&
+
+ test_commit msg somename content &&
+
+ git mv somename othername &&
+ NEW_TREE=$(git write-tree) &&
+ MSG="$(git log -1 --format=%B HEAD)" &&
+ NEW_COMMIT=$(git commit-tree -p HEAD^1 -m "$MSG" $NEW_TREE) &&
+ git replace main $NEW_COMMIT &&
+
+ echo more >>othername &&
+ git add othername &&
+ git commit -qm more &&
+
+ git fast-export --all >tmp &&
+ sed -e s/othername/somename/ tmp >tmp2 &&
+ git fast-import --force <tmp2 2>msgs &&
+
+ test_grep "dropping.*since it would point to itself" msgs &&
+ git show-ref >refs &&
+ test_grep ! refs/replace refs
+ )
+'
+
+for root in '""' ''
+do
+ test_expect_success "T: ls root ($root) tree" '
+ 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 'I: export-pack-edges' '
+ test_when_finished "rm -rf repo" &&
+ git init -b main repo &&
+ (
+ cd repo &&
+ test_commit one &&
+
+ 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
+
+ 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_done
diff --git a/t/t9309-fast-import-checkpoint.sh b/t/t9309-fast-import-checkpoint.sh
new file mode 100755
index 0000000000..64674dcf83
--- /dev/null
+++ b/t/t9309-fast-import-checkpoint.sh
@@ -0,0 +1,188 @@
+#!/bin/sh
+
+test_description='test fast-import checkpoint handling'
+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+
+. ./test-lib.sh
+
+# The commands in input_file should not produce any output on the file
+# descriptor set with --cat-blob-fd (or stdout if unspecified).
+#
+# To make sure you're observing the side effects of checkpoint *before*
+# fast-import terminates (and thus writes out its state), check that the
+# fast-import process is still running using background_import_still_running
+# *after* evaluating the test conditions.
+background_import_then_checkpoint () {
+ options=$1
+ input_file=$2
+
+ mkfifo V.input
+ exec 8<>V.input
+ rm V.input
+
+ mkfifo V.output
+ exec 9<>V.output
+ rm V.output
+
+ (
+ git -C repo fast-import $options <&8 >&9 &
+ echo $! >&9
+ wait $!
+ echo >&2 "background fast-import terminated too early with exit code $?"
+ # Un-block the read loop in the main shell process.
+ echo >&9 UNEXPECTED
+ ) &
+ sh_pid=$!
+ read fi_pid <&9
+ # We don't mind if fast-import has already died by the time the test
+ # ends.
+ test_when_finished "
+ exec 8>&-; exec 9>&-;
+ kill $sh_pid && wait $sh_pid
+ kill $fi_pid && wait $fi_pid
+ true"
+
+ # Start in the background to ensure we adhere strictly to (blocking)
+ # pipes writing sequence. We want to assume that the write below could
+ # block, e.g. if fast-import blocks writing its own output to &9
+ # because there is no reader on &9 yet.
+ (
+ cat "$input_file"
+ echo "checkpoint"
+ echo "progress checkpoint"
+ ) >&8 &
+
+ last=$(
+ while read output <&9
+ do
+ if test "$output" = "progress checkpoint" || test "$output" = "UNEXPECTED"
+ then
+ echo "$output"
+ break
+ else
+ # otherwise ignore cruft
+ echo >&2 "cruft: $output"
+ fi
+ done
+ )
+
+ test "$last" = "progress checkpoint"
+}
+
+background_import_still_running () {
+ if ! kill -0 "$fi_pid"
+ then
+ echo >&2 "background fast-import terminated too early"
+ false
+ 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' '
+ setup_checkpoint_repo &&
+ cat >repo/input <<-INPUT_END &&
+ progress foo
+ progress bar
+
+ INPUT_END
+
+ background_import_then_checkpoint "" repo/input &&
+ background_import_still_running
+'
+
+test_expect_success PIPE 'V: checkpoint updates refs after reset' '
+ setup_checkpoint_repo &&
+ cat >repo/input <<-\INPUT_END &&
+ reset refs/heads/V
+ from refs/heads/base
+
+ INPUT_END
+
+ 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' '
+ 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/base
+
+ INPUT_END
+
+ background_import_then_checkpoint "--export-marks=marks.actual" repo/input &&
+ (
+ cd repo &&
+ echo ":1 $(git rev-parse --verify V)" >marks.expected &&
+
+ 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)' '
+ 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/base
+
+ INPUT_END
+
+ background_import_then_checkpoint "--export-marks=marks.actual" repo/input &&
+ (
+ cd repo &&
+ 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
+ ) &&
+ background_import_still_running
+'
+
+test_expect_success PIPE 'V: checkpoint updates tags after tag' '
+ setup_checkpoint_repo &&
+ cat >repo/input <<-INPUT_END &&
+ tag Vtag
+ from refs/heads/base
+ tagger $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data 0
+
+ INPUT_END
+
+ background_import_then_checkpoint "" repo/input &&
+ git -C repo show-ref -d Vtag &&
+ background_import_still_running
+'
+
+test_done
diff --git a/t/t9310-fast-import-submodule.sh b/t/t9310-fast-import-submodule.sh
new file mode 100755
index 0000000000..6e7dbda9f9
--- /dev/null
+++ b/t/t9310-fast-import-submodule.sh
@@ -0,0 +1,341 @@
+#!/bin/sh
+
+test_description='test fast-import with submodules and gitlinks'
+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+
+. ./test-lib.sh
+
+setup_gitlinks_repo () {
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ test_commit -C repo base &&
+ (
+ 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' '
+ setup_gitlinks_repo &&
+ (
+ cd repo &&
+
+ SUBLAST=$(git rev-parse --verify sub) &&
+ SUBPREV=$(git rev-parse --verify sub^) &&
+
+ cat >input <<-INPUT_END &&
+ blob
+ mark :1
+ data <<DATAEND
+ [submodule "sub"]
+ path = sub
+ url = "$(pwd)/sub"
+ DATAEND
+
+ 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
+
+ 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
+
+ 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' '
+ setup_gitlinks_repo &&
+ (
+ cd repo &&
+
+ 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
+
+ from refs/heads/subuse1
+ M 160000 inline sub
+ data <<DATA
+ $SUBPREV
+ DATA
+
+ INPUT_END
+
+ test_must_fail git fast-import <input
+ )
+'
+
+test_expect_success 'P: fail on blob mark in gitlink' '
+ setup_gitlinks_repo &&
+ (
+ cd repo &&
+
+ SUBPREV=$(git rev-parse --verify sub^) &&
+ test_tick &&
+ cat >input <<-INPUT_END &&
+ blob
+ mark :1
+ data <<DATA
+ $SUBPREV
+ DATA
+
+ commit refs/heads/subuse3
+ mark :2
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ corrupt
+ COMMIT
+
+ from refs/heads/subuse1
+ M 160000 :1 sub
+
+ INPUT_END
+
+ test_must_fail git fast-import <input
+ )
+'
+
+cat >Y-sub-input <<\Y_INPUT_END
+blob
+mark :1
+data 4
+foo
+
+reset refs/heads/main
+commit refs/heads/main
+mark :2
+author Full Name <user@company.tld> 1000000000 +0100
+committer Full Name <user@company.tld> 1000000000 +0100
+data 24
+Test submodule commit 1
+M 100644 :1 file
+
+blob
+mark :3
+data 8
+foo
+bar
+
+commit refs/heads/main
+mark :4
+author Full Name <user@company.tld> 1000000001 +0100
+committer Full Name <user@company.tld> 1000000001 +0100
+data 24
+Test submodule commit 2
+from :2
+M 100644 :3 file
+Y_INPUT_END
+
+# Note that the submodule object IDs are intentionally not translated.
+cat >Y-main-input <<\Y_INPUT_END
+blob
+mark :1
+data 4
+foo
+
+reset refs/heads/main
+commit refs/heads/main
+mark :2
+author Full Name <user@company.tld> 2000000000 +0100
+committer Full Name <user@company.tld> 2000000000 +0100
+data 14
+Test commit 1
+M 100644 :1 file
+
+blob
+mark :3
+data 73
+[submodule "sub1"]
+ path = sub1
+ url = https://void.example.com/main.git
+
+commit refs/heads/main
+mark :4
+author Full Name <user@company.tld> 2000000001 +0100
+committer Full Name <user@company.tld> 2000000001 +0100
+data 14
+Test commit 2
+from :2
+M 100644 :3 .gitmodules
+M 160000 0712c5be7cf681388e355ef47525aaf23aee1a6d sub1
+
+blob
+mark :5
+data 8
+foo
+bar
+
+commit refs/heads/main
+mark :6
+author Full Name <user@company.tld> 2000000002 +0100
+committer Full Name <user@company.tld> 2000000002 +0100
+data 14
+Test commit 3
+from :4
+M 100644 :5 file
+M 160000 ff729f5e62f72c0c3978207d9a80e5f3a65f14d7 sub1
+Y_INPUT_END
+
+cat >Y-marks <<\Y_INPUT_END
+:2 0712c5be7cf681388e355ef47525aaf23aee1a6d
+:4 ff729f5e62f72c0c3978207d9a80e5f3a65f14d7
+Y_INPUT_END
+
+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 &&
+ git init sub2 &&
+ git -C sub2 fast-import --export-marks=../sub2-marks <../Y-sub-input &&
+ git fast-import --rewrite-submodules-from=sub:../Y-marks \
+ --rewrite-submodules-to=sub:sub2-marks <../Y-main-input &&
+ test "$(git rev-parse main)" = "$(test_oid Ymain)"
+ )
+'
+
+test_expect_success 'Y: reference pending tag or commit' '
+ test_oid_cache <<-EOF &&
+ pending_commit sha1:85b46dd918355ff17b4109ec738723d42f235a04
+ pending_commit sha256:17e650f097a4db6fe069c96935360d3ccc9b35c4018728c5f311a4217c2ced3d
+ pending_tag sha1:ec6c4db71feb5f66615214dad2324ce030e777a7
+ pending_tag sha256:85edc5eac315bc680677b2fc71622bd77476f057eb8dc8ed6a497803a24f1f46
+ EOF
+
+ test_when_finished "rm -rf reference-pending" &&
+ git init reference-pending &&
+ (
+ cd reference-pending &&
+ git fast-import <<-EOF
+ commit refs/heads/main
+ committer A U Thor <author@example.com> 1712563200 +0000
+ data 14
+ commit message
+ M 644 inline test file
+ data 14
+ dummy content
+
+ tag newtag
+ from $(test_oid pending_commit)
+ tagger A U Thor <author@example.com> 1712563300 +0000
+ data 11
+ tag message
+ # no emty line after tag data!
+ reset refs/heads/other
+ from $(test_oid pending_tag)
+
+ commit refs/heads/further
+ committer A U Thor <author@example.com> 1712563400 +0000
+ data 21
+ what about 2nd commit
+ from $(test_oid pending_commit)
+ M 644 inline other test file
+ data 19
+ more dummy content
+
+ done
+ EOF
+ )
+'
+
+test_done
diff --git a/t/t9311-fast-import-refs.sh b/t/t9311-fast-import-refs.sh
new file mode 100755
index 0000000000..2bb8ac1d46
--- /dev/null
+++ b/t/t9311-fast-import-refs.sh
@@ -0,0 +1,194 @@
+#!/bin/sh
+
+test_description='test fast-import ref updates'
+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+
+. ./test-lib.sh
+
+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' '
+ 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/main~1
+
+ reset refs/heads/other
+ from refs/heads/main
+
+ INPUT_END
+
+ test_must_fail git -c fastimport.unpackLimit=0 fast-import <input &&
+ # branch must remain unaffected
+ test $old_branch = $(git rev-parse --verify main^0) &&
+
+ for p in .git/objects/pack/*.pack
+ do
+ git verify-pack "$p" || return 1
+ done &&
+
+ 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
+ )
+'
+
+test_expect_success 'G: non-fast-forward update forced' '
+ 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/main~1
+
+ 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}) &&
+
+ for p in .git/objects/pack/*.pack
+ do
+ git verify-pack "$p" || return 1
+ done
+ )
+'
+
+test_expect_success 'J: reset existing branch creates empty 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/main
+
+ reset refs/heads/J
+
+ 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 &&
+ # 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' '
+ 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
+ )
+'
+
+test_expect_success 'K: reinit branch with from' '
+ 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/main
+
+ commit refs/heads/K
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ redo K
+ COMMIT
+
+ from refs/heads/main^1
+
+ INPUT_END
+ git fast-import <input &&
+ # K^1 = main^1
+ test $(git rev-parse --verify main^1) \
+ = $(git rev-parse --verify K^1)
+ )
+'
+
+test_expect_success 'T: delete branch' '
+ 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' '
+ 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
+ )
+'
+
+test_done
--
2.56.GIT
^ permalink raw reply related [flat|nested] 45+ messages in thread* [PATCH 20/20] t93xx: drop the series letter from the moved test names
2026-11-10 11:49 [PATCH 00/20] t9300: group and move tests to other files Karthik Nayak
` (18 preceding siblings ...)
2026-11-10 11:50 ` [PATCH 19/20] t9300: move self-contained tests into dedicated files Karthik Nayak
@ 2026-11-10 11:50 ` Karthik Nayak
2026-11-10 16:45 ` [PATCH 00/20] t9300: group and move tests to other files Junio C Hamano
2026-11-12 17:34 ` [PATCH v2 " Karthik Nayak
21 siblings, 0 replies; 45+ messages in thread
From: Karthik Nayak @ 2026-11-10 11:50 UTC (permalink / raw)
To: git; +Cc: Karthik Nayak
In 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.
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
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(-)
diff --git a/t/t9301-fast-import-notes.sh b/t/t9301-fast-import-notes.sh
index 5d43a523d0..89078b6527 100755
--- a/t/t9301-fast-import-notes.sh
+++ b/t/t9301-fast-import-notes.sh
@@ -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 &&
(
diff --git a/t/t9304-fast-import-marks.sh b/t/t9304-fast-import-marks.sh
index 437f9016fa..57050dcfe4 100755
--- a/t/t9304-fast-import-marks.sh
+++ b/t/t9304-fast-import-marks.sh
@@ -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 &&
(
diff --git a/t/t9307-fast-import-validation.sh b/t/t9307-fast-import-validation.sh
index e52ae3326f..ec551e2487 100755
--- a/t/t9307-fast-import-validation.sh
+++ b/t/t9307-fast-import-validation.sh
@@ -6,7 +6,7 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
-test_expect_success 'B: fail on invalid blob sha1' '
+test_expect_success 'fail on invalid blob sha1' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -31,7 +31,7 @@ test_expect_success 'B: fail on invalid blob sha1' '
)
'
-test_expect_success 'B: accept branch name "TEMP_TAG"' '
+test_expect_success 'accept branch name "TEMP_TAG"' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -55,7 +55,7 @@ test_expect_success 'B: accept branch name "TEMP_TAG"' '
)
'
-test_expect_success 'B: accept empty committer' '
+test_expect_success 'accept empty committer' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -75,7 +75,7 @@ test_expect_success 'B: accept empty committer' '
)
'
-test_expect_success 'B: reject invalid timezone' '
+test_expect_success 'reject invalid timezone' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -93,7 +93,7 @@ test_expect_success 'B: reject invalid timezone' '
)
'
-test_expect_success 'B: accept invalid timezone with raw-permissive' '
+test_expect_success 'accept invalid timezone with raw-permissive' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -113,7 +113,7 @@ test_expect_success 'B: accept invalid timezone with raw-permissive' '
)
'
-test_expect_success 'B: accept and fixup committer with no name' '
+test_expect_success 'accept and fixup committer with no name' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -133,7 +133,7 @@ test_expect_success 'B: accept and fixup committer with no name' '
)
'
-test_expect_success 'B: fail on invalid committer (1)' '
+test_expect_success 'fail on invalid committer (1)' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -151,7 +151,7 @@ test_expect_success 'B: fail on invalid committer (1)' '
)
'
-test_expect_success 'B: fail on invalid committer (2)' '
+test_expect_success 'fail on invalid committer (2)' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -169,7 +169,7 @@ test_expect_success 'B: fail on invalid committer (2)' '
)
'
-test_expect_success 'B: fail on invalid committer (3)' '
+test_expect_success 'fail on invalid committer (3)' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -187,7 +187,7 @@ test_expect_success 'B: fail on invalid committer (3)' '
)
'
-test_expect_success 'B: fail on invalid committer (4)' '
+test_expect_success 'fail on invalid committer (4)' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -205,7 +205,7 @@ test_expect_success 'B: fail on invalid committer (4)' '
)
'
-test_expect_success 'B: fail on invalid committer (5)' '
+test_expect_success 'fail on invalid committer (5)' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -223,7 +223,7 @@ test_expect_success 'B: fail on invalid committer (5)' '
)
'
-test_expect_success 'B: fail on invalid file path of ..' '
+test_expect_success 'fail on invalid file path of ..' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -248,7 +248,7 @@ test_expect_success 'B: fail on invalid file path of ..' '
)
'
-test_expect_success 'B: fail on invalid file path of .' '
+test_expect_success 'fail on invalid file path of .' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -280,7 +280,7 @@ test_expect_success 'B: fail on invalid file path of .' '
)
'
-test_expect_success WINDOWS 'B: fail on invalid file path of C:' '
+test_expect_success WINDOWS 'fail on invalid file path of C:' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -305,7 +305,7 @@ test_expect_success WINDOWS 'B: fail on invalid file path of C:' '
)
'
-test_expect_success 'B: fail on invalid file path of .git' '
+test_expect_success 'fail on invalid file path of .git' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -330,7 +330,7 @@ test_expect_success 'B: fail on invalid file path of .git' '
)
'
-test_expect_success 'B: fail on invalid file path of .gitmodules' '
+test_expect_success 'fail on invalid file path of .gitmodules' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -355,7 +355,7 @@ test_expect_success 'B: fail on invalid file path of .gitmodules' '
)
'
-test_expect_success 'R: abort on unsupported feature' '
+test_expect_success 'abort on unsupported feature' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -369,7 +369,7 @@ test_expect_success 'R: abort on unsupported feature' '
)
'
-test_expect_success 'R: supported feature is accepted' '
+test_expect_success 'supported feature is accepted' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -383,7 +383,7 @@ test_expect_success 'R: supported feature is accepted' '
)
'
-test_expect_success 'R: abort on receiving feature after data command' '
+test_expect_success 'abort on receiving feature after data command' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -400,7 +400,7 @@ test_expect_success 'R: abort on receiving feature after data command' '
)
'
-test_expect_success 'R: import-marks features forbidden by default' '
+test_expect_success 'import-marks features forbidden by default' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -414,7 +414,7 @@ test_expect_success 'R: import-marks features forbidden by default' '
)
'
-test_expect_success 'R: only one import-marks feature allowed per stream' '
+test_expect_success 'only one import-marks feature allowed per stream' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -431,7 +431,7 @@ test_expect_success 'R: only one import-marks feature allowed per stream' '
)
'
-test_expect_success 'R: export-marks feature forbidden by default' '
+test_expect_success 'export-marks feature forbidden by default' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -442,7 +442,7 @@ test_expect_success 'R: export-marks feature forbidden by default' '
)
'
-test_expect_success 'R: feature ls supported' '
+test_expect_success 'feature ls supported' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -453,7 +453,7 @@ test_expect_success 'R: feature ls supported' '
)
'
-test_expect_success 'R: feature cat-blob supported' '
+test_expect_success 'feature cat-blob supported' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -464,7 +464,7 @@ test_expect_success 'R: feature cat-blob supported' '
)
'
-test_expect_success 'R: cat-blob-fd must be a nonnegative integer' '
+test_expect_success 'cat-blob-fd must be a nonnegative integer' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -474,7 +474,7 @@ test_expect_success 'R: cat-blob-fd must be a nonnegative integer' '
)
'
-test_expect_success 'R: die on unknown option' '
+test_expect_success 'die on unknown option' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -488,7 +488,7 @@ test_expect_success 'R: die on unknown option' '
)
'
-test_expect_success 'R: unknown commandline options are rejected' '\
+test_expect_success 'unknown commandline options are rejected' '\
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -498,7 +498,7 @@ test_expect_success 'R: unknown commandline options are rejected' '\
)
'
-test_expect_success 'R: feature-only names are rejected on the command line' '
+test_expect_success 'feature-only names are rejected on the command line' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -511,7 +511,7 @@ test_expect_success 'R: feature-only names are rejected on the command line' '
)
'
-test_expect_success 'R: die on invalid option argument' '
+test_expect_success 'die on invalid option argument' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -525,7 +525,7 @@ test_expect_success 'R: die on invalid option argument' '
)
'
-test_expect_success 'R: ignore non-git options' '
+test_expect_success 'ignore non-git options' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -615,7 +615,7 @@ setup_marks_repo () {
#
# filemodify, three datarefs
#
-test_expect_success 'S: filemodify with garbage after mark must fail' '
+test_expect_success 'filemodify with garbage after mark must fail' '
setup_marks_repo &&
(
cd repo &&
@@ -633,7 +633,7 @@ test_expect_success 'S: filemodify with garbage after mark must fail' '
'
# inline is misspelled; fast-import thinks it is some unknown dataref
-test_expect_success 'S: filemodify with garbage after inline must fail' '
+test_expect_success 'filemodify with garbage after inline must fail' '
setup_marks_repo &&
(
cd repo &&
@@ -653,7 +653,7 @@ test_expect_success 'S: filemodify with garbage after inline must fail' '
)
'
-test_expect_success 'S: filemodify with garbage after sha1 must fail' '
+test_expect_success 'filemodify with garbage after sha1 must fail' '
setup_marks_repo &&
(
cd repo &&
@@ -674,7 +674,7 @@ test_expect_success 'S: filemodify with garbage after sha1 must fail' '
#
# notemodify, three ways to say dataref
#
-test_expect_success 'S: notemodify with garbage after mark dataref must fail' '
+test_expect_success 'notemodify with garbage after mark dataref must fail' '
setup_marks_repo &&
(
cd repo &&
@@ -691,7 +691,7 @@ test_expect_success 'S: notemodify with garbage after mark dataref must fail' '
)
'
-test_expect_success 'S: notemodify with garbage after inline dataref must fail' '
+test_expect_success 'notemodify with garbage after inline dataref must fail' '
setup_marks_repo &&
(
cd repo &&
@@ -711,7 +711,7 @@ test_expect_success 'S: notemodify with garbage after inline dataref must fail'
)
'
-test_expect_success 'S: notemodify with garbage after sha1 dataref must fail' '
+test_expect_success 'notemodify with garbage after sha1 dataref must fail' '
setup_marks_repo &&
(
cd repo &&
@@ -732,7 +732,7 @@ test_expect_success 'S: notemodify with garbage after sha1 dataref must fail' '
#
# notemodify, mark in commit-ish
#
-test_expect_success 'S: notemodify with garbage after mark commit-ish must fail' '
+test_expect_success 'notemodify with garbage after mark commit-ish must fail' '
setup_marks_repo &&
(
cd repo &&
@@ -752,7 +752,7 @@ test_expect_success 'S: notemodify with garbage after mark commit-ish must fail'
#
# from
#
-test_expect_success 'S: from with garbage after mark must fail' '
+test_expect_success 'from with garbage after mark must fail' '
setup_marks_repo &&
(
cd repo &&
@@ -777,7 +777,7 @@ test_expect_success 'S: from with garbage after mark must fail' '
#
# merge
#
-test_expect_success 'S: merge with garbage after mark must fail' '
+test_expect_success 'merge with garbage after mark must fail' '
setup_marks_repo &&
(
cd repo &&
@@ -811,7 +811,7 @@ test_expect_success 'S: merge with garbage after mark must fail' '
#
# tag, from markref
#
-test_expect_success 'S: tag with garbage after mark must fail' '
+test_expect_success 'tag with garbage after mark must fail' '
setup_marks_repo &&
(
cd repo &&
@@ -831,7 +831,7 @@ test_expect_success 'S: tag with garbage after mark must fail' '
#
# cat-blob markref
#
-test_expect_success 'S: cat-blob with garbage after mark must fail' '
+test_expect_success 'cat-blob with garbage after mark must fail' '
setup_marks_repo &&
(
cd repo &&
@@ -846,7 +846,7 @@ test_expect_success 'S: cat-blob with garbage after mark must fail' '
#
# ls markref
#
-test_expect_success 'S: ls with garbage after mark must fail' '
+test_expect_success 'ls with garbage after mark must fail' '
setup_marks_repo &&
(
cd repo &&
@@ -858,7 +858,7 @@ test_expect_success 'S: ls with garbage after mark must fail' '
)
'
-test_expect_success 'S: ls with garbage after sha1 must fail' '
+test_expect_success 'ls with garbage after sha1 must fail' '
setup_marks_repo &&
(
cd repo &&
@@ -893,7 +893,7 @@ test_expect_success 'S: ls with garbage after sha1 must fail' '
#
test_path_eol_success () {
local test="$1" path="$2" unquoted_path="$3"
- test_expect_success "S: paths at EOL with $test must work" '
+ test_expect_success "paths at EOL with $test must work" '
test_when_finished "git branch -D S-path-eol" &&
git -c core.protectNTFS=false fast-import --export-marks=marks.out <<-EOF >out 2>err &&
@@ -1002,7 +1002,7 @@ test_path_eol_success 'octal escapes' '"\150\151\056\143"' 'hi.c'
#
test_path_space_success () {
local test="$1" path="$2" unquoted_path="$3"
- test_expect_success "S: paths before space with $test must work" '
+ test_expect_success "paths before space with $test must work" '
test_when_finished "git branch -D S-path-space" &&
git -c core.protectNTFS=false fast-import --export-marks=marks.out <<-EOF 2>err &&
@@ -1067,7 +1067,7 @@ test_path_space_success 'octal escapes' '"\150\151\056\143"' 'hi.c'
#
test_path_fail () {
local change="$1" what="$2" prefix="$3" path="$4" suffix="$5" err_grep="$6"
- test_expect_success "S: $change with $what must fail" '
+ test_expect_success "$change with $what must fail" '
test_must_fail git fast-import <<-EOF 2>err &&
blob
mark :1
@@ -1130,7 +1130,7 @@ test_path_eol_fail 'ls (in commit)' 'ls :2 ' path
# When 'ls' has no <dataref>, the <path> must be quoted.
test_path_eol_quoted_fail 'ls (without dataref in commit)' 'ls ' path
-test_expect_success 'E: rfc2822 date, --date-format=raw' '
+test_expect_success 'rfc2822 date, --date-format=raw' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -1153,7 +1153,7 @@ test_expect_success 'E: rfc2822 date, --date-format=raw' '
)
'
-test_expect_success 'E: rfc2822 date, --date-format=rfc2822' '
+test_expect_success 'rfc2822 date, --date-format=rfc2822' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
diff --git a/t/t9308-fast-import-stream.sh b/t/t9308-fast-import-stream.sh
index f8743cbfa4..cb361c0369 100755
--- a/t/t9308-fast-import-stream.sh
+++ b/t/t9308-fast-import-stream.sh
@@ -26,7 +26,7 @@ test_expect_success 'truncated stream complains' '
)
'
-test_expect_success !MINGW 'R: print old blob' '
+test_expect_success !MINGW 'print old blob' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -44,7 +44,7 @@ test_expect_success !MINGW 'R: print old blob' '
)
'
-test_expect_success !MINGW 'R: in-stream cat-blob-fd not respected' '
+test_expect_success !MINGW 'in-stream cat-blob-fd not respected' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -71,7 +71,7 @@ test_expect_success !MINGW 'R: in-stream cat-blob-fd not respected' '
)
'
-test_expect_success !MINGW 'R: print mark for new blob' '
+test_expect_success !MINGW 'print mark for new blob' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -90,7 +90,7 @@ test_expect_success !MINGW 'R: print mark for new blob' '
)
'
-test_expect_success !MINGW 'R: print new blob' '
+test_expect_success !MINGW 'print new blob' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -114,7 +114,7 @@ test_expect_success !MINGW 'R: print new blob' '
)
'
-test_expect_success !MINGW 'R: print new blob by sha1' '
+test_expect_success !MINGW 'print new blob by sha1' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -149,7 +149,7 @@ setup_big_file () {
)
}
-test_expect_success 'R: print two blobs to stdout' '
+test_expect_success 'print two blobs to stdout' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -192,7 +192,7 @@ test_expect_success 'R: print two blobs to stdout' '
)
'
-test_expect_success PIPE 'R: copy using cat-file' '
+test_expect_success PIPE 'copy using cat-file' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -244,7 +244,7 @@ test_expect_success PIPE 'R: copy using cat-file' '
)
'
-test_expect_success PIPE 'R: print blob mid-commit' '
+test_expect_success PIPE 'print blob mid-commit' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -281,7 +281,7 @@ test_expect_success PIPE 'R: print blob mid-commit' '
)
'
-test_expect_success PIPE 'R: print staged blob within commit' '
+test_expect_success PIPE 'print staged blob within commit' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -322,7 +322,7 @@ test_expect_success PIPE 'R: print staged blob within commit' '
)
'
-test_expect_success 'R: quiet option results in no stats being output' '
+test_expect_success 'quiet option results in no stats being output' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -341,7 +341,7 @@ test_expect_success 'R: quiet option results in no stats being output' '
)
'
-test_expect_success 'R: feature done means terminating "done" is mandatory' '
+test_expect_success 'feature done means terminating "done" is mandatory' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -352,7 +352,7 @@ test_expect_success 'R: feature done means terminating "done" is mandatory' '
)
'
-test_expect_success 'R: terminating "done" with trailing gibberish is ok' '
+test_expect_success 'terminating "done" with trailing gibberish is ok' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -370,7 +370,7 @@ test_expect_success 'R: terminating "done" with trailing gibberish is ok' '
)
'
-test_expect_success 'R: terminating "done" within commit' '
+test_expect_success 'terminating "done" within commit' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -433,7 +433,7 @@ import_reference_commit () {
INPUT_END
}
-test_expect_success 'O: comments are all skipped' '
+test_expect_success 'comments are all skipped' '
setup_import_repo &&
(
cd repo &&
@@ -485,7 +485,7 @@ test_expect_success 'O: comments are all skipped' '
)
'
-test_expect_success 'O: blank lines not necessary after data commands' '
+test_expect_success 'blank lines not necessary after data commands' '
setup_import_repo &&
(
cd repo &&
@@ -523,7 +523,7 @@ test_expect_success 'O: blank lines not necessary after data commands' '
)
'
-test_expect_success 'O: blank lines not necessary after other commands' '
+test_expect_success 'blank lines not necessary after other commands' '
setup_import_repo &&
(
cd repo &&
@@ -577,7 +577,7 @@ test_expect_success 'O: blank lines not necessary after other commands' '
)
'
-test_expect_success 'O: progress outputs as requested by input' '
+test_expect_success 'progress outputs as requested by input' '
setup_import_repo &&
(
cd repo &&
@@ -616,7 +616,7 @@ test_expect_success 'O: progress outputs as requested by input' '
##
## R: very large blobs
##
-test_expect_success 'R: blob bigger than threshold' '
+test_expect_success 'blob bigger than threshold' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -671,7 +671,7 @@ w_input () {
W_INPUT_END
}
-test_expect_success !MINGW 'W: get-mark & empty orphan commit with no newlines' '
+test_expect_success !MINGW 'get-mark & empty orphan commit with no newlines' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -681,7 +681,7 @@ test_expect_success !MINGW 'W: get-mark & empty orphan commit with no newlines'
)
'
-test_expect_success !MINGW 'W: get-mark & empty orphan commit with one newline' '
+test_expect_success !MINGW 'get-mark & empty orphan commit with one newline' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -691,7 +691,7 @@ test_expect_success !MINGW 'W: get-mark & empty orphan commit with one newline'
)
'
-test_expect_success !MINGW 'W: get-mark & empty orphan commit with ugly second newline' '
+test_expect_success !MINGW 'get-mark & empty orphan commit with ugly second newline' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -707,7 +707,7 @@ test_expect_success !MINGW 'W: get-mark & empty orphan commit with ugly second n
)
'
-test_expect_success !MINGW 'W: get-mark & empty orphan commit with erroneous third newline' '
+test_expect_success !MINGW 'get-mark & empty orphan commit with erroneous third newline' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -718,7 +718,7 @@ test_expect_success !MINGW 'W: get-mark & empty orphan commit with erroneous thi
)
'
-test_expect_success ICONV 'X: handling encoding' '
+test_expect_success ICONV 'handling encoding' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -740,7 +740,7 @@ test_expect_success ICONV 'X: handling encoding' '
)
'
-test_expect_success 'X: replace ref that becomes useless is removed' '
+test_expect_success 'replace ref that becomes useless is removed' '
test_when_finished "rm -rf testrepo" &&
git init -qb main testrepo &&
(
@@ -771,7 +771,7 @@ test_expect_success 'X: replace ref that becomes useless is removed' '
for root in '""' ''
do
- test_expect_success "T: ls root ($root) tree" '
+ test_expect_success "ls root ($root) tree" '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -790,7 +790,7 @@ do
'
done
-test_expect_success 'I: export-pack-edges' '
+test_expect_success 'export-pack-edges' '
test_when_finished "rm -rf repo" &&
git init -b main repo &&
(
diff --git a/t/t9309-fast-import-checkpoint.sh b/t/t9309-fast-import-checkpoint.sh
index 64674dcf83..5c1e80c240 100755
--- a/t/t9309-fast-import-checkpoint.sh
+++ b/t/t9309-fast-import-checkpoint.sh
@@ -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
diff --git a/t/t9310-fast-import-submodule.sh b/t/t9310-fast-import-submodule.sh
index 6e7dbda9f9..1d33ec7055 100755
--- a/t/t9310-fast-import-submodule.sh
+++ b/t/t9310-fast-import-submodule.sh
@@ -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
diff --git a/t/t9311-fast-import-refs.sh b/t/t9311-fast-import-refs.sh
index 2bb8ac1d46..3283fe77c0 100755
--- a/t/t9311-fast-import-refs.sh
+++ b/t/t9311-fast-import-refs.sh
@@ -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 &&
(
--
2.56.GIT
^ permalink raw reply related [flat|nested] 45+ messages in thread* Re: [PATCH 00/20] t9300: group and move tests to other files
2026-11-10 11:49 [PATCH 00/20] t9300: group and move tests to other files Karthik Nayak
` (19 preceding siblings ...)
2026-11-10 11:50 ` [PATCH 20/20] t93xx: drop the series letter from the moved test names Karthik Nayak
@ 2026-11-10 16:45 ` Junio C Hamano
2026-11-10 20:06 ` Junio C Hamano
2026-11-12 17:34 ` [PATCH v2 " Karthik Nayak
21 siblings, 1 reply; 45+ messages in thread
From: Junio C Hamano @ 2026-11-10 16:45 UTC (permalink / raw)
To: Karthik Nayak; +Cc: git
Karthik Nayak <karthik.188@gmail.com> writes:
> 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.
^ permalink raw reply [flat|nested] 45+ messages in thread* Re: [PATCH 00/20] t9300: group and move tests to other files
2026-11-10 16:45 ` [PATCH 00/20] t9300: group and move tests to other files Junio C Hamano
@ 2026-11-10 20:06 ` Junio C Hamano
2026-11-11 11:22 ` Karthik Nayak
0 siblings, 1 reply; 45+ messages in thread
From: Junio C Hamano @ 2026-11-10 20:06 UTC (permalink / raw)
To: Karthik Nayak; +Cc: git
Junio C Hamano <gitster@pobox.com> writes:
> Karthik Nayak <karthik.188@gmail.com> writes:
>
>> 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.
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.
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 00/20] t9300: group and move tests to other files
2026-11-10 20:06 ` Junio C Hamano
@ 2026-11-11 11:22 ` Karthik Nayak
0 siblings, 0 replies; 45+ messages in thread
From: Karthik Nayak @ 2026-11-11 11:22 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
[-- Attachment #1: Type: text/plain, Size: 1760 bytes --]
Junio C Hamano <gitster@pobox.com> writes:
> Junio C Hamano <gitster@pobox.com> writes:
>
>> Karthik Nayak <karthik.188@gmail.com> writes:
>>
>>> 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.
>
> 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.
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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 690 bytes --]
^ permalink raw reply [flat|nested] 45+ messages in thread
* [PATCH v2 00/20] t9300: group and move tests to other files
2026-11-10 11:49 [PATCH 00/20] t9300: group and move tests to other files Karthik Nayak
` (20 preceding siblings ...)
2026-11-10 16:45 ` [PATCH 00/20] t9300: group and move tests to other files Junio C Hamano
@ 2026-11-12 17:34 ` Karthik Nayak
2026-11-12 17:34 ` [PATCH v2 01/20] t9300: move 'fastimport.unpackLimit' to the required test Karthik Nayak
` (19 more replies)
21 siblings, 20 replies; 45+ messages in thread
From: Karthik Nayak @ 2026-11-12 17:34 UTC (permalink / raw)
To: git; +Cc: Karthik Nayak, gitster
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.
---
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/20261110-kn-fast-import-tests-1-v1-0-dbd9ee502aae@gmail.com
---
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
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
## 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 <karthik.188@gmail.com>
@@ 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.
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
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
^ permalink raw reply [flat|nested] 45+ messages in thread* [PATCH v2 01/20] t9300: move 'fastimport.unpackLimit' to the required test
2026-11-12 17:34 ` [PATCH v2 " Karthik Nayak
@ 2026-11-12 17:34 ` Karthik Nayak
2026-11-12 17:34 ` [PATCH v2 02/20] t9300: make the series B tests self-contained Karthik Nayak
` (18 subsequent siblings)
19 siblings, 0 replies; 45+ messages in thread
From: Karthik Nayak @ 2026-11-12 17:34 UTC (permalink / raw)
To: git; +Cc: Karthik Nayak, gitster
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'.
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
t/t9300-fast-import.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 15f511fb6b..4cffe43a71 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -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
--
2.56.GIT
^ permalink raw reply related [flat|nested] 45+ messages in thread* [PATCH v2 02/20] t9300: make the series B tests self-contained
2026-11-12 17:34 ` [PATCH v2 " Karthik Nayak
2026-11-12 17:34 ` [PATCH v2 01/20] t9300: move 'fastimport.unpackLimit' to the required test Karthik Nayak
@ 2026-11-12 17:34 ` Karthik Nayak
2026-11-12 17:34 ` [PATCH v2 03/20] t9300: make the series T " Karthik Nayak
` (17 subsequent siblings)
19 siblings, 0 replies; 45+ messages in thread
From: Karthik Nayak @ 2026-11-12 17:34 UTC (permalink / raw)
To: git; +Cc: Karthik Nayak, gitster
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 <karthik.188@gmail.com>
---
t/t9300-fast-import.sh | 472 ++++++++++++++++++++++++++++---------------------
1 file changed, 275 insertions(+), 197 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 4cffe43a71..e2cf0b7a22 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -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 <a@b.com> $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 <a@b.com> $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
+ )
'
###
--
2.56.GIT
^ permalink raw reply related [flat|nested] 45+ messages in thread* [PATCH v2 03/20] t9300: make the series T tests self-contained
2026-11-12 17:34 ` [PATCH v2 " Karthik Nayak
2026-11-12 17:34 ` [PATCH v2 01/20] t9300: move 'fastimport.unpackLimit' to the required test Karthik Nayak
2026-11-12 17:34 ` [PATCH v2 02/20] t9300: make the series B tests self-contained Karthik Nayak
@ 2026-11-12 17:34 ` Karthik Nayak
2026-11-12 17:34 ` [PATCH v2 04/20] t9300: make the series S " Karthik Nayak
` (16 subsequent siblings)
19 siblings, 0 replies; 45+ messages in thread
From: Karthik Nayak @ 2026-11-12 17:34 UTC (permalink / raw)
To: git; +Cc: Karthik Nayak, gitster
Similar 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.
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
t/t9300-fast-import.sh | 62 +++++++++++++++++++++++++++++++++-----------------
1 file changed, 41 insertions(+), 21 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index e2cf0b7a22..a0e322b866 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -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
+ )
'
###
--
2.56.GIT
^ permalink raw reply related [flat|nested] 45+ messages in thread* [PATCH v2 04/20] t9300: make the series S tests self-contained
2026-11-12 17:34 ` [PATCH v2 " Karthik Nayak
` (2 preceding siblings ...)
2026-11-12 17:34 ` [PATCH v2 03/20] t9300: make the series T " Karthik Nayak
@ 2026-11-12 17:34 ` Karthik Nayak
2026-11-12 17:34 ` [PATCH v2 05/20] t9300: make the series V " Karthik Nayak
` (15 subsequent siblings)
19 siblings, 0 replies; 45+ messages in thread
From: Karthik Nayak @ 2026-11-12 17:34 UTC (permalink / raw)
To: git; +Cc: Karthik Nayak, gitster
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 <karthik.188@gmail.com>
---
t/t9300-fast-import.sh | 332 +++++++++++++++++++++++++++++--------------------
1 file changed, 198 insertions(+), 134 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index a0e322b866..f9359bbaf3 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -3100,10 +3100,12 @@ test_expect_success 'R: --git-completion-helper-all does not read from stdin' '
#
# invalid dataref ..
#
-test_expect_success 'S: initialize for S tests' '
+setup_marks_repo () {
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
test_tick &&
- cat >input <<-INPUT_END &&
+ cat >repo/input <<-INPUT_END &&
commit refs/heads/S
mark :301
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
@@ -3140,142 +3142,168 @@ test_expect_success 'S: initialize for S tests' '
BLOB
INPUT_END
- git fast-import --export-marks=marks <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
+ )
'
#
--
2.56.GIT
^ permalink raw reply related [flat|nested] 45+ messages in thread* [PATCH v2 05/20] t9300: make the series V tests self-contained
2026-11-12 17:34 ` [PATCH v2 " Karthik Nayak
` (3 preceding siblings ...)
2026-11-12 17:34 ` [PATCH v2 04/20] t9300: make the series S " Karthik Nayak
@ 2026-11-12 17:34 ` Karthik Nayak
2026-11-12 17:34 ` [PATCH v2 06/20] t9300: make the series Q " Karthik Nayak
` (14 subsequent siblings)
19 siblings, 0 replies; 45+ messages in thread
From: Karthik Nayak @ 2026-11-12 17:34 UTC (permalink / raw)
To: git; +Cc: Karthik Nayak, gitster
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.
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 <karthik.188@gmail.com>
---
t/t9300-fast-import.sh | 80 ++++++++++++++++++++++++++++++++++----------------
1 file changed, 55 insertions(+), 25 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index f9359bbaf3..809a5a59c5 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -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
'
--
2.56.GIT
^ permalink raw reply related [flat|nested] 45+ messages in thread* [PATCH v2 06/20] t9300: make the series Q tests self-contained
2026-11-12 17:34 ` [PATCH v2 " Karthik Nayak
` (4 preceding siblings ...)
2026-11-12 17:34 ` [PATCH v2 05/20] t9300: make the series V " Karthik Nayak
@ 2026-11-12 17:34 ` Karthik Nayak
2026-11-12 17:34 ` [PATCH v2 07/20] t9300: make the series P " Karthik Nayak
` (13 subsequent siblings)
19 siblings, 0 replies; 45+ messages in thread
From: Karthik Nayak @ 2026-11-12 17:34 UTC (permalink / raw)
To: git; +Cc: Karthik Nayak, gitster
Similar 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.
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
t/t9300-fast-import.sh | 339 +++++++++++++++++++++++++++++++------------------
1 file changed, 212 insertions(+), 127 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 809a5a59c5..a85e3e0757 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -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
+ )
'
###
--
2.56.GIT
^ permalink raw reply related [flat|nested] 45+ messages in thread* [PATCH v2 07/20] t9300: make the series P tests self-contained
2026-11-12 17:34 ` [PATCH v2 " Karthik Nayak
` (5 preceding siblings ...)
2026-11-12 17:34 ` [PATCH v2 06/20] t9300: make the series Q " Karthik Nayak
@ 2026-11-12 17:34 ` Karthik Nayak
2026-11-12 17:34 ` [PATCH v2 08/20] t9300: make the series O " Karthik Nayak
` (12 subsequent siblings)
19 siblings, 0 replies; 45+ messages in thread
From: Karthik Nayak @ 2026-11-12 17:34 UTC (permalink / raw)
To: git; +Cc: Karthik Nayak, gitster
Similar 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.
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
t/t9300-fast-import.sh | 290 +++++++++++++++++++++++++++----------------------
1 file changed, 161 insertions(+), 129 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index a85e3e0757..920fcd52b5 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -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
+ )
'
###
--
2.56.GIT
^ permalink raw reply related [flat|nested] 45+ messages in thread* [PATCH v2 08/20] t9300: make the series O tests self-contained
2026-11-12 17:34 ` [PATCH v2 " Karthik Nayak
` (6 preceding siblings ...)
2026-11-12 17:34 ` [PATCH v2 07/20] t9300: make the series P " Karthik Nayak
@ 2026-11-12 17:34 ` Karthik Nayak
2026-11-12 17:34 ` [PATCH v2 09/20] t9300: make the big blob " Karthik Nayak
` (11 subsequent siblings)
19 siblings, 0 replies; 45+ messages in thread
From: Karthik Nayak @ 2026-11-12 17:34 UTC (permalink / raw)
To: git; +Cc: Karthik Nayak, gitster
Similar 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.
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
t/t9300-fast-import.sh | 291 +++++++++++++++++++++++++++++++------------------
1 file changed, 182 insertions(+), 109 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 920fcd52b5..e0b9663452 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -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
+ )
'
###
--
2.56.GIT
^ permalink raw reply related [flat|nested] 45+ messages in thread* [PATCH v2 09/20] t9300: make the big blob tests self-contained
2026-11-12 17:34 ` [PATCH v2 " Karthik Nayak
` (7 preceding siblings ...)
2026-11-12 17:34 ` [PATCH v2 08/20] t9300: make the series O " Karthik Nayak
@ 2026-11-12 17:34 ` Karthik Nayak
2026-11-12 17:34 ` [PATCH v2 10/20] t9300: make the ref update " Karthik Nayak
` (10 subsequent siblings)
19 siblings, 0 replies; 45+ messages in thread
From: Karthik Nayak @ 2026-11-12 17:34 UTC (permalink / raw)
To: git; +Cc: Karthik Nayak, gitster
Similar 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.
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
t/t9300-fast-import.sh | 79 ++++++++++++++++++++++++--------------------------
1 file changed, 38 insertions(+), 41 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index e0b9663452..2231e1bdab 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -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 &&
--
2.56.GIT
^ permalink raw reply related [flat|nested] 45+ messages in thread* [PATCH v2 10/20] t9300: make the ref update tests self-contained
2026-11-12 17:34 ` [PATCH v2 " Karthik Nayak
` (8 preceding siblings ...)
2026-11-12 17:34 ` [PATCH v2 09/20] t9300: make the big blob " Karthik Nayak
@ 2026-11-12 17:34 ` Karthik Nayak
2026-11-12 17:34 ` [PATCH v2 11/20] t9300: make the date format " Karthik Nayak
` (9 subsequent siblings)
19 siblings, 0 replies; 45+ messages in thread
From: Karthik Nayak @ 2026-11-12 17:34 UTC (permalink / raw)
To: git; +Cc: Karthik Nayak, gitster
Similar to the previous commits, modify the reference update tests in
series 'F', 'G', 'J' and 'K' to make them independent of state from
previous tests. Add a 'setup_two_commit_repo()' function which creates
a repository with two commits on 'main', so each test can invoke it.
Fold the tests which only check the result of an import into the tests
performing it, as they can't run on their own. As
'fastimport.unpackLimit' is no longer set by an earlier test, set it for
the 'F' and 'G' imports so that a pack is written, and verify it with an
inline loop in place of 'verify_packs()'.
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
t/t9300-fast-import.sh | 214 +++++++++++++++++++++++++++----------------------
1 file changed, 119 insertions(+), 95 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 2231e1bdab..446cf0c51a 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -865,43 +865,53 @@ test_expect_success 'E: verify commit' '
### series F
###
+setup_two_commit_repo () {
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ test_commit -C repo one &&
+ test_commit -C repo two
+}
+
test_expect_success 'F: non-fast-forward update skips' '
- old_branch=$(git rev-parse --verify branch^0) &&
- test_tick &&
- cat >input <<-INPUT_END &&
- commit refs/heads/branch
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<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)
+ )
'
###
--
2.56.GIT
^ permalink raw reply related [flat|nested] 45+ messages in thread* [PATCH v2 11/20] t9300: make the date format tests self-contained
2026-11-12 17:34 ` [PATCH v2 " Karthik Nayak
` (9 preceding siblings ...)
2026-11-12 17:34 ` [PATCH v2 10/20] t9300: make the ref update " Karthik Nayak
@ 2026-11-12 17:34 ` Karthik Nayak
2026-11-12 17:34 ` [PATCH v2 12/20] t9300: make the pack edges test self-contained Karthik Nayak
` (8 subsequent siblings)
19 siblings, 0 replies; 45+ messages in thread
From: Karthik Nayak @ 2026-11-12 17:34 UTC (permalink / raw)
To: git; +Cc: Karthik Nayak, gitster
Similar 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()'.
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
t/t9300-fast-import.sh | 72 ++++++++++++++++++++++++++++++++++----------------
1 file changed, 49 insertions(+), 23 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 446cf0c51a..54394c892b 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -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
+ )
'
###
--
2.56.GIT
^ permalink raw reply related [flat|nested] 45+ messages in thread* [PATCH v2 12/20] t9300: make the pack edges test self-contained
2026-11-12 17:34 ` [PATCH v2 " Karthik Nayak
` (10 preceding siblings ...)
2026-11-12 17:34 ` [PATCH v2 11/20] t9300: make the date format " Karthik Nayak
@ 2026-11-12 17:34 ` Karthik Nayak
2026-11-12 17:34 ` [PATCH v2 13/20] t9300: make the marks tests self-contained Karthik Nayak
` (7 subsequent siblings)
19 siblings, 0 replies; 45+ messages in thread
From: Karthik Nayak @ 2026-11-12 17:34 UTC (permalink / raw)
To: git; +Cc: Karthik Nayak, gitster
Similar 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'.
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
t/t9300-fast-import.sh | 90 +++++++++++++++++++++++++++++++-------------------
1 file changed, 56 insertions(+), 34 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 54394c892b..5b8550584e 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -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
+ )
'
###
--
2.56.GIT
^ permalink raw reply related [flat|nested] 45+ messages in thread* [PATCH v2 13/20] t9300: make the marks tests self-contained
2026-11-12 17:34 ` [PATCH v2 " Karthik Nayak
` (11 preceding siblings ...)
2026-11-12 17:34 ` [PATCH v2 12/20] t9300: make the pack edges test self-contained Karthik Nayak
@ 2026-11-12 17:34 ` Karthik Nayak
2026-11-12 17:34 ` [PATCH v2 14/20] t9300: make the series Y " Karthik Nayak
` (6 subsequent siblings)
19 siblings, 0 replies; 45+ messages in thread
From: Karthik Nayak @ 2026-11-12 17:34 UTC (permalink / raw)
To: git; +Cc: Karthik Nayak, gitster
Similar 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.
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
t/t9300-fast-import.sh | 512 +++++++++++++++++++++++++++++++------------------
1 file changed, 322 insertions(+), 190 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 5b8550584e..1022299b7d 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -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
+ )
'
##
--
2.56.GIT
^ permalink raw reply related [flat|nested] 45+ messages in thread* [PATCH v2 14/20] t9300: make the series Y tests self-contained
2026-11-12 17:34 ` [PATCH v2 " Karthik Nayak
` (12 preceding siblings ...)
2026-11-12 17:34 ` [PATCH v2 13/20] t9300: make the marks tests self-contained Karthik Nayak
@ 2026-11-12 17:34 ` Karthik Nayak
2026-11-12 17:34 ` [PATCH v2 15/20] t9300: make the cat-blob " Karthik Nayak
` (5 subsequent siblings)
19 siblings, 0 replies; 45+ messages in thread
From: Karthik Nayak @ 2026-11-12 17:34 UTC (permalink / raw)
To: git; +Cc: Karthik Nayak, gitster
Similar 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.
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
t/t9300-fast-import.sh | 40 +++++++++++++++++++++++++++-------------
1 file changed, 27 insertions(+), 13 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 1022299b7d..7b755d8de1 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -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 &&
--
2.56.GIT
^ permalink raw reply related [flat|nested] 45+ messages in thread* [PATCH v2 15/20] t9300: make the cat-blob tests self-contained
2026-11-12 17:34 ` [PATCH v2 " Karthik Nayak
` (13 preceding siblings ...)
2026-11-12 17:34 ` [PATCH v2 14/20] t9300: make the series Y " Karthik Nayak
@ 2026-11-12 17:34 ` Karthik Nayak
2026-11-12 17:34 ` [PATCH v2 16/20] t9300: make the feature and option " Karthik Nayak
` (4 subsequent siblings)
19 siblings, 0 replies; 45+ messages in thread
From: Karthik Nayak @ 2026-11-12 17:34 UTC (permalink / raw)
To: git; +Cc: Karthik Nayak, gitster
Similar to the previous commits, modify the cat-blog tests to make
them independent of state from previous tests.
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
t/t9300-fast-import.sh | 428 ++++++++++++++++++++++++++++---------------------
1 file changed, 242 insertions(+), 186 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 7b755d8de1..0dc71648ca 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -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' '
--
2.56.GIT
^ permalink raw reply related [flat|nested] 45+ messages in thread* [PATCH v2 16/20] t9300: make the feature and option tests self-contained
2026-11-12 17:34 ` [PATCH v2 " Karthik Nayak
` (14 preceding siblings ...)
2026-11-12 17:34 ` [PATCH v2 15/20] t9300: make the cat-blob " Karthik Nayak
@ 2026-11-12 17:34 ` Karthik Nayak
2026-11-12 17:34 ` [PATCH v2 17/20] t9300: make the stream " Karthik Nayak
` (3 subsequent siblings)
19 siblings, 0 replies; 45+ messages in thread
From: Karthik Nayak @ 2026-11-12 17:34 UTC (permalink / raw)
To: git; +Cc: Karthik Nayak, gitster
Similar 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.
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
t/t9300-fast-import.sh | 260 +++++++++++++++++++++++++++++++++++--------------
1 file changed, 187 insertions(+), 73 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 0dc71648ca..5f84c66ac4 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -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' '
--
2.56.GIT
^ permalink raw reply related [flat|nested] 45+ messages in thread* [PATCH v2 17/20] t9300: make the stream tests self-contained
2026-11-12 17:34 ` [PATCH v2 " Karthik Nayak
` (15 preceding siblings ...)
2026-11-12 17:34 ` [PATCH v2 16/20] t9300: make the feature and option " Karthik Nayak
@ 2026-11-12 17:34 ` Karthik Nayak
2026-11-12 17:34 ` [PATCH v2 18/20] t9300: make the get-mark and encoding " Karthik Nayak
` (2 subsequent siblings)
19 siblings, 0 replies; 45+ messages in thread
From: Karthik Nayak @ 2026-11-12 17:34 UTC (permalink / raw)
To: git; +Cc: Karthik Nayak, gitster
Similar 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.
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
t/t9300-fast-import.sh | 154 ++++++++++++++++++++++++++++++++-----------------
1 file changed, 101 insertions(+), 53 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 5f84c66ac4..45720ed003 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -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
+ )
'
###
--
2.56.GIT
^ permalink raw reply related [flat|nested] 45+ messages in thread* [PATCH v2 18/20] t9300: make the get-mark and encoding tests self-contained
2026-11-12 17:34 ` [PATCH v2 " Karthik Nayak
` (16 preceding siblings ...)
2026-11-12 17:34 ` [PATCH v2 17/20] t9300: make the stream " Karthik Nayak
@ 2026-11-12 17:34 ` Karthik Nayak
2026-11-12 17:34 ` [PATCH v2 19/20] t9300: move self-contained tests into dedicated files Karthik Nayak
2026-11-12 17:34 ` [PATCH v2 20/20] t93xx: drop the series letter from the moved test names Karthik Nayak
19 siblings, 0 replies; 45+ messages in thread
From: Karthik Nayak @ 2026-11-12 17:34 UTC (permalink / raw)
To: git; +Cc: Karthik Nayak, gitster
Similar 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.
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
t/t9300-fast-import.sh | 81 +++++++++++++++++++++++++++++++++++---------------
1 file changed, 57 insertions(+), 24 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 45720ed003..07bd48d2e8 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -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 <user@company.tld> 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 &&
--
2.56.GIT
^ permalink raw reply related [flat|nested] 45+ messages in thread* [PATCH v2 19/20] t9300: move self-contained tests into dedicated files
2026-11-12 17:34 ` [PATCH v2 " Karthik Nayak
` (17 preceding siblings ...)
2026-11-12 17:34 ` [PATCH v2 18/20] t9300: make the get-mark and encoding " Karthik Nayak
@ 2026-11-12 17:34 ` Karthik Nayak
2026-11-12 17:34 ` [PATCH v2 20/20] t93xx: drop the series letter from the moved test names Karthik Nayak
19 siblings, 0 replies; 45+ messages in thread
From: Karthik Nayak @ 2026-11-12 17:34 UTC (permalink / raw)
To: git; +Cc: Karthik Nayak, gitster
The 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'.
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
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(-)
diff --git a/t/meson.build b/t/meson.build
index 1cf1d95f70..15feb9c33f 100644
--- a/t/meson.build
+++ b/t/meson.build
@@ -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',
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 07bd48d2e8..32846bfe79 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -37,26 +37,6 @@ echo "$@"'
### series A
###
-test_expect_success 'empty stream succeeds' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- git fast-import </dev/null
- )
-'
-
-test_expect_success 'truncated stream complains' '
- 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' '
git config fastimport.unpackLimit 0 &&
test_tick &&
@@ -309,421 +289,6 @@ test_expect_success 'A: verify diff' '
= $(git rev-parse --verify verify--import-marks:copy-of-file2)
'
-test_expect_success 'A: export marks with large values' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- test_tick &&
- mt=$(git hash-object --stdin < /dev/null) &&
- >input.blob &&
- >marks.exp &&
- >tree.exp &&
-
- 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
-
- 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 &&
-
- echo ":$l $mt" >>marks.exp &&
- echo ":$m $mt" >>marks.exp &&
- echo ":$n $mt" >>marks.exp &&
-
- 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 &&
-
- l=$(($l + $l)) &&
- m=$(($m + $m)) &&
- n=$(($l + $n)) &&
-
- i=$((1 + $i)) || return 1
- done &&
-
- 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
- )
-'
-
-###
-### series B
-###
-
-test_expect_success 'B: fail on invalid blob sha1' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
- test_commit base &&
-
- 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
-
- from refs/heads/main
- M 755 $(echo $ZERO_OID | sed -e "s/0$/1/") zero1
-
- INPUT_END
-
- test_must_fail git fast-import <input
- )
-'
-
-test_expect_success 'B: accept branch name "TEMP_TAG"' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
- test_commit new &&
-
- cat >input <<-INPUT_END &&
- commit TEMP_TAG
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<COMMIT
- tag base
- COMMIT
-
- from refs/heads/main
-
- 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' '
- 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
-
- git fast-import <input &&
- out=$(git fsck) &&
- echo "$out" &&
- test -z "$out"
- )
-'
-
-test_expect_success 'B: reject invalid timezone' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
- cat >input <<-INPUT_END &&
- commit refs/heads/empty-committer-2
- committer <a@b.com> $GIT_COMMITTER_DATE
- data <<COMMIT
- empty commit
- COMMIT
- INPUT_END
-
- git fast-import <input &&
- out=$(git fsck) &&
- echo "$out" &&
- test -z "$out"
- )
-'
-
-test_expect_success 'B: fail on invalid committer (1)' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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)' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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)' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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)' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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)' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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 ..' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- cat >input <<-INPUT_END &&
- blob
- mark :1
- data <<EOF
- File contents
- EOF
-
- 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 .' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- cat >input <<-INPUT_END &&
- blob
- mark :1
- data <<EOF
- File contents
- EOF
-
- commit refs/heads/badpath
- committer Name <email> $GIT_COMMITTER_DATE
- data <<COMMIT
- Good path
- COMMIT
- M 100644 :1 ok-path
-
- 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:' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- cat >input <<-INPUT_END &&
- blob
- mark :1
- data <<EOF
- File contents
- EOF
-
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- cat >input <<-INPUT_END &&
- blob
- mark :1
- data <<EOF
- File contents
- EOF
-
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- cat >input <<-INPUT_END &&
- blob
- mark :1
- data <<EOF
- File contents
- EOF
-
- 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
- )
-'
-
###
### series C
###
@@ -841,155 +406,6 @@ test_expect_success 'D: verify file6' '
test_cmp expect actual
'
-###
-### series E
-###
-
-test_expect_success 'E: rfc2822 date, --date-format=raw' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
- test_commit one &&
-
- 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
-
- from refs/heads/main^0
-
- INPUT_END
-
- test_must_fail git fast-import --date-format=raw <input
- )
-'
-
-test_expect_success 'E: rfc2822 date, --date-format=rfc2822' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
- test_commit one &&
-
- 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
-
- from refs/heads/main^0
-
- 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
- )
-'
-
-###
-### 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' '
- 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/main~1
-
- reset refs/heads/other
- from refs/heads/main
-
- INPUT_END
-
- test_must_fail git -c fastimport.unpackLimit=0 fast-import <input &&
- # branch must remain unaffected
- test $old_branch = $(git rev-parse --verify main^0) &&
-
- for p in .git/objects/pack/*.pack
- do
- git verify-pack "$p" || return 1
- done &&
-
- 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
- )
-'
-
-###
-### series G
-###
-
-test_expect_success 'G: non-fast-forward update forced' '
- 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/main~1
-
- 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}) &&
-
- for p in .git/objects/pack/*.pack
- do
- git verify-pack "$p" || return 1
- done
- )
-'
-
###
### series H
###
@@ -1043,163 +459,6 @@ test_expect_success 'H: verify file' '
test_cmp expect actual
'
-###
-### 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 &&
- (
- cd repo &&
- test_commit one &&
-
- 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
-
- 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 -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
-###
-
-test_expect_success 'J: reset existing branch creates empty 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/main
-
- reset refs/heads/J
-
- 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 &&
- # 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' '
- 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
- )
-'
-
-###
-### series K
-###
-
-test_expect_success 'K: reinit branch with from' '
- 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/main
-
- commit refs/heads/K
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<COMMIT
- redo K
- COMMIT
-
- from refs/heads/main^1
-
- INPUT_END
- git fast-import <input &&
- # K^1 = main^1
- test $(git rev-parse --verify main^1) \
- = $(git rev-parse --verify K^1)
- )
-'
-
###
### series L
###
@@ -1834,2500 +1093,7 @@ do
'
done
-###
-### series O
-###
-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
-
- 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
-
- INPUT_END
-}
-
-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' '
- setup_import_repo &&
- (
- cd repo &&
-
- 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
-
- 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 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' '
- setup_import_repo &&
- (
- cd repo &&
- git repack -a -d &&
-
- 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
-
- 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' '
- 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
- )
-'
-
-###
-### series P (gitlinks)
-###
-
-setup_gitlinks_repo () {
- test_when_finished "rm -rf repo" &&
- git init repo &&
- test_commit -C repo base &&
- (
- 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' '
- setup_gitlinks_repo &&
- (
- cd repo &&
-
- SUBLAST=$(git rev-parse --verify sub) &&
- SUBPREV=$(git rev-parse --verify sub^) &&
-
- cat >input <<-INPUT_END &&
- blob
- mark :1
- data <<DATAEND
- [submodule "sub"]
- path = sub
- url = "$(pwd)/sub"
- DATAEND
-
- 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
-
- 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
-
- 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' '
- setup_gitlinks_repo &&
- (
- cd repo &&
-
- 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
-
- from refs/heads/subuse1
- M 160000 inline sub
- data <<DATA
- $SUBPREV
- DATA
-
- INPUT_END
-
- test_must_fail git fast-import <input
- )
-'
-
-test_expect_success 'P: fail on blob mark in gitlink' '
- setup_gitlinks_repo &&
- (
- cd repo &&
-
- SUBPREV=$(git rev-parse --verify sub^) &&
- test_tick &&
- cat >input <<-INPUT_END &&
- blob
- mark :1
- data <<DATA
- $SUBPREV
- DATA
-
- commit refs/heads/subuse3
- mark :2
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<COMMIT
- corrupt
- COMMIT
-
- from refs/heads/subuse1
- M 160000 :1 sub
-
- INPUT_END
-
- test_must_fail git fast-import <input
- )
-'
-
-###
-### series Q (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" &&
- note1b_data="The second note for the first commit" &&
- note1c_data="The third note for the first commit" &&
- note2b_data="The second note for the second commit" &&
-
- test_tick &&
- cat >repo/input <<-INPUT_END &&
- blob
- mark :2
- data <<EOF
- $file2_data
- EOF
-
- commit refs/heads/notes-test
- mark :3
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<COMMIT
- first (:3)
- COMMIT
-
- M 644 :2 file2
-
- blob
- mark :4
- data $file4_len
- $file4_data
- commit refs/heads/notes-test
- mark :5
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<COMMIT
- second (:5)
- COMMIT
-
- M 644 :4 file4
-
- commit refs/heads/notes-test
- mark :6
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<COMMIT
- third (:6)
- COMMIT
-
- M 644 inline file5
- data <<EOF
- $file5_data
- EOF
-
- M 755 inline file6
- data <<EOF
- $file6_data
- EOF
-
- blob
- mark :7
- data <<EOF
- $note1_data
- EOF
-
- blob
- mark :8
- data <<EOF
- $note2_data
- EOF
-
- commit refs/notes/foobar
- mark :9
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<COMMIT
- notes (:9)
- COMMIT
-
- N :7 :3
- N :8 :5
- N inline :6
- data <<EOF
- $note3_data
- EOF
-
- commit refs/notes/foobar
- mark :10
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<COMMIT
- notes (:10)
- COMMIT
-
- N inline :3
- data <<EOF
- $note1b_data
- EOF
-
- commit refs/notes/foobar2
- mark :11
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<COMMIT
- notes (:11)
- COMMIT
-
- N inline :3
- data <<EOF
- $note1c_data
- EOF
-
- commit refs/notes/foobar
- mark :12
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<COMMIT
- notes (:12)
- COMMIT
-
- deleteall
- N inline :5
- data <<EOF
- $note2b_data
- EOF
-
- INPUT_END
-
- 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' '
- 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
-
- first (:3)
- EOF
- git cat-file commit notes-test~2 | sed 1d >actual &&
- test_cmp expect actual
- )
-'
-
-test_expect_success 'Q: verify second commit' '
- 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
- )
-'
-
-test_expect_success 'Q: verify third commit' '
- 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
- )
-'
-
-test_expect_success 'Q: verify first notes commit' '
- 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
- )
-'
-
-test_expect_success 'Q: verify first notes tree' '
- 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' '
- 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' '
- 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' '
- 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' '
- 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
- )
-'
-
-test_expect_success 'Q: verify second notes tree' '
- 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' '
- 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' '
- 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' '
- 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' '
- 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
- )
-'
-
-test_expect_success 'Q: verify third notes tree' '
- 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' '
- 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' '
- 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
- )
-'
-
-test_expect_success 'Q: verify fourth notes tree' '
- 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' '
- 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' '
- 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
-
- N inline refs/heads/Q0
- data <<NOTE
- some note
- NOTE
- EOF
- test_must_fail git fast-import <input
- )
-'
-
-###
-### series R (feature and option)
-###
-
-test_expect_success 'R: abort on unsupported feature' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- cat >input <<-EOF &&
- feature no-such-feature-exists
- EOF
-
- test_must_fail git fast-import <input
- )
-'
-
-test_expect_success 'R: supported feature is accepted' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- cat >input <<-EOF &&
- feature date-format=now
- EOF
-
- git fast-import <input
- )
-'
-
-test_expect_success 'R: abort on receiving feature after data command' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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' '
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- >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' '
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- cat >input <<-EOF &&
- feature export-marks=git.marks
- blob
- mark :1
- data 3
- hi
-
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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' '
- 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 &&
- (
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- rm -f io.marks &&
-
- 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 &&
-
- blob=$(echo hi | git hash-object -w --stdin) &&
-
- echo ":1 $blob" >io.marks &&
- echo ":1 $blob" >expect &&
- echo ":2 $blob" >>expect &&
-
- git fast-import --export-marks=io.marks \
- --allow-unsafe-features <<-\EOF &&
- feature import-marks-if-exists=io.marks
- blob
- mark :2
- data 3
- hi
-
- EOF
- test_cmp expect io.marks &&
-
- echo ":3 $blob" >>expect &&
-
- 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
-
- 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
- )
-'
-
-create_marks_file () {
- git fast-import --export-marks="$1" <<-EOF
- blob
- mark :1
- data 4
- one
-
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
- create_marks_file marks.out &&
-
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
- create_marks_file marks.out &&
-
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
- create_marks_file marks.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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
- create_marks_file marks.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' '
- 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' '
- 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_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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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' '
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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
- )
-'
-
-setup_big_file () {
- (
- echo "the quick brown fox jumps over the lazy dog" >big &&
- for i in 1 2 3
- do
- cat big big big big >bigger &&
- cat bigger bigger bigger bigger >big ||
- exit
- done
- )
-}
-
-test_expect_success 'R: print two blobs to stdout' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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
-
- ${blob2} blob 6
- hello
-
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- setup_big_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 &&
- (
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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
-
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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
-
- to_get=$(
- echo "A blob from _within_ the commit." |
- git hash-object --stdin
- ) &&
- echo "cat-blob $to_get" &&
-
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- cat >input <<-EOF &&
- option git quiet
- blob
- data 3
- hi
-
- EOF
-
- git fast-import 2>output <input &&
- test_must_be_empty output
- )
-'
-
-test_expect_success 'R: feature done means terminating "done" is mandatory' '
- 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' '
- 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' '
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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_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' '
- 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' '
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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
- )
-'
-
-##
-## R: very large blobs
-##
-test_expect_success 'R: blob bigger than threshold' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- 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: --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)
-###
-#
-# Make sure missing spaces and EOLs after mark references
-# cause errors.
-#
-# Setup:
-#
-# 1--2--4
-# \ /
-# -3-
-#
-# commit marks: 301, 302, 303, 304
-# blob marks: 403, 404, resp.
-# note mark: 202
-#
-# The error message when a space is missing not at the
-# end of the line is:
-#
-# missing space after ..
-#
-# or when extra characters come after the mark at the end
-# of the line:
-#
-# garbage after ..
-#
-# or when the dataref is neither "inline " or a known SHA1,
-#
-# invalid dataref ..
-#
-setup_marks_repo () {
- test_when_finished "rm -rf repo" &&
- git init repo &&
- test_tick &&
-
- cat >repo/input <<-INPUT_END &&
- commit refs/heads/S
- mark :301
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<COMMIT
- commit 1
- COMMIT
- M 100644 inline hello.c
- data <<BLOB
- blob 1
- BLOB
-
- commit refs/heads/S
- mark :302
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<COMMIT
- commit 2
- COMMIT
- from :301
- M 100644 inline hello.c
- data <<BLOB
- blob 2
- BLOB
-
- blob
- mark :403
- data <<BLOB
- blob 3
- BLOB
-
- blob
- mark :202
- data <<BLOB
- note 2
- BLOB
- INPUT_END
-
- git -C repo fast-import --export-marks=marks <repo/input
-}
-
-#
-# filemodify, three datarefs
-#
-test_expect_success 'S: filemodify with garbage after mark must fail' '
- 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' '
- 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' '
- 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' '
- 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' '
- 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' '
- 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' '
- 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' '
- 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
-
- test_grep "after mark" err
- )
-'
-
-
-#
-# merge
-#
-test_expect_success 'S: merge with garbage after mark must fail' '
- 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' '
- 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' '
- 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' '
- 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' '
- 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
- )
-'
-
-#
-# Path parsing
-#
-# There are two sorts of ways a path can be parsed, depending on whether it is
-# the last field on the line. Additionally, ls without a <dataref> has a special
-# case. Test every occurrence of <path> in the grammar against every error case.
-# Paths for the root (empty strings) are tested elsewhere.
-#
-
-#
-# Valid paths at the end of a line: filemodify, filedelete, filecopy (dest),
-# filerename (dest), and ls.
-#
-# commit :301 from root -- modify hello.c (for setup)
-# commit :302 from :301 -- modify $path
-# commit :303 from :302 -- delete $path
-# commit :304 from :301 -- copy hello.c $path
-# commit :305 from :301 -- rename hello.c $path
-# ls :305 $path
-#
-test_path_eol_success () {
- local test="$1" path="$2" unquoted_path="$3"
- test_expect_success "S: paths at EOL with $test must work" '
- test_when_finished "git branch -D S-path-eol" &&
-
- git -c core.protectNTFS=false fast-import --export-marks=marks.out <<-EOF >out 2>err &&
- blob
- mark :401
- data <<BLOB
- hello world
- BLOB
-
- blob
- mark :402
- data <<BLOB
- hallo welt
- BLOB
-
- commit refs/heads/S-path-eol
- mark :301
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<COMMIT
- initial commit
- COMMIT
- M 100644 :401 hello.c
-
- commit refs/heads/S-path-eol
- mark :302
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<COMMIT
- commit filemodify
- COMMIT
- from :301
- M 100644 :402 $path
-
- commit refs/heads/S-path-eol
- mark :303
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<COMMIT
- commit filedelete
- COMMIT
- from :302
- D $path
-
- commit refs/heads/S-path-eol
- mark :304
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<COMMIT
- commit filecopy dest
- COMMIT
- from :301
- C hello.c $path
-
- commit refs/heads/S-path-eol
- mark :305
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<COMMIT
- commit filerename dest
- COMMIT
- from :301
- R hello.c $path
-
- ls :305 $path
- EOF
-
- commit_m=$(grep :302 marks.out | cut -d\ -f2) &&
- commit_d=$(grep :303 marks.out | cut -d\ -f2) &&
- commit_c=$(grep :304 marks.out | cut -d\ -f2) &&
- commit_r=$(grep :305 marks.out | cut -d\ -f2) &&
- blob1=$(grep :401 marks.out | cut -d\ -f2) &&
- blob2=$(grep :402 marks.out | cut -d\ -f2) &&
-
- (
- printf "100644 blob $blob2\t$unquoted_path\n" &&
- printf "100644 blob $blob1\thello.c\n"
- ) | sort >tree_m.exp &&
- git ls-tree $commit_m | sort >tree_m.out &&
- test_cmp tree_m.exp tree_m.out &&
-
- printf "100644 blob $blob1\thello.c\n" >tree_d.exp &&
- git ls-tree $commit_d >tree_d.out &&
- test_cmp tree_d.exp tree_d.out &&
-
- (
- printf "100644 blob $blob1\t$unquoted_path\n" &&
- printf "100644 blob $blob1\thello.c\n"
- ) | sort >tree_c.exp &&
- git ls-tree $commit_c | sort >tree_c.out &&
- test_cmp tree_c.exp tree_c.out &&
-
- printf "100644 blob $blob1\t$unquoted_path\n" >tree_r.exp &&
- git ls-tree $commit_r >tree_r.out &&
- test_cmp tree_r.exp tree_r.out &&
-
- test_cmp out tree_r.exp
- '
-}
-
-test_path_eol_success 'quoted spaces' '" hello world.c "' ' hello world.c '
-test_path_eol_success 'unquoted spaces' ' hello world.c ' ' hello world.c '
-test_path_eol_success 'octal escapes' '"\150\151\056\143"' 'hi.c'
-
-#
-# Valid paths before a space: filecopy (source) and filerename (source).
-#
-# commit :301 from root -- modify $path (for setup)
-# commit :302 from :301 -- copy $path hello2.c
-# commit :303 from :301 -- rename $path hello2.c
-#
-test_path_space_success () {
- local test="$1" path="$2" unquoted_path="$3"
- test_expect_success "S: paths before space with $test must work" '
- test_when_finished "git branch -D S-path-space" &&
-
- git -c core.protectNTFS=false fast-import --export-marks=marks.out <<-EOF 2>err &&
- blob
- mark :401
- data <<BLOB
- hello world
- BLOB
-
- commit refs/heads/S-path-space
- mark :301
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<COMMIT
- initial commit
- COMMIT
- M 100644 :401 $path
-
- commit refs/heads/S-path-space
- mark :302
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<COMMIT
- commit filecopy source
- COMMIT
- from :301
- C $path hello2.c
-
- commit refs/heads/S-path-space
- mark :303
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<COMMIT
- commit filerename source
- COMMIT
- from :301
- R $path hello2.c
-
- EOF
-
- commit_c=$(grep :302 marks.out | cut -d\ -f2) &&
- commit_r=$(grep :303 marks.out | cut -d\ -f2) &&
- blob=$(grep :401 marks.out | cut -d\ -f2) &&
-
- (
- printf "100644 blob $blob\t$unquoted_path\n" &&
- printf "100644 blob $blob\thello2.c\n"
- ) | sort >tree_c.exp &&
- git ls-tree $commit_c | sort >tree_c.out &&
- test_cmp tree_c.exp tree_c.out &&
-
- printf "100644 blob $blob\thello2.c\n" >tree_r.exp &&
- git ls-tree $commit_r >tree_r.out &&
- test_cmp tree_r.exp tree_r.out
- '
-}
-
-test_path_space_success 'quoted spaces' '" hello world.c "' ' hello world.c '
-test_path_space_success 'no unquoted spaces' 'hello_world.c' 'hello_world.c'
-test_path_space_success 'octal escapes' '"\150\151\056\143"' 'hi.c'
-
-#
-# Test a single commit change with an invalid path. Run it with all occurrences
-# of <path> in the grammar against all error kinds.
-#
-test_path_fail () {
- local change="$1" what="$2" prefix="$3" path="$4" suffix="$5" err_grep="$6"
- test_expect_success "S: $change with $what must fail" '
- test_must_fail git fast-import <<-EOF 2>err &&
- blob
- mark :1
- data <<BLOB
- hello world
- BLOB
-
- commit refs/heads/S-path-fail
- mark :2
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<COMMIT
- commit setup
- COMMIT
- M 100644 :1 hello.c
-
- commit refs/heads/S-path-fail
- committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data <<COMMIT
- commit with bad path
- COMMIT
- from :2
- $prefix$path$suffix
- EOF
-
- test_grep "$err_grep" err
- '
-}
-
-test_path_base_fail () {
- local change="$1" prefix="$2" field="$3" suffix="$4"
- test_path_fail "$change" 'unclosed " in '"$field" "$prefix" '"hello.c' "$suffix" "invalid $field"
- test_path_fail "$change" "invalid escape in quoted $field" "$prefix" '"hello\xff"' "$suffix" "invalid $field"
- test_path_fail "$change" "escaped NUL in quoted $field" "$prefix" '"hello\000"' "$suffix" "NUL in $field"
-}
-test_path_eol_quoted_fail () {
- local change="$1" prefix="$2" field="$3"
- test_path_base_fail "$change" "$prefix" "$field" ''
- test_path_fail "$change" "garbage after quoted $field" "$prefix" '"hello.c"' 'x' "garbage after $field"
- test_path_fail "$change" "space after quoted $field" "$prefix" '"hello.c"' ' ' "garbage after $field"
-}
-test_path_eol_fail () {
- local change="$1" prefix="$2" field="$3"
- test_path_eol_quoted_fail "$change" "$prefix" "$field"
-}
-test_path_space_fail () {
- local change="$1" prefix="$2" field="$3"
- test_path_base_fail "$change" "$prefix" "$field" ' world.c'
- test_path_fail "$change" "missing space after quoted $field" "$prefix" '"hello.c"' 'x world.c' "missing space after $field"
- test_path_fail "$change" "missing space after unquoted $field" "$prefix" 'hello.c' '' "missing space after $field"
-}
-
-test_path_eol_fail filemodify 'M 100644 :1 ' path
-test_path_eol_fail filedelete 'D ' path
-test_path_space_fail filecopy 'C ' source
-test_path_eol_fail filecopy 'C hello.c ' dest
-test_path_space_fail filerename 'R ' source
-test_path_eol_fail filerename 'R hello.c ' dest
-test_path_eol_fail 'ls (in commit)' 'ls :2 ' path
-
-# When 'ls' has no <dataref>, the <path> must be quoted.
-test_path_eol_quoted_fail 'ls (without dataref in commit)' 'ls ' path
-
-###
-### series T (ls)
-###
-
-for root in '""' ''
-do
- test_expect_success "T: ls root ($root) tree" '
- 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' '
- 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' '
- 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
- )
-'
###
### series U (filedelete)
@@ -4439,500 +1205,4 @@ do
'
done
-###
-### series V (checkpoint)
-###
-
-# The commands in input_file should not produce any output on the file
-# descriptor set with --cat-blob-fd (or stdout if unspecified).
-#
-# To make sure you're observing the side effects of checkpoint *before*
-# fast-import terminates (and thus writes out its state), check that the
-# fast-import process is still running using background_import_still_running
-# *after* evaluating the test conditions.
-background_import_then_checkpoint () {
- options=$1
- input_file=$2
-
- mkfifo V.input
- exec 8<>V.input
- rm V.input
-
- mkfifo V.output
- exec 9<>V.output
- rm V.output
-
- (
- git -C repo fast-import $options <&8 >&9 &
- echo $! >&9
- wait $!
- echo >&2 "background fast-import terminated too early with exit code $?"
- # Un-block the read loop in the main shell process.
- echo >&9 UNEXPECTED
- ) &
- sh_pid=$!
- read fi_pid <&9
- # We don't mind if fast-import has already died by the time the test
- # ends.
- test_when_finished "
- exec 8>&-; exec 9>&-;
- kill $sh_pid && wait $sh_pid
- kill $fi_pid && wait $fi_pid
- true"
-
- # Start in the background to ensure we adhere strictly to (blocking)
- # pipes writing sequence. We want to assume that the write below could
- # block, e.g. if fast-import blocks writing its own output to &9
- # because there is no reader on &9 yet.
- (
- cat "$input_file"
- echo "checkpoint"
- echo "progress checkpoint"
- ) >&8 &
-
- last=$(
- while read output <&9
- do
- if test "$output" = "progress checkpoint" || test "$output" = "UNEXPECTED"
- then
- echo "$output"
- break
- else
- # otherwise ignore cruft
- echo >&2 "cruft: $output"
- fi
- done
- )
-
- test "$last" = "progress checkpoint"
-}
-
-background_import_still_running () {
- if ! kill -0 "$fi_pid"
- then
- echo >&2 "background fast-import terminated too early"
- false
- 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' '
- setup_checkpoint_repo &&
- cat >repo/input <<-INPUT_END &&
- progress foo
- progress bar
-
- INPUT_END
-
- background_import_then_checkpoint "" repo/input &&
- background_import_still_running
-'
-
-test_expect_success PIPE 'V: checkpoint updates refs after reset' '
- setup_checkpoint_repo &&
- cat >repo/input <<-\INPUT_END &&
- reset refs/heads/V
- from refs/heads/base
-
- INPUT_END
-
- 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' '
- 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/base
-
- INPUT_END
-
- background_import_then_checkpoint "--export-marks=marks.actual" repo/input &&
- (
- cd repo &&
- echo ":1 $(git rev-parse --verify V)" >marks.expected &&
-
- 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)' '
- 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/base
-
- INPUT_END
-
- background_import_then_checkpoint "--export-marks=marks.actual" repo/input &&
- (
- cd repo &&
- 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
- ) &&
- background_import_still_running
-'
-
-test_expect_success PIPE 'V: checkpoint updates tags after tag' '
- setup_checkpoint_repo &&
- cat >repo/input <<-INPUT_END &&
- tag Vtag
- from refs/heads/base
- tagger $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
- data 0
-
- INPUT_END
-
- background_import_then_checkpoint "" repo/input &&
- git -C repo show-ref -d Vtag &&
- background_import_still_running
-'
-
-###
-### series W (get-mark and empty orphan commits)
-###
-
-w_input () {
- cat <<-W_INPUT_END
- commit refs/heads/W-branch
- mark :1
- author Full Name <user@company.tld> 1000000000 +0100
- committer Full Name <user@company.tld> 1000000000 +0100
- data 27
- Intentionally empty commit
- LFsget-mark :1
- W_INPUT_END
-}
-
-test_expect_success !MINGW 'W: get-mark & empty orphan commit with no newlines' '
- 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' '
- 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' '
- 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' '
- 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
- )
-'
-
-###
-### series X (other new features)
-###
-
-test_expect_success ICONV 'X: handling encoding' '
- test_when_finished "rm -rf repo" &&
- git init repo &&
- (
- cd repo &&
-
- 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
-
- 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 &&
- test_commit test &&
-
- test_commit msg somename content &&
-
- git mv somename othername &&
- NEW_TREE=$(git write-tree) &&
- MSG="$(git log -1 --format=%B HEAD)" &&
- NEW_COMMIT=$(git commit-tree -p HEAD^1 -m "$MSG" $NEW_TREE) &&
- git replace main $NEW_COMMIT &&
-
- echo more >>othername &&
- git add othername &&
- git commit -qm more &&
-
- git fast-export --all >tmp &&
- sed -e s/othername/somename/ tmp >tmp2 &&
- git fast-import --force <tmp2 2>msgs &&
-
- test_grep "dropping.*since it would point to itself" msgs &&
- git show-ref >refs &&
- test_grep ! refs/replace refs
- )
-'
-
-###
-### series Y (submodules and hash algorithms)
-###
-
-cat >Y-sub-input <<\Y_INPUT_END
-blob
-mark :1
-data 4
-foo
-
-reset refs/heads/main
-commit refs/heads/main
-mark :2
-author Full Name <user@company.tld> 1000000000 +0100
-committer Full Name <user@company.tld> 1000000000 +0100
-data 24
-Test submodule commit 1
-M 100644 :1 file
-
-blob
-mark :3
-data 8
-foo
-bar
-
-commit refs/heads/main
-mark :4
-author Full Name <user@company.tld> 1000000001 +0100
-committer Full Name <user@company.tld> 1000000001 +0100
-data 24
-Test submodule commit 2
-from :2
-M 100644 :3 file
-Y_INPUT_END
-
-# Note that the submodule object IDs are intentionally not translated.
-cat >Y-main-input <<\Y_INPUT_END
-blob
-mark :1
-data 4
-foo
-
-reset refs/heads/main
-commit refs/heads/main
-mark :2
-author Full Name <user@company.tld> 2000000000 +0100
-committer Full Name <user@company.tld> 2000000000 +0100
-data 14
-Test commit 1
-M 100644 :1 file
-
-blob
-mark :3
-data 73
-[submodule "sub1"]
- path = sub1
- url = https://void.example.com/main.git
-
-commit refs/heads/main
-mark :4
-author Full Name <user@company.tld> 2000000001 +0100
-committer Full Name <user@company.tld> 2000000001 +0100
-data 14
-Test commit 2
-from :2
-M 100644 :3 .gitmodules
-M 160000 0712c5be7cf681388e355ef47525aaf23aee1a6d sub1
-
-blob
-mark :5
-data 8
-foo
-bar
-
-commit refs/heads/main
-mark :6
-author Full Name <user@company.tld> 2000000002 +0100
-committer Full Name <user@company.tld> 2000000002 +0100
-data 14
-Test commit 3
-from :4
-M 100644 :5 file
-M 160000 ff729f5e62f72c0c3978207d9a80e5f3a65f14d7 sub1
-Y_INPUT_END
-
-cat >Y-marks <<\Y_INPUT_END
-:2 0712c5be7cf681388e355ef47525aaf23aee1a6d
-: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 &&
- git init sub2 &&
- git -C sub2 fast-import --export-marks=../sub2-marks <../Y-sub-input &&
- git fast-import --rewrite-submodules-from=sub:../Y-marks \
- --rewrite-submodules-to=sub:sub2-marks <../Y-main-input &&
- test "$(git rev-parse main)" = "$(test_oid Ymain)"
- )
-'
-
-test_expect_success 'Y: reference pending tag or commit' '
- test_oid_cache <<-EOF &&
- pending_commit sha1:85b46dd918355ff17b4109ec738723d42f235a04
- pending_commit sha256:17e650f097a4db6fe069c96935360d3ccc9b35c4018728c5f311a4217c2ced3d
- pending_tag sha1:ec6c4db71feb5f66615214dad2324ce030e777a7
- pending_tag sha256:85edc5eac315bc680677b2fc71622bd77476f057eb8dc8ed6a497803a24f1f46
- EOF
-
- test_when_finished "rm -rf reference-pending" &&
- git init reference-pending &&
- (
- cd reference-pending &&
- git fast-import <<-EOF
- commit refs/heads/main
- committer A U Thor <author@example.com> 1712563200 +0000
- data 14
- commit message
- M 644 inline test file
- data 14
- dummy content
-
- tag newtag
- from $(test_oid pending_commit)
- tagger A U Thor <author@example.com> 1712563300 +0000
- data 11
- tag message
- # no emty line after tag data!
- reset refs/heads/other
- from $(test_oid pending_tag)
-
- commit refs/heads/further
- committer A U Thor <author@example.com> 1712563400 +0000
- data 21
- what about 2nd commit
- from $(test_oid pending_commit)
- M 644 inline other test file
- data 19
- more dummy content
-
- done
- 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
diff --git a/t/t9301-fast-import-notes.sh b/t/t9301-fast-import-notes.sh
index e62173cf1f..a4b4b0b6cd 100755
--- a/t/t9301-fast-import-notes.sh
+++ b/t/t9301-fast-import-notes.sh
@@ -724,4 +724,404 @@ test_expect_success "add notes to $num_commits commits in each of $num_notes_ref
'
+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" &&
+ note1b_data="The second note for the first commit" &&
+ note1c_data="The third note for the first commit" &&
+ note2b_data="The second note for the second commit" &&
+
+ test_tick &&
+ cat >repo/input <<-INPUT_END &&
+ blob
+ mark :2
+ data <<EOF
+ $file2_data
+ EOF
+
+ commit refs/heads/notes-test
+ mark :3
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ first (:3)
+ COMMIT
+
+ M 644 :2 file2
+
+ blob
+ mark :4
+ data $file4_len
+ $file4_data
+ commit refs/heads/notes-test
+ mark :5
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ second (:5)
+ COMMIT
+
+ M 644 :4 file4
+
+ commit refs/heads/notes-test
+ mark :6
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ third (:6)
+ COMMIT
+
+ M 644 inline file5
+ data <<EOF
+ $file5_data
+ EOF
+
+ M 755 inline file6
+ data <<EOF
+ $file6_data
+ EOF
+
+ blob
+ mark :7
+ data <<EOF
+ $note1_data
+ EOF
+
+ blob
+ mark :8
+ data <<EOF
+ $note2_data
+ EOF
+
+ commit refs/notes/foobar
+ mark :9
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ notes (:9)
+ COMMIT
+
+ N :7 :3
+ N :8 :5
+ N inline :6
+ data <<EOF
+ $note3_data
+ EOF
+
+ commit refs/notes/foobar
+ mark :10
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ notes (:10)
+ COMMIT
+
+ N inline :3
+ data <<EOF
+ $note1b_data
+ EOF
+
+ commit refs/notes/foobar2
+ mark :11
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ notes (:11)
+ COMMIT
+
+ N inline :3
+ data <<EOF
+ $note1c_data
+ EOF
+
+ commit refs/notes/foobar
+ mark :12
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ notes (:12)
+ COMMIT
+
+ deleteall
+ N inline :5
+ data <<EOF
+ $note2b_data
+ EOF
+
+ INPUT_END
+
+ 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' '
+ 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
+
+ first (:3)
+ EOF
+ git cat-file commit notes-test~2 | sed 1d >actual &&
+ test_cmp expect actual
+ )
+'
+
+test_expect_success 'Q: verify second commit' '
+ 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
+ )
+'
+
+test_expect_success 'Q: verify third commit' '
+ 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
+ )
+'
+
+test_expect_success 'Q: verify first notes commit' '
+ 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
+ )
+'
+
+test_expect_success 'Q: verify first notes tree' '
+ 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' '
+ 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' '
+ 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' '
+ 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' '
+ 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
+ )
+'
+
+test_expect_success 'Q: verify second notes tree' '
+ 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' '
+ 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' '
+ 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' '
+ 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' '
+ 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
+ )
+'
+
+test_expect_success 'Q: verify third notes tree' '
+ 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' '
+ 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' '
+ 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
+ )
+'
+
+test_expect_success 'Q: verify fourth notes tree' '
+ 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' '
+ 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' '
+ 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
+
+ N inline refs/heads/Q0
+ data <<NOTE
+ some note
+ NOTE
+ EOF
+ test_must_fail git fast-import <input
+ )
+'
+
test_done
diff --git a/t/t9304-fast-import-marks.sh b/t/t9304-fast-import-marks.sh
index 6c50adca00..437f9016fa 100755
--- a/t/t9304-fast-import-marks.sh
+++ b/t/t9304-fast-import-marks.sh
@@ -79,4 +79,397 @@ 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_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ cat >input <<-EOF &&
+ feature export-marks=git.marks
+ blob
+ mark :1
+ data 3
+ hi
+
+ 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' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ 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_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' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ 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
+ 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' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ 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' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ 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' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ rm -f io.marks &&
+
+ 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 &&
+
+ blob=$(echo hi | git hash-object -w --stdin) &&
+
+ echo ":1 $blob" >io.marks &&
+ echo ":1 $blob" >expect &&
+ echo ":2 $blob" >>expect &&
+
+ git fast-import --export-marks=io.marks \
+ --allow-unsafe-features <<-\EOF &&
+ feature import-marks-if-exists=io.marks
+ blob
+ mark :2
+ data 3
+ hi
+
+ EOF
+ test_cmp expect io.marks &&
+
+ echo ":3 $blob" >>expect &&
+
+ 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
+
+ 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: corrupt lines do not mess marks file' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ 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
+ )
+'
+
+create_marks_file () {
+ git fast-import --export-marks="$1" <<-EOF
+ blob
+ mark :1
+ data 4
+ one
+
+ 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' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+ create_marks_file marks.out &&
+
+ 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' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+ create_marks_file marks.out &&
+
+ 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' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+ create_marks_file marks.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' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+ create_marks_file marks.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 'A: export marks with large values' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ test_tick &&
+ mt=$(git hash-object --stdin < /dev/null) &&
+ >input.blob &&
+ >marks.exp &&
+ >tree.exp &&
+
+ 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
+
+ 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 &&
+
+ echo ":$l $mt" >>marks.exp &&
+ echo ":$m $mt" >>marks.exp &&
+ echo ":$n $mt" >>marks.exp &&
+
+ 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 &&
+
+ l=$(($l + $l)) &&
+ m=$(($m + $m)) &&
+ n=$(($l + $n)) &&
+
+ i=$((1 + $i)) || return 1
+ done &&
+
+ 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
+ )
+'
+
test_done
diff --git a/t/t9307-fast-import-validation.sh b/t/t9307-fast-import-validation.sh
new file mode 100755
index 0000000000..e5cb8c6d00
--- /dev/null
+++ b/t/t9307-fast-import-validation.sh
@@ -0,0 +1,1262 @@
+#!/bin/sh
+
+test_description='git fast-import validation'
+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+
+. ./test-lib.sh
+
+test_expect_success 'B: fail on invalid blob sha1' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+ test_commit base &&
+
+ 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
+
+ from refs/heads/main
+ M 755 $(echo $ZERO_OID | sed -e "s/0$/1/") zero1
+
+ INPUT_END
+
+ test_must_fail git fast-import <input
+ )
+'
+
+test_expect_success 'B: accept branch name "TEMP_TAG"' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+ test_commit new &&
+
+ cat >input <<-INPUT_END &&
+ commit TEMP_TAG
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ tag base
+ COMMIT
+
+ from refs/heads/main
+
+ 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' '
+ 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
+
+ git fast-import <input &&
+ out=$(git fsck) &&
+ echo "$out" &&
+ test -z "$out"
+ )
+'
+
+test_expect_success 'B: reject invalid timezone' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ 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' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ 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' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+ cat >input <<-INPUT_END &&
+ commit refs/heads/empty-committer-2
+ committer <a@b.com> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ empty commit
+ COMMIT
+ INPUT_END
+
+ git fast-import <input &&
+ out=$(git fsck) &&
+ echo "$out" &&
+ test -z "$out"
+ )
+'
+
+test_expect_success 'B: fail on invalid committer (1)' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ 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)' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ 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)' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ 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)' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ 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)' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ 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 ..' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ cat >input <<-INPUT_END &&
+ blob
+ mark :1
+ data <<EOF
+ File contents
+ EOF
+
+ 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 .' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ cat >input <<-INPUT_END &&
+ blob
+ mark :1
+ data <<EOF
+ File contents
+ EOF
+
+ commit refs/heads/badpath
+ committer Name <email> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ Good path
+ COMMIT
+ M 100644 :1 ok-path
+
+ 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:' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ cat >input <<-INPUT_END &&
+ blob
+ mark :1
+ data <<EOF
+ File contents
+ EOF
+
+ 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' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ cat >input <<-INPUT_END &&
+ blob
+ mark :1
+ data <<EOF
+ File contents
+ EOF
+
+ 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' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ cat >input <<-INPUT_END &&
+ blob
+ mark :1
+ data <<EOF
+ File contents
+ EOF
+
+ 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
+ )
+'
+
+test_expect_success 'R: abort on unsupported feature' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ cat >input <<-EOF &&
+ feature no-such-feature-exists
+ EOF
+
+ test_must_fail git fast-import <input
+ )
+'
+
+test_expect_success 'R: supported feature is accepted' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ cat >input <<-EOF &&
+ feature date-format=now
+ EOF
+
+ git fast-import <input
+ )
+'
+
+test_expect_success 'R: abort on receiving feature after data command' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ 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' '
+ 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' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ >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' '
+ 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: feature ls supported' '
+ 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' '
+ 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_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 'R: die on unknown option' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ 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_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' '
+ 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' '
+ 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' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ cat >input <<-EOF &&
+ option non-existing-vcs non-existing-option
+ EOF
+
+ git fast-import <input
+ )
+'
+
+###
+### series S (mark and path parsing)
+###
+#
+# Make sure missing spaces and EOLs after mark references
+# cause errors.
+#
+# Setup:
+#
+# 1--2--4
+# \ /
+# -3-
+#
+# commit marks: 301, 302, 303, 304
+# blob marks: 403, 404, resp.
+# note mark: 202
+#
+# The error message when a space is missing not at the
+# end of the line is:
+#
+# missing space after ..
+#
+# or when extra characters come after the mark at the end
+# of the line:
+#
+# garbage after ..
+#
+# or when the dataref is neither "inline " or a known SHA1,
+#
+# invalid dataref ..
+#
+setup_marks_repo () {
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ test_tick &&
+
+ cat >repo/input <<-INPUT_END &&
+ commit refs/heads/S
+ mark :301
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ commit 1
+ COMMIT
+ M 100644 inline hello.c
+ data <<BLOB
+ blob 1
+ BLOB
+
+ commit refs/heads/S
+ mark :302
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ commit 2
+ COMMIT
+ from :301
+ M 100644 inline hello.c
+ data <<BLOB
+ blob 2
+ BLOB
+
+ blob
+ mark :403
+ data <<BLOB
+ blob 3
+ BLOB
+
+ blob
+ mark :202
+ data <<BLOB
+ note 2
+ BLOB
+ INPUT_END
+
+ git -C repo fast-import --export-marks=marks <repo/input
+}
+
+#
+# filemodify, three datarefs
+#
+test_expect_success 'S: filemodify with garbage after mark must fail' '
+ 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' '
+ 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' '
+ 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' '
+ 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' '
+ 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' '
+ 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' '
+ 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' '
+ 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
+
+ test_grep "after mark" err
+ )
+'
+
+
+#
+# merge
+#
+test_expect_success 'S: merge with garbage after mark must fail' '
+ 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' '
+ 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' '
+ 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' '
+ 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' '
+ 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
+ )
+'
+
+#
+# Path parsing
+#
+# There are two sorts of ways a path can be parsed, depending on whether it is
+# the last field on the line. Additionally, ls without a <dataref> has a special
+# case. Test every occurrence of <path> in the grammar against every error case.
+# Paths for the root (empty strings) are tested elsewhere.
+#
+
+#
+# Valid paths at the end of a line: filemodify, filedelete, filecopy (dest),
+# filerename (dest), and ls.
+#
+# commit :301 from root -- modify hello.c (for setup)
+# commit :302 from :301 -- modify $path
+# commit :303 from :302 -- delete $path
+# commit :304 from :301 -- copy hello.c $path
+# commit :305 from :301 -- rename hello.c $path
+# ls :305 $path
+#
+test_path_eol_success () {
+ local test="$1" path="$2" unquoted_path="$3"
+ test_expect_success "S: paths at EOL with $test must work" '
+ test_when_finished "git branch -D S-path-eol" &&
+
+ git -c core.protectNTFS=false fast-import --export-marks=marks.out <<-EOF >out 2>err &&
+ blob
+ mark :401
+ data <<BLOB
+ hello world
+ BLOB
+
+ blob
+ mark :402
+ data <<BLOB
+ hallo welt
+ BLOB
+
+ commit refs/heads/S-path-eol
+ mark :301
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ initial commit
+ COMMIT
+ M 100644 :401 hello.c
+
+ commit refs/heads/S-path-eol
+ mark :302
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ commit filemodify
+ COMMIT
+ from :301
+ M 100644 :402 $path
+
+ commit refs/heads/S-path-eol
+ mark :303
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ commit filedelete
+ COMMIT
+ from :302
+ D $path
+
+ commit refs/heads/S-path-eol
+ mark :304
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ commit filecopy dest
+ COMMIT
+ from :301
+ C hello.c $path
+
+ commit refs/heads/S-path-eol
+ mark :305
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ commit filerename dest
+ COMMIT
+ from :301
+ R hello.c $path
+
+ ls :305 $path
+ EOF
+
+ commit_m=$(grep :302 marks.out | cut -d\ -f2) &&
+ commit_d=$(grep :303 marks.out | cut -d\ -f2) &&
+ commit_c=$(grep :304 marks.out | cut -d\ -f2) &&
+ commit_r=$(grep :305 marks.out | cut -d\ -f2) &&
+ blob1=$(grep :401 marks.out | cut -d\ -f2) &&
+ blob2=$(grep :402 marks.out | cut -d\ -f2) &&
+
+ (
+ printf "100644 blob $blob2\t$unquoted_path\n" &&
+ printf "100644 blob $blob1\thello.c\n"
+ ) | sort >tree_m.exp &&
+ git ls-tree $commit_m | sort >tree_m.out &&
+ test_cmp tree_m.exp tree_m.out &&
+
+ printf "100644 blob $blob1\thello.c\n" >tree_d.exp &&
+ git ls-tree $commit_d >tree_d.out &&
+ test_cmp tree_d.exp tree_d.out &&
+
+ (
+ printf "100644 blob $blob1\t$unquoted_path\n" &&
+ printf "100644 blob $blob1\thello.c\n"
+ ) | sort >tree_c.exp &&
+ git ls-tree $commit_c | sort >tree_c.out &&
+ test_cmp tree_c.exp tree_c.out &&
+
+ printf "100644 blob $blob1\t$unquoted_path\n" >tree_r.exp &&
+ git ls-tree $commit_r >tree_r.out &&
+ test_cmp tree_r.exp tree_r.out &&
+
+ test_cmp out tree_r.exp
+ '
+}
+
+test_path_eol_success 'quoted spaces' '" hello world.c "' ' hello world.c '
+test_path_eol_success 'unquoted spaces' ' hello world.c ' ' hello world.c '
+test_path_eol_success 'octal escapes' '"\150\151\056\143"' 'hi.c'
+
+#
+# Valid paths before a space: filecopy (source) and filerename (source).
+#
+# commit :301 from root -- modify $path (for setup)
+# commit :302 from :301 -- copy $path hello2.c
+# commit :303 from :301 -- rename $path hello2.c
+#
+test_path_space_success () {
+ local test="$1" path="$2" unquoted_path="$3"
+ test_expect_success "S: paths before space with $test must work" '
+ test_when_finished "git branch -D S-path-space" &&
+
+ git -c core.protectNTFS=false fast-import --export-marks=marks.out <<-EOF 2>err &&
+ blob
+ mark :401
+ data <<BLOB
+ hello world
+ BLOB
+
+ commit refs/heads/S-path-space
+ mark :301
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ initial commit
+ COMMIT
+ M 100644 :401 $path
+
+ commit refs/heads/S-path-space
+ mark :302
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ commit filecopy source
+ COMMIT
+ from :301
+ C $path hello2.c
+
+ commit refs/heads/S-path-space
+ mark :303
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ commit filerename source
+ COMMIT
+ from :301
+ R $path hello2.c
+
+ EOF
+
+ commit_c=$(grep :302 marks.out | cut -d\ -f2) &&
+ commit_r=$(grep :303 marks.out | cut -d\ -f2) &&
+ blob=$(grep :401 marks.out | cut -d\ -f2) &&
+
+ (
+ printf "100644 blob $blob\t$unquoted_path\n" &&
+ printf "100644 blob $blob\thello2.c\n"
+ ) | sort >tree_c.exp &&
+ git ls-tree $commit_c | sort >tree_c.out &&
+ test_cmp tree_c.exp tree_c.out &&
+
+ printf "100644 blob $blob\thello2.c\n" >tree_r.exp &&
+ git ls-tree $commit_r >tree_r.out &&
+ test_cmp tree_r.exp tree_r.out
+ '
+}
+
+test_path_space_success 'quoted spaces' '" hello world.c "' ' hello world.c '
+test_path_space_success 'no unquoted spaces' 'hello_world.c' 'hello_world.c'
+test_path_space_success 'octal escapes' '"\150\151\056\143"' 'hi.c'
+
+#
+# Test a single commit change with an invalid path. Run it with all occurrences
+# of <path> in the grammar against all error kinds.
+#
+test_path_fail () {
+ local change="$1" what="$2" prefix="$3" path="$4" suffix="$5" err_grep="$6"
+ test_expect_success "S: $change with $what must fail" '
+ test_must_fail git fast-import <<-EOF 2>err &&
+ blob
+ mark :1
+ data <<BLOB
+ hello world
+ BLOB
+
+ commit refs/heads/S-path-fail
+ mark :2
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ commit setup
+ COMMIT
+ M 100644 :1 hello.c
+
+ commit refs/heads/S-path-fail
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ commit with bad path
+ COMMIT
+ from :2
+ $prefix$path$suffix
+ EOF
+
+ test_grep "$err_grep" err
+ '
+}
+
+test_path_base_fail () {
+ local change="$1" prefix="$2" field="$3" suffix="$4"
+ test_path_fail "$change" 'unclosed " in '"$field" "$prefix" '"hello.c' "$suffix" "invalid $field"
+ test_path_fail "$change" "invalid escape in quoted $field" "$prefix" '"hello\xff"' "$suffix" "invalid $field"
+ test_path_fail "$change" "escaped NUL in quoted $field" "$prefix" '"hello\000"' "$suffix" "NUL in $field"
+}
+test_path_eol_quoted_fail () {
+ local change="$1" prefix="$2" field="$3"
+ test_path_base_fail "$change" "$prefix" "$field" ''
+ test_path_fail "$change" "garbage after quoted $field" "$prefix" '"hello.c"' 'x' "garbage after $field"
+ test_path_fail "$change" "space after quoted $field" "$prefix" '"hello.c"' ' ' "garbage after $field"
+}
+test_path_eol_fail () {
+ local change="$1" prefix="$2" field="$3"
+ test_path_eol_quoted_fail "$change" "$prefix" "$field"
+}
+test_path_space_fail () {
+ local change="$1" prefix="$2" field="$3"
+ test_path_base_fail "$change" "$prefix" "$field" ' world.c'
+ test_path_fail "$change" "missing space after quoted $field" "$prefix" '"hello.c"' 'x world.c' "missing space after $field"
+ test_path_fail "$change" "missing space after unquoted $field" "$prefix" 'hello.c' '' "missing space after $field"
+}
+
+test_path_eol_fail filemodify 'M 100644 :1 ' path
+test_path_eol_fail filedelete 'D ' path
+test_path_space_fail filecopy 'C ' source
+test_path_eol_fail filecopy 'C hello.c ' dest
+test_path_space_fail filerename 'R ' source
+test_path_eol_fail filerename 'R hello.c ' dest
+test_path_eol_fail 'ls (in commit)' 'ls :2 ' path
+
+# When 'ls' has no <dataref>, the <path> must be quoted.
+test_path_eol_quoted_fail 'ls (without dataref in commit)' 'ls ' path
+
+test_expect_success 'E: rfc2822 date, --date-format=raw' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+ test_commit one &&
+
+ 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
+
+ from refs/heads/main^0
+
+ INPUT_END
+
+ test_must_fail git fast-import --date-format=raw <input
+ )
+'
+
+test_expect_success 'E: rfc2822 date, --date-format=rfc2822' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+ test_commit one &&
+
+ 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
+
+ from refs/heads/main^0
+
+ 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
+ )
+'
+
+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
diff --git a/t/t9308-fast-import-stream.sh b/t/t9308-fast-import-stream.sh
new file mode 100755
index 0000000000..f0755c9673
--- /dev/null
+++ b/t/t9308-fast-import-stream.sh
@@ -0,0 +1,890 @@
+#!/bin/sh
+
+test_description='test fast-import stream handling and output'
+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+
+. ./test-lib.sh
+
+test_expect_success 'empty stream succeeds' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ git fast-import </dev/null
+ )
+'
+
+test_expect_success 'truncated stream complains' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ echo "tag foo" | test_must_fail git fast-import
+ )
+'
+
+test_expect_success !MINGW 'R: print old blob' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ 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' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ 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' '
+ 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' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ 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' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ 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
+ )
+'
+
+setup_big_file () {
+ (
+ echo "the quick brown fox jumps over the lazy dog" >big &&
+ for i in 1 2 3
+ do
+ cat big big big big >bigger &&
+ cat bigger bigger bigger bigger >big ||
+ exit
+ done
+ )
+}
+
+test_expect_success 'R: print two blobs to stdout' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ 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
+
+ ${blob2} blob 6
+ hello
+
+ 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' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ setup_big_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 &&
+ (
+ 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' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ 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
+
+ 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' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ 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
+
+ to_get=$(
+ echo "A blob from _within_ the commit." |
+ git hash-object --stdin
+ ) &&
+ echo "cat-blob $to_get" &&
+
+ 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' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ cat >input <<-EOF &&
+ option git quiet
+ blob
+ data 3
+ hi
+
+ EOF
+
+ git fast-import 2>output <input &&
+ test_must_be_empty output
+ )
+'
+
+test_expect_success 'R: feature done means terminating "done" is mandatory' '
+ 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' '
+ 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' '
+ 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
+ )
+'
+
+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
+
+ 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
+
+ INPUT_END
+}
+
+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' '
+ setup_import_repo &&
+ (
+ cd repo &&
+
+ 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
+
+ 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 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' '
+ setup_import_repo &&
+ (
+ cd repo &&
+ git repack -a -d &&
+
+ 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
+
+ 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' '
+ 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
+ )
+'
+
+##
+## R: very large blobs
+##
+test_expect_success 'R: blob bigger than threshold' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ 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
+ )
+'
+
+w_input () {
+ cat <<-W_INPUT_END
+ commit refs/heads/W-branch
+ mark :1
+ author Full Name <user@company.tld> 1000000000 +0100
+ committer Full Name <user@company.tld> 1000000000 +0100
+ data 27
+ Intentionally empty commit
+ LFsget-mark :1
+ W_INPUT_END
+}
+
+test_expect_success !MINGW 'W: get-mark & empty orphan commit with no newlines' '
+ 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' '
+ 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' '
+ 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' '
+ 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
+ )
+'
+
+test_expect_success ICONV 'X: handling encoding' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+
+ 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
+
+ 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 &&
+ test_commit test &&
+
+ test_commit msg somename content &&
+
+ git mv somename othername &&
+ NEW_TREE=$(git write-tree) &&
+ MSG="$(git log -1 --format=%B HEAD)" &&
+ NEW_COMMIT=$(git commit-tree -p HEAD^1 -m "$MSG" $NEW_TREE) &&
+ git replace main $NEW_COMMIT &&
+
+ echo more >>othername &&
+ git add othername &&
+ git commit -qm more &&
+
+ git fast-export --all >tmp &&
+ sed -e s/othername/somename/ tmp >tmp2 &&
+ git fast-import --force <tmp2 2>msgs &&
+
+ test_grep "dropping.*since it would point to itself" msgs &&
+ git show-ref >refs &&
+ test_grep ! refs/replace refs
+ )
+'
+
+for root in '""' ''
+do
+ test_expect_success "T: ls root ($root) tree" '
+ 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 'I: export-pack-edges' '
+ test_when_finished "rm -rf repo" &&
+ git init -b main repo &&
+ (
+ cd repo &&
+ test_commit one &&
+
+ 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
+
+ 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 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
diff --git a/t/t9309-fast-import-checkpoint.sh b/t/t9309-fast-import-checkpoint.sh
new file mode 100755
index 0000000000..64674dcf83
--- /dev/null
+++ b/t/t9309-fast-import-checkpoint.sh
@@ -0,0 +1,188 @@
+#!/bin/sh
+
+test_description='test fast-import checkpoint handling'
+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+
+. ./test-lib.sh
+
+# The commands in input_file should not produce any output on the file
+# descriptor set with --cat-blob-fd (or stdout if unspecified).
+#
+# To make sure you're observing the side effects of checkpoint *before*
+# fast-import terminates (and thus writes out its state), check that the
+# fast-import process is still running using background_import_still_running
+# *after* evaluating the test conditions.
+background_import_then_checkpoint () {
+ options=$1
+ input_file=$2
+
+ mkfifo V.input
+ exec 8<>V.input
+ rm V.input
+
+ mkfifo V.output
+ exec 9<>V.output
+ rm V.output
+
+ (
+ git -C repo fast-import $options <&8 >&9 &
+ echo $! >&9
+ wait $!
+ echo >&2 "background fast-import terminated too early with exit code $?"
+ # Un-block the read loop in the main shell process.
+ echo >&9 UNEXPECTED
+ ) &
+ sh_pid=$!
+ read fi_pid <&9
+ # We don't mind if fast-import has already died by the time the test
+ # ends.
+ test_when_finished "
+ exec 8>&-; exec 9>&-;
+ kill $sh_pid && wait $sh_pid
+ kill $fi_pid && wait $fi_pid
+ true"
+
+ # Start in the background to ensure we adhere strictly to (blocking)
+ # pipes writing sequence. We want to assume that the write below could
+ # block, e.g. if fast-import blocks writing its own output to &9
+ # because there is no reader on &9 yet.
+ (
+ cat "$input_file"
+ echo "checkpoint"
+ echo "progress checkpoint"
+ ) >&8 &
+
+ last=$(
+ while read output <&9
+ do
+ if test "$output" = "progress checkpoint" || test "$output" = "UNEXPECTED"
+ then
+ echo "$output"
+ break
+ else
+ # otherwise ignore cruft
+ echo >&2 "cruft: $output"
+ fi
+ done
+ )
+
+ test "$last" = "progress checkpoint"
+}
+
+background_import_still_running () {
+ if ! kill -0 "$fi_pid"
+ then
+ echo >&2 "background fast-import terminated too early"
+ false
+ 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' '
+ setup_checkpoint_repo &&
+ cat >repo/input <<-INPUT_END &&
+ progress foo
+ progress bar
+
+ INPUT_END
+
+ background_import_then_checkpoint "" repo/input &&
+ background_import_still_running
+'
+
+test_expect_success PIPE 'V: checkpoint updates refs after reset' '
+ setup_checkpoint_repo &&
+ cat >repo/input <<-\INPUT_END &&
+ reset refs/heads/V
+ from refs/heads/base
+
+ INPUT_END
+
+ 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' '
+ 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/base
+
+ INPUT_END
+
+ background_import_then_checkpoint "--export-marks=marks.actual" repo/input &&
+ (
+ cd repo &&
+ echo ":1 $(git rev-parse --verify V)" >marks.expected &&
+
+ 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)' '
+ 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/base
+
+ INPUT_END
+
+ background_import_then_checkpoint "--export-marks=marks.actual" repo/input &&
+ (
+ cd repo &&
+ 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
+ ) &&
+ background_import_still_running
+'
+
+test_expect_success PIPE 'V: checkpoint updates tags after tag' '
+ setup_checkpoint_repo &&
+ cat >repo/input <<-INPUT_END &&
+ tag Vtag
+ from refs/heads/base
+ tagger $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data 0
+
+ INPUT_END
+
+ background_import_then_checkpoint "" repo/input &&
+ git -C repo show-ref -d Vtag &&
+ background_import_still_running
+'
+
+test_done
diff --git a/t/t9310-fast-import-submodule.sh b/t/t9310-fast-import-submodule.sh
new file mode 100755
index 0000000000..74c20d39c5
--- /dev/null
+++ b/t/t9310-fast-import-submodule.sh
@@ -0,0 +1,385 @@
+#!/bin/sh
+
+test_description='test fast-import with submodules and gitlinks'
+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+
+. ./test-lib.sh
+
+setup_gitlinks_repo () {
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ test_commit -C repo base &&
+ (
+ 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' '
+ setup_gitlinks_repo &&
+ (
+ cd repo &&
+
+ SUBLAST=$(git rev-parse --verify sub) &&
+ SUBPREV=$(git rev-parse --verify sub^) &&
+
+ cat >input <<-INPUT_END &&
+ blob
+ mark :1
+ data <<DATAEND
+ [submodule "sub"]
+ path = sub
+ url = "$(pwd)/sub"
+ DATAEND
+
+ 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
+
+ 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
+
+ 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' '
+ setup_gitlinks_repo &&
+ (
+ cd repo &&
+
+ 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
+
+ from refs/heads/subuse1
+ M 160000 inline sub
+ data <<DATA
+ $SUBPREV
+ DATA
+
+ INPUT_END
+
+ test_must_fail git fast-import <input
+ )
+'
+
+test_expect_success 'P: fail on blob mark in gitlink' '
+ setup_gitlinks_repo &&
+ (
+ cd repo &&
+
+ SUBPREV=$(git rev-parse --verify sub^) &&
+ test_tick &&
+ cat >input <<-INPUT_END &&
+ blob
+ mark :1
+ data <<DATA
+ $SUBPREV
+ DATA
+
+ commit refs/heads/subuse3
+ mark :2
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ corrupt
+ COMMIT
+
+ from refs/heads/subuse1
+ M 160000 :1 sub
+
+ INPUT_END
+
+ test_must_fail git fast-import <input
+ )
+'
+
+cat >Y-sub-input <<\Y_INPUT_END
+blob
+mark :1
+data 4
+foo
+
+reset refs/heads/main
+commit refs/heads/main
+mark :2
+author Full Name <user@company.tld> 1000000000 +0100
+committer Full Name <user@company.tld> 1000000000 +0100
+data 24
+Test submodule commit 1
+M 100644 :1 file
+
+blob
+mark :3
+data 8
+foo
+bar
+
+commit refs/heads/main
+mark :4
+author Full Name <user@company.tld> 1000000001 +0100
+committer Full Name <user@company.tld> 1000000001 +0100
+data 24
+Test submodule commit 2
+from :2
+M 100644 :3 file
+Y_INPUT_END
+
+# Note that the submodule object IDs are intentionally not translated.
+cat >Y-main-input <<\Y_INPUT_END
+blob
+mark :1
+data 4
+foo
+
+reset refs/heads/main
+commit refs/heads/main
+mark :2
+author Full Name <user@company.tld> 2000000000 +0100
+committer Full Name <user@company.tld> 2000000000 +0100
+data 14
+Test commit 1
+M 100644 :1 file
+
+blob
+mark :3
+data 73
+[submodule "sub1"]
+ path = sub1
+ url = https://void.example.com/main.git
+
+commit refs/heads/main
+mark :4
+author Full Name <user@company.tld> 2000000001 +0100
+committer Full Name <user@company.tld> 2000000001 +0100
+data 14
+Test commit 2
+from :2
+M 100644 :3 .gitmodules
+M 160000 0712c5be7cf681388e355ef47525aaf23aee1a6d sub1
+
+blob
+mark :5
+data 8
+foo
+bar
+
+commit refs/heads/main
+mark :6
+author Full Name <user@company.tld> 2000000002 +0100
+committer Full Name <user@company.tld> 2000000002 +0100
+data 14
+Test commit 3
+from :4
+M 100644 :5 file
+M 160000 ff729f5e62f72c0c3978207d9a80e5f3a65f14d7 sub1
+Y_INPUT_END
+
+cat >Y-marks <<\Y_INPUT_END
+:2 0712c5be7cf681388e355ef47525aaf23aee1a6d
+:4 ff729f5e62f72c0c3978207d9a80e5f3a65f14d7
+Y_INPUT_END
+
+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 &&
+ git init sub2 &&
+ git -C sub2 fast-import --export-marks=../sub2-marks <../Y-sub-input &&
+ git fast-import --rewrite-submodules-from=sub:../Y-marks \
+ --rewrite-submodules-to=sub:sub2-marks <../Y-main-input &&
+ test "$(git rev-parse main)" = "$(test_oid Ymain)"
+ )
+'
+
+test_expect_success 'Y: reference pending tag or commit' '
+ test_oid_cache <<-EOF &&
+ pending_commit sha1:85b46dd918355ff17b4109ec738723d42f235a04
+ pending_commit sha256:17e650f097a4db6fe069c96935360d3ccc9b35c4018728c5f311a4217c2ced3d
+ pending_tag sha1:ec6c4db71feb5f66615214dad2324ce030e777a7
+ pending_tag sha256:85edc5eac315bc680677b2fc71622bd77476f057eb8dc8ed6a497803a24f1f46
+ EOF
+
+ test_when_finished "rm -rf reference-pending" &&
+ git init reference-pending &&
+ (
+ cd reference-pending &&
+ git fast-import <<-EOF
+ commit refs/heads/main
+ committer A U Thor <author@example.com> 1712563200 +0000
+ data 14
+ commit message
+ M 644 inline test file
+ data 14
+ dummy content
+
+ tag newtag
+ from $(test_oid pending_commit)
+ tagger A U Thor <author@example.com> 1712563300 +0000
+ data 11
+ tag message
+ # no emty line after tag data!
+ reset refs/heads/other
+ from $(test_oid pending_tag)
+
+ commit refs/heads/further
+ committer A U Thor <author@example.com> 1712563400 +0000
+ data 21
+ what about 2nd commit
+ from $(test_oid pending_commit)
+ M 644 inline other test file
+ data 19
+ more dummy content
+
+ done
+ EOF
+ )
+'
+
+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
diff --git a/t/t9311-fast-import-refs.sh b/t/t9311-fast-import-refs.sh
new file mode 100755
index 0000000000..2bb8ac1d46
--- /dev/null
+++ b/t/t9311-fast-import-refs.sh
@@ -0,0 +1,194 @@
+#!/bin/sh
+
+test_description='test fast-import ref updates'
+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+
+. ./test-lib.sh
+
+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' '
+ 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/main~1
+
+ reset refs/heads/other
+ from refs/heads/main
+
+ INPUT_END
+
+ test_must_fail git -c fastimport.unpackLimit=0 fast-import <input &&
+ # branch must remain unaffected
+ test $old_branch = $(git rev-parse --verify main^0) &&
+
+ for p in .git/objects/pack/*.pack
+ do
+ git verify-pack "$p" || return 1
+ done &&
+
+ 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
+ )
+'
+
+test_expect_success 'G: non-fast-forward update forced' '
+ 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/main~1
+
+ 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}) &&
+
+ for p in .git/objects/pack/*.pack
+ do
+ git verify-pack "$p" || return 1
+ done
+ )
+'
+
+test_expect_success 'J: reset existing branch creates empty 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/main
+
+ reset refs/heads/J
+
+ 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 &&
+ # 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' '
+ 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
+ )
+'
+
+test_expect_success 'K: reinit branch with from' '
+ 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/main
+
+ commit refs/heads/K
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ redo K
+ COMMIT
+
+ from refs/heads/main^1
+
+ INPUT_END
+ git fast-import <input &&
+ # K^1 = main^1
+ test $(git rev-parse --verify main^1) \
+ = $(git rev-parse --verify K^1)
+ )
+'
+
+test_expect_success 'T: delete branch' '
+ 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' '
+ 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
+ )
+'
+
+test_done
--
2.56.GIT
^ permalink raw reply related [flat|nested] 45+ messages in thread* [PATCH v2 20/20] t93xx: drop the series letter from the moved test names
2026-11-12 17:34 ` [PATCH v2 " Karthik Nayak
` (18 preceding siblings ...)
2026-11-12 17:34 ` [PATCH v2 19/20] t9300: move self-contained tests into dedicated files Karthik Nayak
@ 2026-11-12 17:34 ` Karthik Nayak
19 siblings, 0 replies; 45+ messages in thread
From: Karthik Nayak @ 2026-11-12 17:34 UTC (permalink / raw)
To: git; +Cc: Karthik Nayak, gitster
In 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.
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
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(-)
diff --git a/t/t9301-fast-import-notes.sh b/t/t9301-fast-import-notes.sh
index a4b4b0b6cd..f268b4f0c0 100755
--- a/t/t9301-fast-import-notes.sh
+++ b/t/t9301-fast-import-notes.sh
@@ -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 &&
(
diff --git a/t/t9304-fast-import-marks.sh b/t/t9304-fast-import-marks.sh
index 437f9016fa..57050dcfe4 100755
--- a/t/t9304-fast-import-marks.sh
+++ b/t/t9304-fast-import-marks.sh
@@ -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 &&
(
diff --git a/t/t9307-fast-import-validation.sh b/t/t9307-fast-import-validation.sh
index e5cb8c6d00..e9485fed21 100755
--- a/t/t9307-fast-import-validation.sh
+++ b/t/t9307-fast-import-validation.sh
@@ -6,7 +6,7 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
-test_expect_success 'B: fail on invalid blob sha1' '
+test_expect_success 'fail on invalid blob sha1' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -31,7 +31,7 @@ test_expect_success 'B: fail on invalid blob sha1' '
)
'
-test_expect_success 'B: accept branch name "TEMP_TAG"' '
+test_expect_success 'accept branch name "TEMP_TAG"' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -55,7 +55,7 @@ test_expect_success 'B: accept branch name "TEMP_TAG"' '
)
'
-test_expect_success 'B: accept empty committer' '
+test_expect_success 'accept empty committer' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -75,7 +75,7 @@ test_expect_success 'B: accept empty committer' '
)
'
-test_expect_success 'B: reject invalid timezone' '
+test_expect_success 'reject invalid timezone' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -93,7 +93,7 @@ test_expect_success 'B: reject invalid timezone' '
)
'
-test_expect_success 'B: accept invalid timezone with raw-permissive' '
+test_expect_success 'accept invalid timezone with raw-permissive' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -113,7 +113,7 @@ test_expect_success 'B: accept invalid timezone with raw-permissive' '
)
'
-test_expect_success 'B: accept and fixup committer with no name' '
+test_expect_success 'accept and fixup committer with no name' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -133,7 +133,7 @@ test_expect_success 'B: accept and fixup committer with no name' '
)
'
-test_expect_success 'B: fail on invalid committer (1)' '
+test_expect_success 'fail on invalid committer (1)' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -151,7 +151,7 @@ test_expect_success 'B: fail on invalid committer (1)' '
)
'
-test_expect_success 'B: fail on invalid committer (2)' '
+test_expect_success 'fail on invalid committer (2)' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -169,7 +169,7 @@ test_expect_success 'B: fail on invalid committer (2)' '
)
'
-test_expect_success 'B: fail on invalid committer (3)' '
+test_expect_success 'fail on invalid committer (3)' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -187,7 +187,7 @@ test_expect_success 'B: fail on invalid committer (3)' '
)
'
-test_expect_success 'B: fail on invalid committer (4)' '
+test_expect_success 'fail on invalid committer (4)' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -205,7 +205,7 @@ test_expect_success 'B: fail on invalid committer (4)' '
)
'
-test_expect_success 'B: fail on invalid committer (5)' '
+test_expect_success 'fail on invalid committer (5)' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -223,7 +223,7 @@ test_expect_success 'B: fail on invalid committer (5)' '
)
'
-test_expect_success 'B: fail on invalid file path of ..' '
+test_expect_success 'fail on invalid file path of ..' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -248,7 +248,7 @@ test_expect_success 'B: fail on invalid file path of ..' '
)
'
-test_expect_success 'B: fail on invalid file path of .' '
+test_expect_success 'fail on invalid file path of .' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -280,7 +280,7 @@ test_expect_success 'B: fail on invalid file path of .' '
)
'
-test_expect_success WINDOWS 'B: fail on invalid file path of C:' '
+test_expect_success WINDOWS 'fail on invalid file path of C:' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -305,7 +305,7 @@ test_expect_success WINDOWS 'B: fail on invalid file path of C:' '
)
'
-test_expect_success 'B: fail on invalid file path of .git' '
+test_expect_success 'fail on invalid file path of .git' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -330,7 +330,7 @@ test_expect_success 'B: fail on invalid file path of .git' '
)
'
-test_expect_success 'B: fail on invalid file path of .gitmodules' '
+test_expect_success 'fail on invalid file path of .gitmodules' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -355,7 +355,7 @@ test_expect_success 'B: fail on invalid file path of .gitmodules' '
)
'
-test_expect_success 'R: abort on unsupported feature' '
+test_expect_success 'abort on unsupported feature' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -369,7 +369,7 @@ test_expect_success 'R: abort on unsupported feature' '
)
'
-test_expect_success 'R: supported feature is accepted' '
+test_expect_success 'supported feature is accepted' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -383,7 +383,7 @@ test_expect_success 'R: supported feature is accepted' '
)
'
-test_expect_success 'R: abort on receiving feature after data command' '
+test_expect_success 'abort on receiving feature after data command' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -400,7 +400,7 @@ test_expect_success 'R: abort on receiving feature after data command' '
)
'
-test_expect_success 'R: import-marks features forbidden by default' '
+test_expect_success 'import-marks features forbidden by default' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -414,7 +414,7 @@ test_expect_success 'R: import-marks features forbidden by default' '
)
'
-test_expect_success 'R: only one import-marks feature allowed per stream' '
+test_expect_success 'only one import-marks feature allowed per stream' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -431,7 +431,7 @@ test_expect_success 'R: only one import-marks feature allowed per stream' '
)
'
-test_expect_success 'R: export-marks feature forbidden by default' '
+test_expect_success 'export-marks feature forbidden by default' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -442,7 +442,7 @@ test_expect_success 'R: export-marks feature forbidden by default' '
)
'
-test_expect_success 'R: feature ls supported' '
+test_expect_success 'feature ls supported' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -453,7 +453,7 @@ test_expect_success 'R: feature ls supported' '
)
'
-test_expect_success 'R: feature cat-blob supported' '
+test_expect_success 'feature cat-blob supported' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -464,7 +464,7 @@ test_expect_success 'R: feature cat-blob supported' '
)
'
-test_expect_success 'R: cat-blob-fd must be a nonnegative integer' '
+test_expect_success 'cat-blob-fd must be a nonnegative integer' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -474,7 +474,7 @@ test_expect_success 'R: cat-blob-fd must be a nonnegative integer' '
)
'
-test_expect_success 'R: die on unknown option' '
+test_expect_success 'die on unknown option' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -488,7 +488,7 @@ test_expect_success 'R: die on unknown option' '
)
'
-test_expect_success 'R: unknown commandline options are rejected' '\
+test_expect_success 'unknown commandline options are rejected' '\
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -498,7 +498,7 @@ test_expect_success 'R: unknown commandline options are rejected' '\
)
'
-test_expect_success 'R: feature-only names are rejected on the command line' '
+test_expect_success 'feature-only names are rejected on the command line' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -511,7 +511,7 @@ test_expect_success 'R: feature-only names are rejected on the command line' '
)
'
-test_expect_success 'R: die on invalid option argument' '
+test_expect_success 'die on invalid option argument' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -525,7 +525,7 @@ test_expect_success 'R: die on invalid option argument' '
)
'
-test_expect_success 'R: ignore non-git options' '
+test_expect_success 'ignore non-git options' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -618,7 +618,7 @@ setup_marks_repo () {
#
# filemodify, three datarefs
#
-test_expect_success 'S: filemodify with garbage after mark must fail' '
+test_expect_success 'filemodify with garbage after mark must fail' '
setup_marks_repo &&
(
cd repo &&
@@ -636,7 +636,7 @@ test_expect_success 'S: filemodify with garbage after mark must fail' '
'
# inline is misspelled; fast-import thinks it is some unknown dataref
-test_expect_success 'S: filemodify with garbage after inline must fail' '
+test_expect_success 'filemodify with garbage after inline must fail' '
setup_marks_repo &&
(
cd repo &&
@@ -656,7 +656,7 @@ test_expect_success 'S: filemodify with garbage after inline must fail' '
)
'
-test_expect_success 'S: filemodify with garbage after sha1 must fail' '
+test_expect_success 'filemodify with garbage after sha1 must fail' '
setup_marks_repo &&
(
cd repo &&
@@ -677,7 +677,7 @@ test_expect_success 'S: filemodify with garbage after sha1 must fail' '
#
# notemodify, three ways to say dataref
#
-test_expect_success 'S: notemodify with garbage after mark dataref must fail' '
+test_expect_success 'notemodify with garbage after mark dataref must fail' '
setup_marks_repo &&
(
cd repo &&
@@ -694,7 +694,7 @@ test_expect_success 'S: notemodify with garbage after mark dataref must fail' '
)
'
-test_expect_success 'S: notemodify with garbage after inline dataref must fail' '
+test_expect_success 'notemodify with garbage after inline dataref must fail' '
setup_marks_repo &&
(
cd repo &&
@@ -714,7 +714,7 @@ test_expect_success 'S: notemodify with garbage after inline dataref must fail'
)
'
-test_expect_success 'S: notemodify with garbage after sha1 dataref must fail' '
+test_expect_success 'notemodify with garbage after sha1 dataref must fail' '
setup_marks_repo &&
(
cd repo &&
@@ -735,7 +735,7 @@ test_expect_success 'S: notemodify with garbage after sha1 dataref must fail' '
#
# notemodify, mark in commit-ish
#
-test_expect_success 'S: notemodify with garbage after mark commit-ish must fail' '
+test_expect_success 'notemodify with garbage after mark commit-ish must fail' '
setup_marks_repo &&
(
cd repo &&
@@ -755,7 +755,7 @@ test_expect_success 'S: notemodify with garbage after mark commit-ish must fail'
#
# from
#
-test_expect_success 'S: from with garbage after mark must fail' '
+test_expect_success 'from with garbage after mark must fail' '
setup_marks_repo &&
(
cd repo &&
@@ -780,7 +780,7 @@ test_expect_success 'S: from with garbage after mark must fail' '
#
# merge
#
-test_expect_success 'S: merge with garbage after mark must fail' '
+test_expect_success 'merge with garbage after mark must fail' '
setup_marks_repo &&
(
cd repo &&
@@ -814,7 +814,7 @@ test_expect_success 'S: merge with garbage after mark must fail' '
#
# tag, from markref
#
-test_expect_success 'S: tag with garbage after mark must fail' '
+test_expect_success 'tag with garbage after mark must fail' '
setup_marks_repo &&
(
cd repo &&
@@ -834,7 +834,7 @@ test_expect_success 'S: tag with garbage after mark must fail' '
#
# cat-blob markref
#
-test_expect_success 'S: cat-blob with garbage after mark must fail' '
+test_expect_success 'cat-blob with garbage after mark must fail' '
setup_marks_repo &&
(
cd repo &&
@@ -849,7 +849,7 @@ test_expect_success 'S: cat-blob with garbage after mark must fail' '
#
# ls markref
#
-test_expect_success 'S: ls with garbage after mark must fail' '
+test_expect_success 'ls with garbage after mark must fail' '
setup_marks_repo &&
(
cd repo &&
@@ -861,7 +861,7 @@ test_expect_success 'S: ls with garbage after mark must fail' '
)
'
-test_expect_success 'S: ls with garbage after sha1 must fail' '
+test_expect_success 'ls with garbage after sha1 must fail' '
setup_marks_repo &&
(
cd repo &&
@@ -896,7 +896,7 @@ test_expect_success 'S: ls with garbage after sha1 must fail' '
#
test_path_eol_success () {
local test="$1" path="$2" unquoted_path="$3"
- test_expect_success "S: paths at EOL with $test must work" '
+ test_expect_success "paths at EOL with $test must work" '
test_when_finished "git branch -D S-path-eol" &&
git -c core.protectNTFS=false fast-import --export-marks=marks.out <<-EOF >out 2>err &&
@@ -1005,7 +1005,7 @@ test_path_eol_success 'octal escapes' '"\150\151\056\143"' 'hi.c'
#
test_path_space_success () {
local test="$1" path="$2" unquoted_path="$3"
- test_expect_success "S: paths before space with $test must work" '
+ test_expect_success "paths before space with $test must work" '
test_when_finished "git branch -D S-path-space" &&
git -c core.protectNTFS=false fast-import --export-marks=marks.out <<-EOF 2>err &&
@@ -1070,7 +1070,7 @@ test_path_space_success 'octal escapes' '"\150\151\056\143"' 'hi.c'
#
test_path_fail () {
local change="$1" what="$2" prefix="$3" path="$4" suffix="$5" err_grep="$6"
- test_expect_success "S: $change with $what must fail" '
+ test_expect_success "$change with $what must fail" '
test_must_fail git fast-import <<-EOF 2>err &&
blob
mark :1
@@ -1133,7 +1133,7 @@ test_path_eol_fail 'ls (in commit)' 'ls :2 ' path
# When 'ls' has no <dataref>, the <path> must be quoted.
test_path_eol_quoted_fail 'ls (without dataref in commit)' 'ls ' path
-test_expect_success 'E: rfc2822 date, --date-format=raw' '
+test_expect_success 'rfc2822 date, --date-format=raw' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -1156,7 +1156,7 @@ test_expect_success 'E: rfc2822 date, --date-format=raw' '
)
'
-test_expect_success 'E: rfc2822 date, --date-format=rfc2822' '
+test_expect_success 'rfc2822 date, --date-format=rfc2822' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -1193,7 +1193,7 @@ 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 &&
(
@@ -1207,7 +1207,7 @@ 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 &&
(
@@ -1219,7 +1219,7 @@ 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 &&
(
@@ -1232,7 +1232,7 @@ 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 &&
(
@@ -1246,7 +1246,7 @@ 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 &&
(
diff --git a/t/t9308-fast-import-stream.sh b/t/t9308-fast-import-stream.sh
index f0755c9673..8d3cd3c9e6 100755
--- a/t/t9308-fast-import-stream.sh
+++ b/t/t9308-fast-import-stream.sh
@@ -26,7 +26,7 @@ test_expect_success 'truncated stream complains' '
)
'
-test_expect_success !MINGW 'R: print old blob' '
+test_expect_success !MINGW 'print old blob' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -44,7 +44,7 @@ test_expect_success !MINGW 'R: print old blob' '
)
'
-test_expect_success !MINGW 'R: in-stream cat-blob-fd not respected' '
+test_expect_success !MINGW 'in-stream cat-blob-fd not respected' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -71,7 +71,7 @@ test_expect_success !MINGW 'R: in-stream cat-blob-fd not respected' '
)
'
-test_expect_success !MINGW 'R: print mark for new blob' '
+test_expect_success !MINGW 'print mark for new blob' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -90,7 +90,7 @@ test_expect_success !MINGW 'R: print mark for new blob' '
)
'
-test_expect_success !MINGW 'R: print new blob' '
+test_expect_success !MINGW 'print new blob' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -114,7 +114,7 @@ test_expect_success !MINGW 'R: print new blob' '
)
'
-test_expect_success !MINGW 'R: print new blob by sha1' '
+test_expect_success !MINGW 'print new blob by sha1' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -149,7 +149,7 @@ setup_big_file () {
)
}
-test_expect_success 'R: print two blobs to stdout' '
+test_expect_success 'print two blobs to stdout' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -192,7 +192,7 @@ test_expect_success 'R: print two blobs to stdout' '
)
'
-test_expect_success PIPE 'R: copy using cat-file' '
+test_expect_success PIPE 'copy using cat-file' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -244,7 +244,7 @@ test_expect_success PIPE 'R: copy using cat-file' '
)
'
-test_expect_success PIPE 'R: print blob mid-commit' '
+test_expect_success PIPE 'print blob mid-commit' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -281,7 +281,7 @@ test_expect_success PIPE 'R: print blob mid-commit' '
)
'
-test_expect_success PIPE 'R: print staged blob within commit' '
+test_expect_success PIPE 'print staged blob within commit' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -322,7 +322,7 @@ test_expect_success PIPE 'R: print staged blob within commit' '
)
'
-test_expect_success 'R: quiet option results in no stats being output' '
+test_expect_success 'quiet option results in no stats being output' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -341,7 +341,7 @@ test_expect_success 'R: quiet option results in no stats being output' '
)
'
-test_expect_success 'R: feature done means terminating "done" is mandatory' '
+test_expect_success 'feature done means terminating "done" is mandatory' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -352,7 +352,7 @@ test_expect_success 'R: feature done means terminating "done" is mandatory' '
)
'
-test_expect_success 'R: terminating "done" with trailing gibberish is ok' '
+test_expect_success 'terminating "done" with trailing gibberish is ok' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -370,7 +370,7 @@ test_expect_success 'R: terminating "done" with trailing gibberish is ok' '
)
'
-test_expect_success 'R: terminating "done" within commit' '
+test_expect_success 'terminating "done" within commit' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -433,7 +433,7 @@ import_reference_commit () {
INPUT_END
}
-test_expect_success 'O: comments are all skipped' '
+test_expect_success 'comments are all skipped' '
setup_import_repo &&
(
cd repo &&
@@ -485,7 +485,7 @@ test_expect_success 'O: comments are all skipped' '
)
'
-test_expect_success 'O: blank lines not necessary after data commands' '
+test_expect_success 'blank lines not necessary after data commands' '
setup_import_repo &&
(
cd repo &&
@@ -523,7 +523,7 @@ test_expect_success 'O: blank lines not necessary after data commands' '
)
'
-test_expect_success 'O: blank lines not necessary after other commands' '
+test_expect_success 'blank lines not necessary after other commands' '
setup_import_repo &&
(
cd repo &&
@@ -577,7 +577,7 @@ test_expect_success 'O: blank lines not necessary after other commands' '
)
'
-test_expect_success 'O: progress outputs as requested by input' '
+test_expect_success 'progress outputs as requested by input' '
setup_import_repo &&
(
cd repo &&
@@ -616,7 +616,7 @@ test_expect_success 'O: progress outputs as requested by input' '
##
## R: very large blobs
##
-test_expect_success 'R: blob bigger than threshold' '
+test_expect_success 'blob bigger than threshold' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -671,7 +671,7 @@ w_input () {
W_INPUT_END
}
-test_expect_success !MINGW 'W: get-mark & empty orphan commit with no newlines' '
+test_expect_success !MINGW 'get-mark & empty orphan commit with no newlines' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -681,7 +681,7 @@ test_expect_success !MINGW 'W: get-mark & empty orphan commit with no newlines'
)
'
-test_expect_success !MINGW 'W: get-mark & empty orphan commit with one newline' '
+test_expect_success !MINGW 'get-mark & empty orphan commit with one newline' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -691,7 +691,7 @@ test_expect_success !MINGW 'W: get-mark & empty orphan commit with one newline'
)
'
-test_expect_success !MINGW 'W: get-mark & empty orphan commit with ugly second newline' '
+test_expect_success !MINGW 'get-mark & empty orphan commit with ugly second newline' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -707,7 +707,7 @@ test_expect_success !MINGW 'W: get-mark & empty orphan commit with ugly second n
)
'
-test_expect_success !MINGW 'W: get-mark & empty orphan commit with erroneous third newline' '
+test_expect_success !MINGW 'get-mark & empty orphan commit with erroneous third newline' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -718,7 +718,7 @@ test_expect_success !MINGW 'W: get-mark & empty orphan commit with erroneous thi
)
'
-test_expect_success ICONV 'X: handling encoding' '
+test_expect_success ICONV 'handling encoding' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -740,7 +740,7 @@ test_expect_success ICONV 'X: handling encoding' '
)
'
-test_expect_success 'X: replace ref that becomes useless is removed' '
+test_expect_success 'replace ref that becomes useless is removed' '
test_when_finished "rm -rf testrepo" &&
git init -qb main testrepo &&
(
@@ -771,7 +771,7 @@ test_expect_success 'X: replace ref that becomes useless is removed' '
for root in '""' ''
do
- test_expect_success "T: ls root ($root) tree" '
+ test_expect_success "ls root ($root) tree" '
test_when_finished "rm -rf repo" &&
git init repo &&
(
@@ -790,7 +790,7 @@ do
'
done
-test_expect_success 'I: export-pack-edges' '
+test_expect_success 'export-pack-edges' '
test_when_finished "rm -rf repo" &&
git init -b main repo &&
(
@@ -819,7 +819,7 @@ 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 &&
(
@@ -830,7 +830,7 @@ 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 &&
(
@@ -859,7 +859,7 @@ 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 &&
(
@@ -873,7 +873,7 @@ 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 &&
(
diff --git a/t/t9309-fast-import-checkpoint.sh b/t/t9309-fast-import-checkpoint.sh
index 64674dcf83..5c1e80c240 100755
--- a/t/t9309-fast-import-checkpoint.sh
+++ b/t/t9309-fast-import-checkpoint.sh
@@ -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
diff --git a/t/t9310-fast-import-submodule.sh b/t/t9310-fast-import-submodule.sh
index 74c20d39c5..23bbf2db85 100755
--- a/t/t9310-fast-import-submodule.sh
+++ b/t/t9310-fast-import-submodule.sh
@@ -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
diff --git a/t/t9311-fast-import-refs.sh b/t/t9311-fast-import-refs.sh
index 2bb8ac1d46..3283fe77c0 100755
--- a/t/t9311-fast-import-refs.sh
+++ b/t/t9311-fast-import-refs.sh
@@ -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 &&
(
--
2.56.GIT
^ permalink raw reply related [flat|nested] 45+ messages in thread