]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t7400: make hash size independent
authorbrian m. carlson <sandals@crustytoothpaste.net>
Wed, 29 Jul 2020 23:14:03 +0000 (23:14 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 30 Jul 2020 16:16:47 +0000 (09:16 -0700)
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>
t/t7400-submodule-basic.sh

index 956e17abb3d7d5fb480c84c977067837c6baca61..fec7e0299dec2614cad243c2520423fe56ce6605 100755 (executable)
@@ -1231,7 +1231,7 @@ test_expect_success 'submodule helper list is not confused by common prefixes' '
        git submodule add /dir1/b dir1/b &&
        git submodule add /dir2/b dir2/b &&
        git commit -m "first submodule commit" &&
-       git submodule--helper list dir1/b |cut -c51- >actual &&
+       git submodule--helper list dir1/b | cut -f 2 >actual &&
        echo "dir1/b" >expect &&
        test_cmp expect actual
 '
@@ -1260,7 +1260,7 @@ test_expect_success 'submodule update --init with a specification' '
        pwd=$(pwd) &&
        git clone file://"$pwd"/multisuper multisuper_clone &&
        git -C multisuper_clone submodule update --init . ":(exclude)sub0" &&
-       git -C multisuper_clone submodule status |cut -c 1,43- >actual &&
+       git -C multisuper_clone submodule status | sed "s/$OID_REGEX //" >actual &&
        test_cmp expect actual
 '
 
@@ -1271,7 +1271,7 @@ test_expect_success 'submodule update --init with submodule.active set' '
        git -C multisuper_clone config submodule.active "." &&
        git -C multisuper_clone config --add submodule.active ":(exclude)sub0" &&
        git -C multisuper_clone submodule update --init &&
-       git -C multisuper_clone submodule status |cut -c 1,43- >actual &&
+       git -C multisuper_clone submodule status | sed "s/$OID_REGEX //" >actual &&
        test_cmp expect actual
 '
 
@@ -1290,7 +1290,7 @@ test_expect_success 'submodule update and setting submodule.<name>.active' '
        -sub3
        EOF
        git -C multisuper_clone submodule update &&
-       git -C multisuper_clone submodule status |cut -c 1,43- >actual &&
+       git -C multisuper_clone submodule status | sed "s/$OID_REGEX //" >actual &&
        test_cmp expect actual
 '
 
@@ -1307,12 +1307,12 @@ test_expect_success 'clone active submodule without submodule url set' '
                git submodule update &&
                git submodule status >actual_raw &&
 
-               cut -c 1,43- actual_raw >actual &&
+               cut -d" " -f3- actual_raw >actual &&
                cat >expect <<-\EOF &&
-                sub0 (test2)
-                sub1 (test2)
-                sub2 (test2)
-                sub3 (test2)
+               sub0 (test2)
+               sub1 (test2)
+               sub2 (test2)
+               sub3 (test2)
                EOF
                test_cmp expect actual
        )
@@ -1328,7 +1328,7 @@ test_expect_success 'clone --recurse-submodules with a pathspec works' '
        EOF
 
        git clone --recurse-submodules="sub0" multisuper multisuper_clone &&
-       git -C multisuper_clone submodule status |cut -c1,43- >actual &&
+       git -C multisuper_clone submodule status | sed "s/$OID_REGEX //" >actual &&
        test_cmp expected actual
 '
 
@@ -1345,7 +1345,7 @@ test_expect_success 'clone with multiple --recurse-submodules options' '
                  --recurse-submodules=":(exclude)sub0" \
                  --recurse-submodules=":(exclude)sub2" \
                  multisuper multisuper_clone &&
-       git -C multisuper_clone submodule status |cut -c1,43- >actual &&
+       git -C multisuper_clone submodule status | sed "s/$OID_REGEX //" >actual &&
        test_cmp expect actual
 '
 
@@ -1373,7 +1373,7 @@ test_expect_success 'clone and subsequent updates correctly auto-initialize subm
                  --recurse-submodules=":(exclude)sub4" \
                  multisuper multisuper_clone &&
 
-       git -C multisuper_clone submodule status |cut -c1,43- >actual &&
+       git -C multisuper_clone submodule status | sed "s/$OID_REGEX //" >actual &&
        test_cmp expect actual &&
 
        git -C multisuper submodule add ../sub1 sub4 &&
@@ -1382,7 +1382,7 @@ test_expect_success 'clone and subsequent updates correctly auto-initialize subm
        # obtain the new superproject
        git -C multisuper_clone pull &&
        git -C multisuper_clone submodule update --init &&
-       git -C multisuper_clone submodule status |cut -c1,43- >actual &&
+       git -C multisuper_clone submodule status | sed "s/$OID_REGEX //" >actual &&
        test_cmp expect2 actual
 '