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

[PATCH] upload-pack: fix how ALLOW_ANY_SHA1 flag is disabled

From
Piotr Szlazak via GitGitGadget <gitgitgadget@gmail.com>
Date
Oct 16, 2024, 21:06 UTC
Message-ID
<pull.1814.git.git.1729112794671.gitgitgadget@gmail.com>
From: Piotr Szlazak <piotr.szlazak@gmail.com>

ALLOW_ANY_SHA1 implies ALLOW_TIP_SHA1 and ALLOW_REACHABLE_SHA1. Yet ALLOW_TIP_SHA1 and ALLOW_REACHABLE_SHA1 flags can be enabled independently. If uploadpack.allowAnySHA1InWant is not enabled in config file, other flags should not be disabled together with ALLOW_ANY_SHA1. They should be kept enabled if they were separately enabled in config file with they respective options.

Signed-off-by: Piotr Szlazak <piotr.szlazak@gmail.com>
---
    upload-pack: fix how ALLOW_ANY_SHA1 flag is disabled
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1814%2Fpszlazak%2Fupload-pack-allow-flags-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1814/pszlazak/upload-pack-allow-flags-v1
Pull-Request: https://github.com/git/git/pull/1814
 upload-pack.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/upload-pack.c b/upload-pack.c
index 6d6e0f9f980..cf99b228719 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -53,6 +53,7 @@ enum allow_uor {
 	/* Allow request of a sha1 if it is reachable from a ref (possibly hidden ref). */
 	ALLOW_REACHABLE_SHA1 = 0x02,
 	/* Allow request of any sha1. Implies ALLOW_TIP_SHA1 and ALLOW_REACHABLE_SHA1. */
+	/* As this flag implies other two flags, be careful when it must be disabled. */
 	ALLOW_ANY_SHA1 = 0x07
 };
 
@@ -1368,7 +1369,7 @@ static int upload_pack_config(const char *var, const char *value,
 		if (git_config_bool(var, value))
 			data->allow_uor |= ALLOW_ANY_SHA1;
 		else
-			data->allow_uor &= ~ALLOW_ANY_SHA1;
+			data->allow_uor &= ~(ALLOW_ANY_SHA1 -(ALLOW_TIP_SHA1|ALLOW_REACHABLE_SHA1));
 	} else if (!strcmp("uploadpack.keepalive", var)) {
 		data->keepalive = git_config_int(var, value, ctx->kvi);
 		if (!data->keepalive)

base-commit: ef8ce8f3d4344fd3af049c17eeba5cd20d98b69f
-- 
gitgitgadget
Next: Taylor Blau
Message 1 of 14 in “upload-pack: fix how ALLOW_ANY_SHA1 flag is disabled”
  1. upload-pack: fix how ALLOW_ANY_SHA1 flag is disabledPiotr Szlazak via GitGitGadget, Oct 16, 2024
  2. Taylor BlauOct 16, 2024
  3. Jeff KingOct 17, 2024
  4. Taylor BlauOct 17, 2024
  5. Piotr SzlazakOct 17, 2024
  6. Taylor BlauOct 17, 2024
  7. Jeff KingOct 18, 2024
  8. Taylor BlauOct 18, 2024
  9. doc: document how uploadpack.allowAnySHA1InWant impact other allow optionsPiotr Szlazak via GitGitGadget, Oct 19, 2024
  10. Piotr SzlazakOct 19, 2024
  11. Piotr SzlazakOct 21, 2024
  12. Jeff KingOct 21, 2024
  13. Taylor BlauOct 21, 2024
  14. Taylor BlauOct 21, 2024

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.