@matheusbsbs / matheus-bagliano / commits / c0b65ea8fd
Fork 0

t7400: make hash size independent

Instead of using cut with hard-coded hash sizes, use cut with fields, or where that's not possible, sed with $OID_REGEX, so that the tests are independent of hash size. 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 c0b65ea8fda9959c6bb4036c7bff22d5e769973c
1 file changed +13 -13
t/t7400-submodule-basic.sh
+13 -13
@@ -1231,7 +1231,7 @@ test_expect_success 'submodule helper list is not confused by common prefixes' '
1231 git submodule add /dir1/b dir1/b &&
1232 git submodule add /dir2/b dir2/b &&
1233 git commit -m "first submodule commit" &&
1234 - git submodule--helper list dir1/b |cut -c51- >actual &&
1234 + git submodule--helper list dir1/b | cut -f 2 >actual &&
1235 echo "dir1/b" >expect &&
1236 test_cmp expect actual
1237 '
@@ -1260,7 +1260,7 @@ test_expect_success 'submodule update --init with a specification' '
1260 pwd=$(pwd) &&
1261 git clone file://"$pwd"/multisuper multisuper_clone &&
1262 git -C multisuper_clone submodule update --init . ":(exclude)sub0" &&
1263 - git -C multisuper_clone submodule status |cut -c 1,43- >actual &&
1263 + git -C multisuper_clone submodule status | sed "s/$OID_REGEX //" >actual &&
1264 test_cmp expect actual
1265 '
1266
@@ -1271,7 +1271,7 @@ test_expect_success 'submodule update --init with submodule.active set' '
1271 git -C multisuper_clone config submodule.active "." &&
1272 git -C multisuper_clone config --add submodule.active ":(exclude)sub0" &&
1273 git -C multisuper_clone submodule update --init &&
1274 - git -C multisuper_clone submodule status |cut -c 1,43- >actual &&
1274 + git -C multisuper_clone submodule status | sed "s/$OID_REGEX //" >actual &&
1275 test_cmp expect actual
1276 '
1277
@@ -1290,7 +1290,7 @@ test_expect_success 'submodule update and setting submodule.<name>.active' '
1290 -sub3
1291 EOF
1292 git -C multisuper_clone submodule update &&
1293 - git -C multisuper_clone submodule status |cut -c 1,43- >actual &&
1293 + git -C multisuper_clone submodule status | sed "s/$OID_REGEX //" >actual &&
1294 test_cmp expect actual
1295 '
1296
@@ -1307,12 +1307,12 @@ test_expect_success 'clone active submodule without submodule url set' '
1307 git submodule update &&
1308 git submodule status >actual_raw &&
1309
1310 - cut -c 1,43- actual_raw >actual &&
1310 + cut -d" " -f3- actual_raw >actual &&
1311 cat >expect <<-\EOF &&
1312 - sub0 (test2)
1313 - sub1 (test2)
1314 - sub2 (test2)
1315 - sub3 (test2)
1312 + sub0 (test2)
1313 + sub1 (test2)
1314 + sub2 (test2)
1315 + sub3 (test2)
1316 EOF
1317 test_cmp expect actual
1318 )
@@ -1328,7 +1328,7 @@ test_expect_success 'clone --recurse-submodules with a pathspec works' '
1328 EOF
1329
1330 git clone --recurse-submodules="sub0" multisuper multisuper_clone &&
1331 - git -C multisuper_clone submodule status |cut -c1,43- >actual &&
1331 + git -C multisuper_clone submodule status | sed "s/$OID_REGEX //" >actual &&
1332 test_cmp expected actual
1333 '
1334
@@ -1345,7 +1345,7 @@ test_expect_success 'clone with multiple --recurse-submodules options' '
1345 --recurse-submodules=":(exclude)sub0" \
1346 --recurse-submodules=":(exclude)sub2" \
1347 multisuper multisuper_clone &&
1348 - git -C multisuper_clone submodule status |cut -c1,43- >actual &&
1348 + git -C multisuper_clone submodule status | sed "s/$OID_REGEX //" >actual &&
1349 test_cmp expect actual
1350 '
1351
@@ -1373,7 +1373,7 @@ test_expect_success 'clone and subsequent updates correctly auto-initialize subm
1373 --recurse-submodules=":(exclude)sub4" \
1374 multisuper multisuper_clone &&
1375
1376 - git -C multisuper_clone submodule status |cut -c1,43- >actual &&
1376 + git -C multisuper_clone submodule status | sed "s/$OID_REGEX //" >actual &&
1377 test_cmp expect actual &&
1378
1379 git -C multisuper submodule add ../sub1 sub4 &&
@@ -1382,7 +1382,7 @@ test_expect_success 'clone and subsequent updates correctly auto-initialize subm
1382 # obtain the new superproject
1383 git -C multisuper_clone pull &&
1384 git -C multisuper_clone submodule update --init &&
1385 - git -C multisuper_clone submodule status |cut -c1,43- >actual &&
1385 + git -C multisuper_clone submodule status | sed "s/$OID_REGEX //" >actual &&
1386 test_cmp expect2 actual
1387 '
1388