Subject: Re: [RFC/PATCH 3/9] for-each-ref: add '--points-at' option

From: Junio C Hamano <[email-masked]>
Date: Tue, 09 Jun 2015 12:07:26 -0700

Karthik Nayak <[email-masked]> writes:

>>> @@ -54,7 +59,6 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)
>>>   	/* for warn_ambiguous_refs */
>>>   	git_config(git_default_config, NULL);
>>>
>>> -	memset(&ref_cbdata, 0, sizeof(ref_cbdata));
>>
>> I cannot quite see how this change relates to the addition of the
>> new option.
>>
>
> Well if we memset() after calling parse_opt_points_at(), we loose all
> the information we would have obtained.
> So the memset() is moved to an earlier location.

which I did not see, because I expected the code to follow the usual
"no decl-after-statement" pattern.  IOW

>>   	int maxcount = 0, quote_style = 0;
>>   	struct ref_filter_cbdata ref_cbdata;
>> +	memset(&ref_cbdata, 0, sizeof(ref_cbdata));
>>
>>   	struct option opts[] = {
>>   		OPT_BIT('s', "shell", &quote_style,

Don't do that.  Always start your function like so:

	type funcname(args)
        {
        	declarations;

                first statement;
		...

with no blank line within declarations block and a blank line after
the declarations block.