Subject: Re: [PATCHv2] fetch: Only call a new ref a "branch" if it's under refs/heads/.

From: Marc Branchaud <[email-masked]>
Date: Mon, 16 Apr 2012 10:26:40 -0400

On 12-04-13 04:07 PM, Jonathan Nieder wrote:
> [email-masked] wrote:
> 
>> --- a/builtin/fetch.c
>> +++ b/builtin/fetch.c
>> @@ -293,14 +293,18 @@ static int update_local_ref(struct ref *ref,
>>  		const char *msg;
>>  		const char *what;
>>  		int r;
>> -		if (!strncmp(ref->name, "refs/tags/", 10)) {
>> +		if (!prefixcmp(ref->name, "refs/tags/")) {
> 
> This part is just a clean-up, right?

Yes.

It seems most of the code in fetch.c uses prefixcmp(), so I thought I'd use
it for my patch.  But then I thought it looked weird for one check to use
strncmp() and the other to use prefixcmp().

After a cursory search for strncmp() and strcmp() in fetch.c, I think this is
the only place where prefixcmp() should've been used but wasn't.

It didn't seem worth making an extra patch for this change, but I've happy to
break it out if that's what folks want.

>>  			msg = "storing tag";
>>  			what = _("[new tag]");
>>  		}
>> -		else {
>> +		else if (!prefixcmp(ref->name, "refs/heads/")) {
>>  			msg = "storing head";
>>  			what = _("[new branch]");
>>  		}
>> +		else {
>> +			msg = "storing ref";
>> +			what = _("[new ref]");
>> +		}
> 
> Neat.  I like it, for what it's worth.

Thanks!

		M.