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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Aug 13 2021, Teng Long wrote:

> 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@xxxxxxxxx>
> ---
>  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);
>  		}
>  	}

Isn't this adding support for:

    [fetch]
    uriProtocols

I.e. the case where it's an existing key that we'll get a NULL from,
ditto the ="" case.

Partially this issue pre-dates your series, but I think code here is
rather unclear because we keep using the same comma-delimited
representation we want in the protocol for too long in fetch-pack.c et
al.

But also, if we're going to make http/https the default, wouldn't
parsing config/options it, and then interpreting the empty list as that
default, as opposed to injecting it? Or have I misunderstood the intent
here...?




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux