Skip to content

Commit c0b65ea

Browse files
bk2204gitster
authored andcommitted
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 <[email protected]> Reviewed-by: Eric Sunshine <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d62607d commit c0b65ea

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

t/t7400-submodule-basic.sh

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,7 +1231,7 @@ test_expect_success 'submodule helper list is not confused by common prefixes' '
12311231
git submodule add /dir1/b dir1/b &&
12321232
git submodule add /dir2/b dir2/b &&
12331233
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 &&
12351235
echo "dir1/b" >expect &&
12361236
test_cmp expect actual
12371237
'
@@ -1260,7 +1260,7 @@ test_expect_success 'submodule update --init with a specification' '
12601260
pwd=$(pwd) &&
12611261
git clone file://"$pwd"/multisuper multisuper_clone &&
12621262
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 &&
12641264
test_cmp expect actual
12651265
'
12661266

@@ -1271,7 +1271,7 @@ test_expect_success 'submodule update --init with submodule.active set' '
12711271
git -C multisuper_clone config submodule.active "." &&
12721272
git -C multisuper_clone config --add submodule.active ":(exclude)sub0" &&
12731273
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 &&
12751275
test_cmp expect actual
12761276
'
12771277

@@ -1290,7 +1290,7 @@ test_expect_success 'submodule update and setting submodule.<name>.active' '
12901290
-sub3
12911291
EOF
12921292
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 &&
12941294
test_cmp expect actual
12951295
'
12961296

@@ -1307,12 +1307,12 @@ test_expect_success 'clone active submodule without submodule url set' '
13071307
git submodule update &&
13081308
git submodule status >actual_raw &&
13091309
1310-
cut -c 1,43- actual_raw >actual &&
1310+
cut -d" " -f3- actual_raw >actual &&
13111311
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)
13161316
EOF
13171317
test_cmp expect actual
13181318
)
@@ -1328,7 +1328,7 @@ test_expect_success 'clone --recurse-submodules with a pathspec works' '
13281328
EOF
13291329
13301330
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 &&
13321332
test_cmp expected actual
13331333
'
13341334

@@ -1345,7 +1345,7 @@ test_expect_success 'clone with multiple --recurse-submodules options' '
13451345
--recurse-submodules=":(exclude)sub0" \
13461346
--recurse-submodules=":(exclude)sub2" \
13471347
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 &&
13491349
test_cmp expect actual
13501350
'
13511351

@@ -1373,7 +1373,7 @@ test_expect_success 'clone and subsequent updates correctly auto-initialize subm
13731373
--recurse-submodules=":(exclude)sub4" \
13741374
multisuper multisuper_clone &&
13751375
1376-
git -C multisuper_clone submodule status |cut -c1,43- >actual &&
1376+
git -C multisuper_clone submodule status | sed "s/$OID_REGEX //" >actual &&
13771377
test_cmp expect actual &&
13781378
13791379
git -C multisuper submodule add ../sub1 sub4 &&
@@ -1382,7 +1382,7 @@ test_expect_success 'clone and subsequent updates correctly auto-initialize subm
13821382
# obtain the new superproject
13831383
git -C multisuper_clone pull &&
13841384
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 &&
13861386
test_cmp expect2 actual
13871387
'
13881388

0 commit comments

Comments
 (0)