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

[PATCH] setup: Only allow extenions.objectFormat to be specified once

From
EBEric W. Biederman <ebiederm@gmail.com>
Date
Sep 26, 2023, 16:01 UTC
Message-ID
<87h6ngapqb.fsf@gmail.froward.int.ebiederm.org>

Today there is no sanity checking of what happens when extensions.objectFormat is specified multiple times. Catch confused git configurations by only allowing this option to be specified once.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
---
 setup.c | 8 ++++++++
 1 file changed, 8 insertions(+)
diff --git a/setup.c b/setup.c
index 18927a847b86..ef9f79b8885e 100644
--- a/setup.c
+++ b/setup.c
@@ -580,6 +580,7 @@ static enum extension_result handle_extension(const char *var,
 	if (!strcmp(ext, "noop-v1")) {
 		return EXTENSION_OK;
 	} else if (!strcmp(ext, "objectformat")) {
+		struct string_list_item *item;
 		int format;
 
 		if (!value)
@@ -588,6 +589,13 @@ static enum extension_result handle_extension(const char *var,
 		if (format == GIT_HASH_UNKNOWN)
 			return error(_("invalid value for '%s': '%s'"),
 				     "extensions.objectformat", value);
+		/* Only support objectFormat being specified once. */
+		for_each_string_list_item(item, &data->v1_only_extensions) {
+			if (!strcmp(item->string, "objectformat"))
+				return error(_("'%s' already specified as '%s'"),
+					"extensions.objectformat",
+					hash_algos[data->hash_algo].name);
+		}
 		data->hash_algo = format;
 		return EXTENSION_OK;
 	}
-- 
2.41.0
Next: Junio C Hamano
Message 1 of 4 in “setup: Only allow extenions.objectFormat to be specified once”
  1. setup: Only allow extenions.objectFormat to be specified onceEric W. Biederman, Sep 26, 2023
  2. Junio C HamanoSep 26, 2023
  3. Eric W. BiedermanSep 27, 2023
  4. Junio C HamanoSep 27, 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.