Skip to content

Commit 8e75941

Browse files
committed
Merge branch 'cc/t9350-cleanup'
Test clean-up. * cc/t9350-cleanup: t9350: redirect input to only fast-import
2 parents 41ca6a9 + 5345ca1 commit 8e75941

File tree

1 file changed

+91
-124
lines changed

1 file changed

+91
-124
lines changed

t/t9350-fast-export.sh

Lines changed: 91 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,11 @@ test_expect_success 'fast-export | fast-import' '
4848
mkdir new &&
4949
git --git-dir=new/.git init &&
5050
git fast-export --all >actual &&
51-
(cd new &&
52-
git fast-import &&
53-
test $MAIN = $(git rev-parse --verify refs/heads/main) &&
54-
test $REIN = $(git rev-parse --verify refs/tags/rein) &&
55-
test $WER = $(git rev-parse --verify refs/heads/wer) &&
56-
test $MUSS = $(git rev-parse --verify refs/tags/muss)) <actual
51+
git -C new fast-import <actual &&
52+
test $MAIN = $(git -C new rev-parse --verify refs/heads/main) &&
53+
test $REIN = $(git -C new rev-parse --verify refs/tags/rein) &&
54+
test $WER = $(git -C new rev-parse --verify refs/heads/wer) &&
55+
test $MUSS = $(git -C new rev-parse --verify refs/tags/muss)
5756
5857
'
5958

@@ -87,13 +86,11 @@ test_expect_success 'fast-export --mark-tags ^muss^{commit} muss' '
8786
test_expect_success 'fast-export main~2..main' '
8887
8988
git fast-export main~2..main >actual &&
90-
sed "s/main/partial/" actual |
91-
(cd new &&
92-
git fast-import &&
93-
test $MAIN != $(git rev-parse --verify refs/heads/partial) &&
94-
git diff --exit-code main partial &&
95-
git diff --exit-code main^ partial^ &&
96-
test_must_fail git rev-parse partial~2)
89+
sed "s/main/partial/" actual | git -C new fast-import &&
90+
test $MAIN != $(git -C new rev-parse --verify refs/heads/partial) &&
91+
git -C new diff --exit-code main partial &&
92+
git -C new diff --exit-code main^ partial^ &&
93+
test_must_fail git -C new rev-parse partial~2
9794
9895
'
9996

@@ -102,10 +99,8 @@ test_expect_success 'fast-export --reference-excluded-parents main~2..main' '
10299
git fast-export --reference-excluded-parents main~2..main >actual &&
103100
grep commit.refs/heads/main actual >commit-count &&
104101
test_line_count = 2 commit-count &&
105-
sed "s/main/rewrite/" actual |
106-
(cd new &&
107-
git fast-import &&
108-
test $MAIN = $(git rev-parse --verify refs/heads/rewrite))
102+
sed "s/main/rewrite/" actual | git -C new fast-import &&
103+
test $MAIN = $(git -C new rev-parse --verify refs/heads/rewrite)
109104
'
110105

111106
test_expect_success 'fast-export --show-original-ids' '
@@ -133,20 +128,19 @@ test_expect_success ICONV 'reencoding iso-8859-7' '
133128
echo rosten >file &&
134129
git commit -s -F "$TEST_DIRECTORY/t9350/simple-iso-8859-7-commit-message.txt" file &&
135130
git fast-export --reencode=yes wer^..wer >iso-8859-7.fi &&
136-
sed "s/wer/i18n/" iso-8859-7.fi |
137-
(cd new &&
138-
git fast-import &&
139-
# The commit object, if not re-encoded, would be 200 bytes plus hash.
140-
# Removing the "encoding iso-8859-7\n" header drops 20 bytes.
141-
# Re-encoding the Pi character from \xF0 (\360) in iso-8859-7
142-
# to \xCF\x80 (\317\200) in UTF-8 adds a byte. Check for
143-
# the expected size.
144-
test $(($(test_oid hexsz) + 181)) -eq "$(git cat-file -s i18n)" &&
145-
# ...and for the expected translation of bytes.
146-
git cat-file commit i18n >actual &&
147-
grep $(printf "\317\200") actual &&
148-
# Also make sure the commit does not have the "encoding" header
149-
! grep ^encoding actual)
131+
sed "s/wer/i18n/" iso-8859-7.fi | git -C new fast-import &&
132+
133+
# The commit object, if not re-encoded, would be 200 bytes plus hash.
134+
# Removing the "encoding iso-8859-7\n" header drops 20 bytes.
135+
# Re-encoding the Pi character from \xF0 (\360) in iso-8859-7
136+
# to \xCF\x80 (\317\200) in UTF-8 adds a byte. Check for
137+
# the expected size.
138+
test $(($(test_oid hexsz) + 181)) -eq "$(git -C new cat-file -s i18n)" &&
139+
# ...and for the expected translation of bytes.
140+
git -C new cat-file commit i18n >actual &&
141+
grep $(printf "\317\200") actual &&
142+
# Also make sure the commit does not have the "encoding" header
143+
! grep ^encoding actual
150144
'
151145

