t7419, t7420: use test_cmp_config instead of grepping .gitmodules

We have a test function to verify config files. Use it as it's more precise. Signed-off-by: Jan Alexander Steffens (heftig) <heftig@archlinux.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jan Alexander Steffens (heftig) committed Oct 3, 2023 at 20:50 UTC 5fc880632d5e9ef6fd40a5ef9b5e01d61cdc320a
2 files changed +6 -6
t/t7419-submodule-set-branch.sh
+5 -5
@@ -44,14 +44,14 @@ test_expect_success 'submodule config cache setup' '
44
45 test_expect_success 'ensure submodule branch is unset' '
46 (cd super &&
47 - ! grep branch .gitmodules
47 + test_cmp_config "" -f .gitmodules --default "" submodule.submodule.branch
48 )
49 '
50
51 test_expect_success 'test submodule set-branch --branch' '
52 (cd super &&
53 git submodule set-branch --branch topic submodule &&
54 - grep "branch = topic" .gitmodules &&
54 + test_cmp_config topic -f .gitmodules submodule.submodule.branch &&
55 git submodule update --remote &&
56 cat <<-\EOF >expect &&
57 b
@@ -64,7 +64,7 @@ test_expect_success 'test submodule set-branch --branch' '
64 test_expect_success 'test submodule set-branch --default' '
65 (cd super &&
66 git submodule set-branch --default submodule &&
67 - ! grep branch .gitmodules &&
67 + test_cmp_config "" -f .gitmodules --default "" submodule.submodule.branch &&
68 git submodule update --remote &&
69 cat <<-\EOF >expect &&
70 a
@@ -77,7 +77,7 @@ test_expect_success 'test submodule set-branch --default' '
77 test_expect_success 'test submodule set-branch -b' '
78 (cd super &&
79 git submodule set-branch -b topic submodule &&
80 - grep "branch = topic" .gitmodules &&
80 + test_cmp_config topic -f .gitmodules submodule.submodule.branch &&
81 git submodule update --remote &&
82 cat <<-\EOF >expect &&
83 b
@@ -90,7 +90,7 @@ test_expect_success 'test submodule set-branch -b' '
90 test_expect_success 'test submodule set-branch -d' '
91 (cd super &&
92 git submodule set-branch -d submodule &&
93 - ! grep branch .gitmodules &&
93 + test_cmp_config "" -f .gitmodules --default "" submodule.submodule.branch &&
94 git submodule update --remote &&
95 cat <<-\EOF >expect &&
96 a
t/t7420-submodule-set-url.sh
+1 -1
@@ -49,7 +49,7 @@ test_expect_success 'test submodule set-url' '
49 cd super &&
50 test_must_fail git submodule update --remote &&
51 git submodule set-url submodule ../newsubmodule &&
52 - grep -F "url = ../newsubmodule" .gitmodules &&
52 + test_cmp_config ../newsubmodule -f .gitmodules submodule.submodule.url &&
53 git submodule update --remote
54 ) &&
55 git -C super/submodule show >actual &&