Subject: Re: [PATCH v2 01/10] object.c: stop supporting len == -1 in type_from_string_gently()

From: Ævar Arnfjörð Bjarmason <[email-masked]>
Date: Sun, 28 Mar 2021 17:46:39 +0200

On Sun, Mar 28 2021, Junio C Hamano wrote:

> Ævar Arnfjörð Bjarmason  <[email-masked]> writes:
>
>> Change the type_from_string() macro into a function and drop the
>> support for passing len < 0.
>>
>> Support for len < 0 was added in fe8e3b71805 (Refactor
>> type_from_string() to allow continuing after detecting an error,
>> 2014-09-10), but no callers use that form. Let's drop it to simplify
>> this, and in preparation for simplifying these even further.
>
> Given the recent fallout of oversimplifying we've seen in other
> topic, this line of thinking makes me nauseated, but let's see how
> well this works this time around.

Do you mean related to tree-walk.[ch]? But yeah, this step doesn't
striclly need to be taken, but seemed worth it given that there's just
10 or so callers (none of which used this).

> At least, replacing an already queued topic with v2 would not
> increase the number of topics that are supposedly in-flight but not
> quite moving due to lack of reviews and responses, unlike bunch of
> totally new patches ;-)

I'm not sure what to do to improve things in that area.

I'm obviously for increasing the net velocity of my patches making it to
master, but if it's held up my number of reviews a submission of Y won't
necessarily make X worse, since people who've got an interest in Y will
be different than those with an interest in X.

But some of it's definitely on my end, e.g. re-rolls sometimes taking me
longer than I'd prefer. It's a different activity to dissect outstanding
reviews & re-roll than writing code, and sometimes I'm interested in one
over the other...

>> Signed-off-by: Ævar Arnfjörð Bjarmason <[email-masked]>
>> ---
>>  object.c | 10 +++++++---
>>  object.h |  2 +-
>>  2 files changed, 8 insertions(+), 4 deletions(-)
>>
>> diff --git a/object.c b/object.c
>> index 78343781ae7..65446172172 100644
>> --- a/object.c
>> +++ b/object.c
>> @@ -39,9 +39,6 @@ int type_from_string_gently(const char *str, ssize_t len, int gentle)
>>  {
>>  	int i;
>>  
>> -	if (len < 0)
>> -		len = strlen(str);
>> -
>>  	for (i = 1; i < ARRAY_SIZE(object_type_strings); i++)
>>  		if (!strncmp(str, object_type_strings[i], len) &&
>>  		    object_type_strings[i][len] == '\0')
>> @@ -53,6 +50,13 @@ int type_from_string_gently(const char *str, ssize_t len, int gentle)
>>  	die(_("invalid object type \"%s\""), str);
>>  }
>>  
>> +int type_from_string(const char *str)
>> +{
>> +	size_t len = strlen(str);
>> +	int ret = type_from_string_gently(str, len, 0);
>> +	return ret;
>> +}
>> +
>>  /*
>>   * Return a numerical hash value between 0 and n-1 for the object with
>>   * the specified sha1.  n must be a power of 2.  Please note that the
>> diff --git a/object.h b/object.h
>> index 59daadce214..3ab3eb193d3 100644
>> --- a/object.h
>> +++ b/object.h
>> @@ -94,7 +94,7 @@ struct object {
>>  
>>  const char *type_name(unsigned int type);
>>  int type_from_string_gently(const char *str, ssize_t, int gentle);
>> -#define type_from_string(str) type_from_string_gently(str, -1, 0)
>> +int type_from_string(const char *str);
>>  
>>  /*
>>   * Return the current number of buckets in the object hashmap.