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

[PATCH v4 2/3] repo-settings: fix error handling for unknown values

From
Elijah Newren via GitGitGadget <gitgitgadget@gmail.com>
Date
Feb 2, 2022, 03:42 UTC
Message-ID
<23f692b81be26072f44609df8c78d1b8d81f01d3.1643773361.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.1131.v4.git.1643773361.gitgitgadget@gmail.com>
From: Elijah Newren <newren@gmail.com>

In commit af3a67de01 ("negotiator: unknown fetch.negotiationAlgorithm should error out", 2018-08-01), error handling for an unknown fetch.negotiationAlgorithm was added with the code die()ing. This was also added to the documentation for the fetch.negotiationAlgorithm option, to make it explicit that the code would die on unknown values.

This behavior was lost with commit aaf633c2ad ("repo-settings: create feature.experimental setting", 2019-08-13). Restore it so that the behavior again matches the documentation.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 repo-settings.c       | 2 ++
 t/t5500-fetch-pack.sh | 7 +++++++
 2 files changed, 9 insertions(+)
diff --git a/repo-settings.c b/repo-settings.c
index 38c10f9977b..41e1c30845f 100644
--- a/repo-settings.c
+++ b/repo-settings.c
@@ -87,6 +87,8 @@ void prepare_repo_settings(struct repository *r)
 			r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_NOOP;
 		else if (!strcasecmp(strval, "default"))
 			r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_DEFAULT;
+		else
+			die("unknown fetch negotiation algorithm '%s'", strval);
 	}
 
 	/*
diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh
index 666502ed832..41ea9f25de6 100755
--- a/t/t5500-fetch-pack.sh
+++ b/t/t5500-fetch-pack.sh
@@ -971,6 +971,13 @@ test_expect_success 'same as last but with config overrides' '
 		-c fetch.negotiationAlgorithm=default
 '
 
+test_expect_success 'ensure bogus fetch.negotiationAlgorithm yields error' '
+	test_when_finished rm -rf clientv0 &&
+	cp -r client clientv0 &&
+	test_must_fail git -C clientv0 --fetch.negotiationAlgorithm=bogus \
+		       fetch origin server_has both_have_2
+'
+
 test_expect_success 'filtering by size' '
 	rm -rf server client &&
 	test_create_repo server &&
-- 
gitgitgadget
Previous: Elijah Newren via GitGitGadgetNext: Elijah Newren via GitGitGadget
Message 21 of 23 in “repo-settings: fix checking for fetch.negotiationAlgorithm=default”
  1. repo-settings: fix checking for fetch.negotiationAlgorithm=defaultElijah Newren via GitGitGadget, Jan 28, 2022
  2. Ævar Arnfjörð BjarmasonJan 28, 2022
  3. Elijah NewrenJan 29, 2022
  4. Ævar Arnfjörð BjarmasonJan 29, 2022
  5. Junio C HamanoJan 31, 2022
  6. Elijah NewrenJan 31, 2022
  7. Ævar Arnfjörð BjarmasonJan 31, 2022
  8. Elijah NewrenJan 31, 2022
  9. Jonathan TanFeb 1, 2022
  10. Junio C HamanoJan 31, 2022
  11. repo-settings: fix checking for fetch.negotiationAlgorithm=defaultElijah Newren via GitGitGadget, Jan 29, 2022
  12. 0/3 repo-settings: fix checking for fetch.negotiationAlgorithm=defaultElijah Newren via GitGitGadget, Feb 1, 2022
  13. 1/3 repo-settings: fix checking for fetch.negotiationAlgorithm=defaultElijah Newren via GitGitGadget, Feb 1, 2022
  14. Junio C HamanoFeb 1, 2022
  15. 2/3 repo-settings: fix error handling for unknown valuesElijah Newren via GitGitGadget, Feb 1, 2022
  16. Junio C HamanoFeb 1, 2022
  17. 3/3 repo-settings: name the default fetch.negotiationAlgorithm 'consecutive'Elijah Newren via GitGitGadget, Feb 1, 2022
  18. Junio C HamanoFeb 1, 2022
  19. 0/3 repo-settings: fix checking for fetch.negotiationAlgorithm=defaultElijah Newren via GitGitGadget, Feb 2, 2022
  20. 1/3 repo-settings: fix checking for fetch.negotiationAlgorithm=defaultElijah Newren via GitGitGadget, Feb 2, 2022
  21. 2/3 repo-settings: fix error handling for unknown valuesElijah Newren via GitGitGadget, Feb 2, 2022
  22. 3/3 repo-settings: rename the traditional default fetch.negotiationAlgorithmElijah Newren via GitGitGadget, Feb 2, 2022
  23. Junio C HamanoFeb 2, 2022

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.