152146
test_expect_success 'aborting on iso-8859-7' '
@@ -165,20 +159,19 @@ test_expect_success 'preserving iso-8859-7' '
165159
echo rosten >file &&
166160
git commit -s -F "$TEST_DIRECTORY/t9350/simple-iso-8859-7-commit-message.txt" file &&
167161
git fast-export --reencode=no wer^..wer >iso-8859-7.fi &&
168-
sed "s/wer/i18n-no-recoding/" iso-8859-7.fi |
169-
(cd new &&
170-
git fast-import &&
171-
# The commit object, if not re-encoded, is 200 bytes plus hash.
172-
# Removing the "encoding iso-8859-7\n" header would drops 20
173-
# bytes. Re-encoding the Pi character from \xF0 (\360) in
174-
# iso-8859-7 to \xCF\x80 (\317\200) in UTF-8 adds a byte.
175-
# Check for the expected size...
176-
test $(($(test_oid hexsz) + 200)) -eq "$(git cat-file -s i18n-no-recoding)" &&
177-
# ...as well as the expected byte.
178-
git cat-file commit i18n-no-recoding >actual &&
179-
grep $(printf "\360") actual &&
180-
# Also make sure the commit has the "encoding" header
181-
grep ^encoding actual)
162+
sed "s/wer/i18n-no-recoding/" iso-8859-7.fi | git -C new fast-import &&
163+
164+
# The commit object, if not re-encoded, is 200 bytes plus hash.
165+
# Removing the "encoding iso-8859-7\n" header would drops 20
166+
# bytes. Re-encoding the Pi character from \xF0 (\360) in
167+
# iso-8859-7 to \xCF\x80 (\317\200) in UTF-8 adds a byte.
168+
# Check for the expected size...
169+
test $(($(test_oid hexsz) + 200)) -eq "$(git -C new cat-file -s i18n-no-recoding)" &&
170+
# ...as well as the expected byte.
171+
git -C new cat-file commit i18n-no-recoding >actual &&
172+
grep $(printf "\360") actual &&
173+
# Also make sure the commit has the "encoding" header
174+
grep ^encoding actual
182175
'
183176

184177
test_expect_success 'encoding preserved if reencoding fails' '
@@ -188,18 +181,17 @@ test_expect_success 'encoding preserved if reencoding fails' '
188181
echo rosten >file &&
189182
git commit -s -F "$TEST_DIRECTORY/t9350/broken-iso-8859-7-commit-message.txt" file &&
190183
git fast-export --reencode=yes wer^..wer >iso-8859-7.fi &&
191-
sed "s/wer/i18n-invalid/" iso-8859-7.fi |
192-
(cd new &&
193-
git fast-import &&
194-
git cat-file commit i18n-invalid >actual &&
195-
# Make sure the commit still has the encoding header
196-
grep ^encoding actual &&
197-
# Verify that the commit has the expected size; i.e.
198-
# that no bytes were re-encoded to a different encoding.
199-
test $(($(test_oid hexsz) + 212)) -eq "$(git cat-file -s i18n-invalid)" &&
200-
# ...and check for the original special bytes
201-
grep $(printf "\360") actual &&
202-
grep $(printf "\377") actual)
184+
sed "s/wer/i18n-invalid/" iso-8859-7.fi | git -C new fast-import &&
185+
git -C new cat-file commit i18n-invalid >actual &&
186+
187+
# Make sure the commit still has the encoding header
188+
grep ^encoding actual &&
189+
# Verify that the commit has the expected size; i.e.
190+
# that no bytes were re-encoded to a different encoding.
191+
test $(($(test_oid hexsz) + 212)) -eq "$(git -C new cat-file -s i18n-invalid)" &&
192+
# ...and check for the original special bytes
193+
grep $(printf "\360") actual &&
194+
grep $(printf "\377") actual
203195
'
204196

