@matheusbsbs / matheus-bagliano / commits / 22f182442d
Fork 0

t9300: abstract away SHA-1-specific constants

Adjust the test so that it computes variables for object IDs instead of using hard-coded hashes. In addition, use cut to filter out the object IDs and verify only the information that we're really interested in. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Reviewed-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

brian m. carlson committed Jul 29, 2020 at 23:14 UTC 22f182442d8095ac1ece8c7dc48bf1ab1091425e
1 file changed +59 -49
t/t9300-fast-import.sh
+59 -49
@@ -284,8 +284,9 @@ test_expect_success 'A: verify pack' '
284 '
285
286 test_expect_success 'A: verify diff' '
287 + copy=$(git rev-parse --verify master:file2) &&
288 cat >expect <<-EOF &&
288 - :000000 100755 0000000000000000000000000000000000000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 A copy-of-file2
289 + :000000 100755 0000000000000000000000000000000000000000 $copy A copy-of-file2
290 EOF
291 git diff-tree -M -r master verify--import-marks >actual &&
292 compare_diff_raw expect actual &&
@@ -528,6 +529,7 @@ test_expect_success 'B: fail on invalid committer (5)' '
529 test_expect_success 'C: incremental import create pack from stdin' '
530 newf=$(echo hi newf | git hash-object -w --stdin) &&
531 oldf=$(git rev-parse --verify master:file2) &&
532 + thrf=$(git rev-parse --verify master:file3) &&
533 test_tick &&
534 cat >input <<-INPUT_END &&
535 commit refs/heads/branch
@@ -570,10 +572,11 @@ test_expect_success 'C: verify commit' '
572 '
573
574 test_expect_success 'C: validate rename result' '
575 + zero=$ZERO_OID &&
576 cat >expect <<-EOF &&
574 - :000000 100755 0000000000000000000000000000000000000000 f1fb5da718392694d0076d677d6d0e364c79b0bc A file2/newf
575 - :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2 file2/oldf
576 - :100644 000000 0d92e9f3374ae2947c23aa477cbc68ce598135f1 0000000000000000000000000000000000000000 D file3
577 + :000000 100755 $zero $newf A file2/newf
578 + :100644 100644 $oldf $oldf R100 file2 file2/oldf
579 + :100644 000000 $thrf $zero D file3
580 EOF
581 git diff-tree -M -r master branch >actual &&
582 compare_diff_raw expect actual
@@ -614,9 +617,11 @@ test_expect_success 'D: verify pack' '
617 '
618
619 test_expect_success 'D: validate new files added' '
620 + f5id=$(echo "$file5_data" | git hash-object --stdin) &&
621 + f6id=$(echo "$file6_data" | git hash-object --stdin) &&
622 cat >expect <<-EOF &&
618 - :000000 100755 0000000000000000000000000000000000000000 e74b7d465e52746be2b4bae983670711e6e66657 A newdir/exec.sh
619 - :000000 100644 0000000000000000000000000000000000000000 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 A newdir/interesting
623 + :000000 100755 0000000000000000000000000000000000000000 $f6id A newdir/exec.sh
624 + :000000 100644 0000000000000000000000000000000000000000 $f5id A newdir/interesting
625 EOF
626 git diff-tree -M -r branch^ branch >actual &&
627 compare_diff_raw expect actual
@@ -779,12 +784,13 @@ test_expect_success 'H: verify pack' '
784 '
785
786 test_expect_success 'H: validate old files removed, new files added' '
787 + f4id=$(git rev-parse HEAD:file4) &&
788 cat >expect <<-EOF &&
783 - :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file2/newf
784 - :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file2/oldf
785 - :100755 000000 85df50785d62d3b05ab03d9cbf7e4a0b49449730 0000000000000000000000000000000000000000 D file4
786 - :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting h/e/l/lo
787 - :100755 000000 e74b7d465e52746be2b4bae983670711e6e66657 0000000000000000000000000000000000000000 D newdir/exec.sh
789 + :100755 000000 $newf $zero D file2/newf
790 + :100644 000000 $oldf $zero D file2/oldf
791 + :100755 000000 $f4id $zero D file4
792 + :100644 100644 $f5id $f5id R100 newdir/interesting h/e/l/lo
793 + :100755 000000 $f6id $zero D newdir/exec.sh
794 EOF
795 git diff-tree -M -r H^ H >actual &&
796 compare_diff_raw expect actual
@@ -935,14 +941,15 @@ test_expect_success 'L: verify internal tree sorting' '
941 INPUT_END
942
943 cat >expect <<-EXPECT_END &&
938 - :100644 100644 4268632... 55d3a52... M b.
939 - :040000 040000 0ae5cac... 443c768... M b
940 - :100644 100644 4268632... 55d3a52... M ba
944 + :100644 100644 M b.
945 + :040000 040000 M b
946 + :100644 100644 M ba
947 EXPECT_END
948
949 git fast-import <input &&
950 GIT_PRINT_SHA1_ELLIPSIS="yes" git diff-tree --abbrev --raw L^ L >output &&
945 - test_cmp expect output
951 + cut -d" " -f1,2,5 output >actual &&
952 + test_cmp expect actual
953 '
954
955 test_expect_success 'L: nested tree copy does not corrupt deltas' '
@@ -1004,7 +1011,7 @@ test_expect_success 'M: rename file in same subdirectory' '
1011 INPUT_END
1012
1013 cat >expect <<-EOF &&
1007 - :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf file2/n.e.w.f
1014 + :100755 100755 $newf $newf R100 file2/newf file2/n.e.w.f
1015 EOF
1016 git fast-import <input &&
1017 git diff-tree -M -r M1^ M1 >actual &&
@@ -1025,7 +1032,7 @@ test_expect_success 'M: rename file to new subdirectory' '
1032 INPUT_END
1033
1034 cat >expect <<-EOF &&
1028 - :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf i/am/new/to/you
1035 + :100755 100755 $newf $newf R100 file2/newf i/am/new/to/you
1036 EOF
1037 git fast-import <input &&
1038 git diff-tree -M -r M2^ M2 >actual &&
@@ -1046,7 +1053,7 @@ test_expect_success 'M: rename subdirectory to new subdirectory' '
1053 INPUT_END
1054
1055 cat >expect <<-EOF &&
1049 - :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you other/sub/am/new/to/you
1056 + :100755 100755 $newf $newf R100 i/am/new/to/you other/sub/am/new/to/you
1057 EOF
1058 git fast-import <input &&
1059 git diff-tree -M -r M3^ M3 >actual &&
@@ -1067,11 +1074,11 @@ test_expect_success 'M: rename root to subdirectory' '
1074 INPUT_END
1075
1076 cat >expect <<-EOF &&
1070 - :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2/oldf sub/file2/oldf
1071 - :100755 100755 85df50785d62d3b05ab03d9cbf7e4a0b49449730 85df50785d62d3b05ab03d9cbf7e4a0b49449730 R100 file4 sub/file4
1072 - :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you sub/i/am/new/to/you
1073 - :100755 100755 e74b7d465e52746be2b4bae983670711e6e66657 e74b7d465e52746be2b4bae983670711e6e66657 R100 newdir/exec.sh sub/newdir/exec.sh
1074 - :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting sub/newdir/interesting
1077 + :100644 100644 $oldf $oldf R100 file2/oldf sub/file2/oldf
1078 + :100755 100755 $f4id $f4id R100 file4 sub/file4
1079 + :100755 100755 $newf $newf R100 i/am/new/to/you sub/i/am/new/to/you
1080 + :100755 100755 $f6id $f6id R100 newdir/exec.sh sub/newdir/exec.sh
1081 + :100644 100644 $f5id $f5id R100 newdir/interesting sub/newdir/interesting
1082 EOF
1083 git fast-import <input &&
1084 git diff-tree -M -r M4^ M4 >actual &&
@@ -1097,7 +1104,7 @@ test_expect_success 'N: copy file in same subdirectory' '
1104 INPUT_END
1105
1106 cat >expect <<-EOF &&
1100 - :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file2/n.e.w.f
1107 + :100755 100755 $newf $newf C100 file2/newf file2/n.e.w.f
1108 EOF
1109 git fast-import <input &&
1110 git diff-tree -C --find-copies-harder -r N1^ N1 >actual &&
@@ -1129,9 +1136,9 @@ test_expect_success 'N: copy then modify subdirectory' '
1136 INPUT_END
1137
1138 cat >expect <<-EOF &&
1132 - :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
1133 - :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1134 - :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1139 + :100644 100644 $f5id $f5id C100 newdir/interesting file3/file5
1140 + :100755 100755 $newf $newf C100 file2/newf file3/newf
1141 + :100644 100644 $oldf $oldf C100 file2/oldf file3/oldf
1142 EOF
1143 git fast-import <input &&
1144 git diff-tree -C --find-copies-harder -r N2^^ N2 >actual &&
@@ -1162,9 +1169,9 @@ test_expect_success 'N: copy dirty subdirectory' '
1169 '
1170
1171 test_expect_success 'N: copy directory by id' '
1165 - cat >expect <<-\EOF &&
1166 - :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1167 - :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1172 + cat >expect <<-EOF &&
1173 + :100755 100755 $newf $newf C100 file2/newf file3/newf
1174 + :100644 100644 $oldf $oldf C100 file2/oldf file3/oldf
1175 EOF
1176 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1177 cat >input <<-INPUT_END &&
@@ -1183,9 +1190,9 @@ test_expect_success 'N: copy directory by id' '
1190 '
1191
1192 test_expect_success PIPE 'N: read and copy directory' '
1186 - cat >expect <<-\EOF &&
1187 - :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1188 - :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1193 + cat >expect <<-EOF &&
1194 + :100755 100755 $newf $newf C100 file2/newf file3/newf
1195 + :100644 100644 $oldf $oldf C100 file2/oldf file3/oldf
1196 EOF
1197 git update-ref -d refs/heads/N4 &&
1198 rm -f backflow &&
@@ -1254,9 +1261,9 @@ test_expect_success PIPE 'N: empty directory reads as missing' '
1261 '
1262
1263 test_expect_success 'N: copy root directory by tree hash' '
1257 - cat >expect <<-\EOF &&
1258 - :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file3/newf
1259 - :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file3/oldf
1264 + cat >expect <<-EOF &&
1265 + :100755 000000 $newf $zero D file3/newf
1266 + :100644 000000 $oldf $zero D file3/oldf
1267 EOF
1268 root=$(git rev-parse refs/heads/branch^0^{tree}) &&
1269 cat >input <<-INPUT_END &&
@@ -1275,12 +1282,12 @@ test_expect_success 'N: copy root directory by tree hash' '
1282 '
1283
1284 test_expect_success 'N: copy root by path' '
1278 - cat >expect <<-\EOF &&
1279 - :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf oldroot/file2/newf
1280 - :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf oldroot/file2/oldf
1281 - :100755 100755 85df50785d62d3b05ab03d9cbf7e4a0b49449730 85df50785d62d3b05ab03d9cbf7e4a0b49449730 C100 file4 oldroot/file4
1282 - :100755 100755 e74b7d465e52746be2b4bae983670711e6e66657 e74b7d465e52746be2b4bae983670711e6e66657 C100 newdir/exec.sh oldroot/newdir/exec.sh
1283 - :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting oldroot/newdir/interesting
1285 + cat >expect <<-EOF &&
1286 + :100755 100755 $newf $newf C100 file2/newf oldroot/file2/newf
1287 + :100644 100644 $oldf $oldf C100 file2/oldf oldroot/file2/oldf
1288 + :100755 100755 $f4id $f4id C100 file4 oldroot/file4
1289 + :100755 100755 $f6id $f6id C100 newdir/exec.sh oldroot/newdir/exec.sh
1290 + :100644 100644 $f5id $f5id C100 newdir/interesting oldroot/newdir/interesting
1291 EOF
1292 cat >input <<-INPUT_END &&
1293 commit refs/heads/N-copy-root-path
@@ -1340,10 +1347,10 @@ test_expect_success 'N: delete directory by copying' '
1347 '
1348
1349 test_expect_success 'N: modify copied tree' '
1343 - cat >expect <<-\EOF &&
1344 - :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
1345 - :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1346 - :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1350 + cat >expect <<-EOF &&
1351 + :100644 100644 $f5id $f5id C100 newdir/interesting file3/file5
1352 + :100755 100755 $newf $newf C100 file2/newf file3/newf
1353 + :100644 100644 $oldf $oldf C100 file2/oldf file3/oldf
1354 EOF
1355 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1356 cat >input <<-INPUT_END &&
@@ -3117,6 +3124,9 @@ test_expect_success 'U: initialize for U tests' '
3124
3125 INPUT_END
3126
3127 + f7id=$(echo "blob 1" | git hash-object --stdin) &&
3128 + f8id=$(echo "sleep well" | git hash-object --stdin) &&
3129 + f9id=$(echo "au revoir" | git hash-object --stdin) &&
3130 git fast-import <input
3131 '
3132
@@ -3137,7 +3147,7 @@ test_expect_success 'U: filedelete file succeeds' '
3147
3148 test_expect_success 'U: validate file delete result' '
3149 cat >expect <<-EOF &&
3140 - :100644 000000 2907ebb4bf85d91bf0716bb3bd8a68ef48d6da76 0000000000000000000000000000000000000000 D good/night.txt
3150 + :100644 000000 $f8id $ZERO_OID D good/night.txt
3151 EOF
3152
3153 git diff-tree -M -r U^1 U >actual &&
@@ -3162,7 +3172,7 @@ test_expect_success 'U: filedelete directory succeeds' '
3172
3173 test_expect_success 'U: validate directory delete result' '
3174 cat >expect <<-EOF &&
3165 - :100644 000000 69cb75792f55123d8389c156b0b41c2ff00ed507 0000000000000000000000000000000000000000 D good/bye.txt
3175 + :100644 000000 $f9id $ZERO_OID D good/bye.txt
3176 EOF
3177
3178 git diff-tree -M -r U^1 U >actual &&
@@ -3187,7 +3197,7 @@ test_expect_success 'U: filedelete root succeeds' '
3197
3198 test_expect_success 'U: validate root delete result' '
3199 cat >expect <<-EOF &&
3190 - :100644 000000 c18147dc648481eeb65dc5e66628429a64843327 0000000000000000000000000000000000000000 D hello.c
3200 + :100644 000000 $f7id $ZERO_OID D hello.c
3201 EOF
3202
3203 git diff-tree -M -r U^1 U >actual &&