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

[PATCH v1 1/3] packfile-uri: http and https as default value of `--uri-protocol`

From
Teng Long <dyroneteng@gmail.com>
Date
Aug 13, 2021, 09:14 UTC
Message-ID
<0754ea6472f2665a5fe77de080434d3734c67259.1628845748.git.dyroneteng@gmail.com>
In-Reply-To
<cover.1628845748.git.dyroneteng@gmail.com>

HTTP(S) is usually one of the most common protocols, using "http" and "https" as the default parameter values of `--uri-protocol`, which can simplify the use of packfile-uri feature on client side when run a git-clone or git-fetch.

Signed-off-by: Teng Long <dyroneteng@gmail.com>
---
 builtin/pack-objects.c | 18 +++++++++++++++---
 fetch-pack.c           | 13 ++++++++-----
 2 files changed, 23 insertions(+), 8 deletions(-)
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index de00adbb9e..5f6db92a4c 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -3892,6 +3892,18 @@ static int option_parse_unpack_unreachable(const struct option *opt,
 	return 0;
 }
 
+static int option_parse_uri_protocol(const struct option *opt,
+				      const char *arg, int unset)
+{
+	if (!arg) {
+		string_list_append(&uri_protocols, "http");
+		string_list_append(&uri_protocols, "https");
+	} else {
+		string_list_append(&uri_protocols, arg);
+	}
+	return 0;
+}
+
 int cmd_pack_objects(int argc, const char **argv, const char *prefix)
 {
 	int use_internal_rev_list = 0;
@@ -3995,9 +4007,9 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
 			 N_("do not pack objects in promisor packfiles")),
 		OPT_BOOL(0, "delta-islands", &use_delta_islands,
 			 N_("respect islands during delta compression")),
-		OPT_STRING_LIST(0, "uri-protocol", &uri_protocols,
-				N_("protocol"),
-				N_("exclude any configured uploadpack.blobpackfileuri with this protocol")),
+		OPT_CALLBACK_F(0, "uri-protocol", NULL, N_("protocol"),
+			       N_("exclude any configured uploadpack.blobpackfileuri with this protocol"),
+			       PARSE_OPT_OPTARG, option_parse_uri_protocol),
 		OPT_END(),
 	};
 
diff --git a/fetch-pack.c b/fetch-pack.c
index c135635e34..511a892d4c 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -1755,11 +1755,14 @@ static void fetch_pack_config(void)
 	git_config_get_bool("transfer.fsckobjects", &transfer_fsck_objects);
 	git_config_get_bool("transfer.advertisesid", &advertise_sid);
 	if (!uri_protocols.nr) {
-		char *str;
-
-		if (!git_config_get_string("fetch.uriprotocols", &str) && str) {
-			string_list_split(&uri_protocols, str, ',', -1);
-			free(str);
+		const char *value;
+
+		if (!git_config_get_value("fetch.uriprotocols", &value)) {
+			if (!value || !strcmp(value, "")) {
+				string_list_append(&uri_protocols, "http");
+				string_list_append(&uri_protocols, "https");
+			} else
+				string_list_split(&uri_protocols, value, ',', -1);
 		}
 	}
 
-- 
2.32.0.1.g0de8fe24d1.dirty
Previous: Teng LongNext: Ævar Arnfjörð Bjarmason
Message 2 of 7 in “packfile-uri: http and https as default value of `--uri-protocol`”
  1. 0/3 packfile-uri: http and https as default value of `--uri-protocol`Teng Long, Aug 13, 2021
  2. 1/3 packfile-uri: http and https as default value of `--uri-protocol`Teng Long, Aug 13, 2021
  3. Ævar Arnfjörð BjarmasonAug 21, 2021
  4. 2/3 git-pack-objects.txt: introduce `--uri-protocol` optionTeng Long, Aug 13, 2021
  5. Ævar Arnfjörð BjarmasonAug 21, 2021
  6. 3/3 t5702: `fetch.uriprotocols` is configured without valueTeng Long, Aug 13, 2021
  7. Ævar Arnfjörð BjarmasonAug 21, 2021

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.