205197
test_expect_success 'import/export-marks' '
@@ -316,12 +308,9 @@ test_expect_success GPG 'signed-commits=verbatim' '
316308
git fast-export --signed-commits=verbatim --reencode=no commit-signing >output &&
317309
test_grep -E "^gpgsig $GIT_DEFAULT_HASH openpgp" output &&
318310
grep "encoding ISO-8859-1" output &&
319-
(
320-
cd new &&
321-
git fast-import &&
322-
STRIPPED=$(git rev-parse --verify refs/heads/commit-signing) &&
323-
test $COMMIT_SIGNING = $STRIPPED
324-
) <output
311+
git -C new fast-import <output &&
312+
STRIPPED=$(git -C new rev-parse --verify refs/heads/commit-signing) &&
313+
test $COMMIT_SIGNING = $STRIPPED
325314
326315
'
327316

@@ -331,12 +320,9 @@ test_expect_success GPG 'signed-commits=warn-verbatim' '
331320
test_grep -E "^gpgsig $GIT_DEFAULT_HASH openpgp" output &&
332321
grep "encoding ISO-8859-1" output &&
333322
test -s err &&
334-
(
335-
cd new &&
336-
git fast-import &&
337-
STRIPPED=$(git rev-parse --verify refs/heads/commit-signing) &&
338-
test $COMMIT_SIGNING = $STRIPPED
339-
) <output
323+
git -C new fast-import <output &&
324+
STRIPPED=$(git -C new rev-parse --verify refs/heads/commit-signing) &&
325+
test $COMMIT_SIGNING = $STRIPPED
340326
341327
'
342328

@@ -345,12 +331,9 @@ test_expect_success GPG 'signed-commits=strip' '
345331
git fast-export --signed-commits=strip --reencode=no commit-signing >output &&
346332
! grep ^gpgsig output &&
347333
grep "^encoding ISO-8859-1" output &&
348-
sed "s/commit-signing/commit-strip-signing/" output | (
349-
cd new &&
350-
git fast-import &&
351-
STRIPPED=$(git rev-parse --verify refs/heads/commit-strip-signing) &&
352-
test $COMMIT_SIGNING != $STRIPPED
353-
)
334+
sed "s/commit-signing/commit-strip-signing/" output | git -C new fast-import &&
335+
STRIPPED=$(git -C new rev-parse --verify refs/heads/commit-strip-signing) &&
336+
test $COMMIT_SIGNING != $STRIPPED
354337
355338
'
356339

@@ -360,12 +343,9 @@ test_expect_success GPG 'signed-commits=warn-strip' '
360343
! grep ^gpgsig output &&
361344
grep "^encoding ISO-8859-1" output &&
362345
test -s err &&
363-
sed "s/commit-signing/commit-strip-signing/" output | (
364-
cd new &&
365-
git fast-import &&
366-
STRIPPED=$(git rev-parse --verify refs/heads/commit-strip-signing) &&
367-
test $COMMIT_SIGNING != $STRIPPED
368-
)
346+
sed "s/commit-signing/commit-strip-signing/" output | git -C new fast-import &&
347+
STRIPPED=$(git -C new rev-parse --verify refs/heads/commit-strip-signing) &&
348+
test $COMMIT_SIGNING != $STRIPPED
369349
370350
'
371351

@@ -386,14 +366,11 @@ test_expect_success GPGSM 'round-trip X.509 signed commit' '
386366
387367
git fast-export --signed-commits=verbatim x509-signing >output &&
388368
test_grep -E "^gpgsig $GIT_DEFAULT_HASH x509" output &&
389-
(
390-
cd new &&
391-
git fast-import &&
392-
git cat-file commit refs/heads/x509-signing >actual &&
393-
grep "^gpgsig" actual &&
394-
IMPORTED=$(git rev-parse refs/heads/x509-signing) &&
395-
test $X509_COMMIT = $IMPORTED
396-
) <output
369+
git -C new fast-import <output &&
370+
git -C new cat-file commit refs/heads/x509-signing >actual &&
371+
grep "^gpgsig" actual &&
372+
IMPORTED=$(git -C new rev-parse refs/heads/x509-signing) &&
373+
test $X509_COMMIT = $IMPORTED
397374
398375
'
399376

