git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 4/6] t7419, t7420: use test_cmp_config instead of grepping .gitmodules

From
Jan Alexander Steffens (heftig) <heftig@archlinux.org>
Date
Nov 21, 2023, 20:32 UTC
Message-ID
<20231121203413.176414-4-heftig@archlinux.org>
In-Reply-To
<20231121203413.176414-1-heftig@archlinux.org>

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>
---
 t/t7419-submodule-set-branch.sh | 10 +++++-----
 t/t7420-submodule-set-url.sh    |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/t/t7419-submodule-set-branch.sh b/t/t7419-submodule-set-branch.sh
index 5ac16d0eb7..3cd30865a7 100755
--- a/t/t7419-submodule-set-branch.sh
+++ b/t/t7419-submodule-set-branch.sh
@@ -44,53 +44,53 @@ test_expect_success 'submodule config cache setup' '
 
 test_expect_success 'ensure submodule branch is unset' '
 	(cd super &&
-		! grep branch .gitmodules
+		test_cmp_config "" -f .gitmodules --default "" submodule.submodule.branch
 	)
 '
 
 test_expect_success 'test submodule set-branch --branch' '
 	(cd super &&
 		git submodule set-branch --branch topic submodule &&
-		grep "branch = topic" .gitmodules &&
+		test_cmp_config topic -f .gitmodules submodule.submodule.branch &&
 		git submodule update --remote &&
 		cat <<-\EOF >expect &&
 		b
 		EOF
 		git -C submodule show -s --pretty=%s >actual &&
 		test_cmp expect actual
 	)
 '
 
 test_expect_success 'test submodule set-branch --default' '
 	(cd super &&
 		git submodule set-branch --default submodule &&
-		! grep branch .gitmodules &&
+		test_cmp_config "" -f .gitmodules --default "" submodule.submodule.branch &&
 		git submodule update --remote &&
 		cat <<-\EOF >expect &&
 		a
 		EOF
 		git -C submodule show -s --pretty=%s >actual &&
 		test_cmp expect actual
 	)
 '
 
 test_expect_success 'test submodule set-branch -b' '
 	(cd super &&
 		git submodule set-branch -b topic submodule &&
-		grep "branch = topic" .gitmodules &&
+		test_cmp_config topic -f .gitmodules submodule.submodule.branch &&
 		git submodule update --remote &&
 		cat <<-\EOF >expect &&
 		b
 		EOF
 		git -C submodule show -s --pretty=%s >actual &&
 		test_cmp expect actual
 	)
 '
 
 test_expect_success 'test submodule set-branch -d' '
 	(cd super &&
 		git submodule set-branch -d submodule &&
-		! grep branch .gitmodules &&
+		test_cmp_config "" -f .gitmodules --default "" submodule.submodule.branch &&
 		git submodule update --remote &&
 		cat <<-\EOF >expect &&
 		a
diff --git a/t/t7420-submodule-set-url.sh b/t/t7420-submodule-set-url.sh
index d6bf62b3ac..aa63d806fe 100755
--- a/t/t7420-submodule-set-url.sh
+++ b/t/t7420-submodule-set-url.sh
@@ -49,7 +49,7 @@ test_expect_success 'test submodule set-url' '
 		cd super &&
 		test_must_fail git submodule update --remote &&
 		git submodule set-url submodule ../newsubmodule &&
-		grep -F "url = ../newsubmodule" .gitmodules &&
+		test_cmp_config ../newsubmodule -f .gitmodules submodule.submodule.url &&
 		git submodule update --remote
 	) &&
 	git -C super/submodule show >actual &&
-- 
2.43.0
Previous: Jan Alexander Steffens (heftig)Next: Jan Alexander Steffens (heftig)
Message 14 of 19 in “git submodule set-url does not sync when name != path”
  1. Jan Alexander Steffens (heftig)Jul 24, 2023
  2. Bug: git submodule set-url does not handle name != path correctlyJan Alexander Steffens (heftig), Sep 9, 2023
  3. 1/6 submodule--helper: use submodule_from_path in set-{url,branch}Jan Alexander Steffens (heftig), Oct 3, 2023
  4. 2/6 submodule--helper: return error from set-url when modifying failedJan Alexander Steffens (heftig), Oct 3, 2023
  5. Junio C HamanoOct 3, 2023
  6. 5/6 t7419: Test that we correctly handle renamed submodulesJan Alexander Steffens (heftig), Oct 3, 2023
  7. 4/6 t7419, t7420: Use test_cmp_config instead of grepping .gitmodulesJan Alexander Steffens (heftig), Oct 3, 2023
  8. 3/6 t7419: Actually test the branch switchingJan Alexander Steffens (heftig), Oct 3, 2023
  9. Junio C HamanoOct 4, 2023
  10. 6/6 t7420: Test that we correctly handle renamed submodulesJan Alexander Steffens (heftig), Oct 3, 2023
  11. Junio C HamanoOct 4, 2023
  12. 1/6 submodule--helper: use submodule_from_path in set-{url,branch}Jan Alexander Steffens (heftig), Nov 21, 2023
  13. 2/6 submodule--helper: return error from set-url when modifying failedJan Alexander Steffens (heftig), Nov 21, 2023
  14. 4/6 t7419, t7420: use test_cmp_config instead of grepping .gitmodulesJan Alexander Steffens (heftig), Nov 21, 2023
  15. 3/6 t7419: actually test the branch switchingJan Alexander Steffens (heftig), Nov 21, 2023
  16. 5/6 t7419: test that we correctly handle renamed submodulesJan Alexander Steffens (heftig), Nov 21, 2023
  17. 6/6 t7420: test that we correctly handle renamed submodulesJan Alexander Steffens (heftig), Nov 21, 2023
  18. Junio C HamanoNov 22, 2023
  19. Jan Alexander Steffens (heftig)Nov 22, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.