Subject: Re: [PATCH 2/4] ref-filter: add ref-filter API

From: karthik nayak <[email-masked]>
Date: Fri, 22 May 2015 18:16:36 +0530

On 05/22/2015 12:14 PM, Matthieu Moy wrote:
> karthik nayak <[email-masked]> writes:
>
>>> I miss a high-level description of what the code is doing. Essentially,
>>> there's the complete repository list of refs, and you want to filter
>>> only some of them, right?
>>>
>>>   From the name, I would guess that ref_filter is the structure describing
>>> how you are filtering, but from the code it seems to be the list you're
>>> filtering, not the filter.
>>
>> Reading this again, A bit confused by what you're trying to imply.
>> Could you rephrase please?
>
> At some point, I'd expect something like
>
>    filtered_list_of_refs = filer(full_list_of_refs, description_of_filter);
>
> That would remove some refs from full_list_of_refs according to
> description_of_filter.
>
> (totally invented code, only to show the idea)
>
> If there's a piece of code looking like this, then you need a data
> structure to store list of refs (full_list_of_refs and
> filtered_list_of_refs) and another to describe what you're doing with it
> (description_of_filter).
>
> The name ref_filter implies to me that it contains the description of
> the filter, but looking at the code it doesn't seem to be the case.
>

But it does just that, doesn't it?

strict ref_filter {
	int count, alloc;
	struct ref_filter_item **items;
	const char **name_patterns;
};

If you see it does contain 'name_patterns' according to which it will 
filter the given refs, but thats just the start, as 'for-each-ref' only 
supports filtering based on the given pattern, eventually as I merge the 
functionality of 'git tag -l' and 'git branch -l' it will contain more 
filters like, 'contains_commit', 'merged' and so on. Eventually becoming 
more of a filter description as you put it. I hope that clears out things :)

Regards,
Karthik