@@ -414,14 +391,11 @@ test_expect_success GPGSSH 'round-trip SSH signed commit' '
414391
415392
git fast-export --signed-commits=verbatim ssh-signing >output &&
416393
test_grep -E "^gpgsig $GIT_DEFAULT_HASH ssh" output &&
417-
(
418-
cd new &&
419-
git fast-import &&
420-
git cat-file commit refs/heads/ssh-signing >actual &&
421-
grep "^gpgsig" actual &&
422-
IMPORTED=$(git rev-parse refs/heads/ssh-signing) &&
423-
test $SSH_COMMIT = $IMPORTED
424-
) <output
394+
git -C new fast-import <output &&
395+
git -C new cat-file commit refs/heads/ssh-signing >actual &&
396+
grep "^gpgsig" actual &&
397+
IMPORTED=$(git -C new rev-parse refs/heads/ssh-signing) &&
398+
test $SSH_COMMIT = $IMPORTED
425399
426400
'
427401

@@ -461,14 +435,13 @@ test_expect_success 'submodule fast-export | fast-import' '
461435
mkdir new &&
462436
git --git-dir=new/.git init &&
463437
git fast-export --signed-tags=strip --all >actual &&
464-
(cd new &&
465-
git fast-import &&
466-
test "$SUBENT1" = "$(git ls-tree refs/heads/main^ sub)" &&
467-
test "$SUBENT2" = "$(git ls-tree refs/heads/main sub)" &&
468-
git checkout main &&
469-
git submodule init &&
470-
git submodule update &&
471-
cmp sub/file ../sub/file) <actual
438+
git -C new fast-import <actual &&
439+
test "$SUBENT1" = "$(git -C new ls-tree refs/heads/main^ sub)" &&
440+
test "$SUBENT2" = "$(git -C new ls-tree refs/heads/main sub)" &&
441+
git -C new checkout main &&
442+
git -C new submodule init &&
443+
git -C new submodule update &&
444+
cmp new/sub/file sub/file
472445
473446
'
474447

@@ -510,10 +483,8 @@ test_expect_success 'fast-export -C -C | fast-import' '
510483
git --git-dir=new/.git init &&
511484
git fast-export -C -C --signed-tags=strip --all > output &&
512485
grep "^C file2 file4\$" output &&
513-
cat output |
514-
(cd new &&
515-
git fast-import &&
516-
test $ENTRY = $(git rev-parse --verify refs/heads/copy))
486+
git -C new fast-import <output &&
487+
test $ENTRY = $(git -C new rev-parse --verify refs/heads/copy)
517488
518489
'
519490

@@ -986,21 +957,17 @@ test_expect_success GPG 'export and import of doubly signed commit' '
986957
git -C explicit-sha256 fast-export --signed-commits=verbatim dual-signed >output &&
987958
test_grep -E "^gpgsig sha1 openpgp" output &&
988959
test_grep -E "^gpgsig sha256 openpgp" output &&
989-
990-
(
991-
cd new &&
992-
git fast-import &&
993-
git cat-file commit refs/heads/dual-signed >actual &&
994-
test_grep -E "^gpgsig " actual &&
995-
test_grep -E "^gpgsig-sha256 " actual &&
996-
IMPORTED=$(git rev-parse refs/heads/dual-signed) &&
997-
if test "$GIT_DEFAULT_HASH" = "sha1"
998-
then
999-
test $SHA1_B = $IMPORTED
1000-
else
1001-
test $SHA256_B = $IMPORTED
1002-
fi
1003-
) <output
960+
git -C new fast-import <output &&
961+
git -C new cat-file commit refs/heads/dual-signed >actual &&
962+
test_grep -E "^gpgsig " actual &&
963+
test_grep -E "^gpgsig-sha256 " actual &&
964+
IMPORTED=$(git -C new rev-parse refs/heads/dual-signed) &&
965+
if test "$GIT_DEFAULT_HASH" = "sha1"
966+
then
967+
test $SHA1_B = $IMPORTED
968+
else
969+
test $SHA256_B = $IMPORTED
970+
fi
1004971
'
1005972

1006973
test_done

0 commit comments

Comments
 (0)