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

Re: [PATCH] protocol: treat unrecognized protocol.version setting as 0

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 28, 2018, 17:55 UTC
Message-ID
<xmqq7eqxm22w.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20180228012207.GB251290@aiede.svl.corp.google.com>
Jonathan Nieder <jrnieder@gmail.com> writes:
Show 8 quoted lines
>> I wonder if it's better to specify multiple versions. If v2 is not
>> recognized by this git but v0 is, then it can pick that up. But if you
>> explicitly tell it to choose between v2 and v3 only and it does not
>> understand either, then it dies. Not sure if this is a good idea
>> though.
>
> Interesting thought.  Something roughly like this (on top of the patch
> this is a reply to)?

I am OK with that, i.e. allow the user to tell us what is acceptable and pick from them, as long as the blind "we do not know so let's fall back to v0" is removed.

Show 36 quoted lines
>
> diff --git i/protocol.c w/protocol.c
> index ce9c634a3a..6aa8857a11 100644
> --- i/protocol.c
> +++ w/protocol.c
> @@ -1,4 +1,5 @@
>  #include "cache.h"
> +#include "string-list.h"
>  #include "config.h"
>  #include "protocol.h"
>  
> @@ -14,14 +15,18 @@ static enum protocol_version parse_protocol_version(const char *value)
>  
>  enum protocol_version get_protocol_version_config(void)
>  {
> -	const char *value;
> -	if (!git_config_get_string_const("protocol.version", &value)) {
> -		enum protocol_version version = parse_protocol_version(value);
> -		if (version != protocol_unknown_version)
> -			return version;
> +	const struct string_list *values;
> +	const struct string_list_item *value;
> +	enum protocol_version result = protocol_v0;
> +
> +	values = git_config_get_value_multi("protocol.version");
> +	for_each_string_list_item(value, values) {
> +		enum protocol_version v = parse_protocol_version(value->string);
> +		if (v != protocol_unknown_version)
> +			result = v;
>  	}
>  
> -	return protocol_v0;
> +	return result;
>  }
>  
>  enum protocol_version determine_protocol_version_server(void)
Previous: Jonathan NiederNext: Junio C Hamano
Message 6 of 9 in “protocol: treat unrecognized protocol.version setting as 0”
  1. protocol: treat unrecognized protocol.version setting as 0Jonathan Nieder, Feb 28, 2018
  2. Brandon WilliamsFeb 28, 2018
  3. Duy NguyenFeb 28, 2018
  4. Brandon WilliamsFeb 28, 2018
  5. Jonathan NiederFeb 28, 2018
  6. Junio C HamanoFeb 28, 2018
  7. Junio C HamanoFeb 28, 2018
  8. Junio C HamanoFeb 28, 2018
  9. Jonathan NiederFeb 28, 2018

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.