Re: [PATCH 11/11] refs: split and make get_*_ref_store() public API

2 messages, 2 authors, 2017-02-15 · open the first message on its own page

Re: [PATCH 11/11] refs: split and make get_*_ref_store() public API

From: Junio C Hamano <hidden>
Date: 2017-02-14 18:25:00

Duy Nguyen [off-list ref] writes:
Direct call sites are just middle men though, e.g.
for_each_ref_submodule(). I'll attempt to clean this up at some point
in future (probably at the same time I attempt to kill *_submodule ref
api). But I think for now I'll just put a TODO or FIXME comment here.
So we'd have get_*_ref_store() for various cases and then will have
a unifying for_each_ref_in_refstore() that takes a ref-store, which
supersedes all the ad-hoc iterators like for_each_ref_submodule(),
for_each_namespaced_ref(), etc?

That's a very sensible longer-term goal, methinks.

I am wondering what we should do to for_each_{tag,branch,...}_ref().  
Would that become

	ref_store = get_ref_main_store();
	tag_ref_store = filter_ref_store(ref_store, "refs/tags/");
	for_each_ref_in_refstore(tag_ref_store, ...);

or do you plan to have some other pattern?

Re: [PATCH 11/11] refs: split and make get_*_ref_store() public API

From: Duy Nguyen <hidden>
Date: 2017-02-15 00:44:53

On Wed, Feb 15, 2017 at 1:24 AM, Junio C Hamano [off-list ref] wrote:
Duy Nguyen [off-list ref] writes:
quoted
Direct call sites are just middle men though, e.g.
for_each_ref_submodule(). I'll attempt to clean this up at some point
in future (probably at the same time I attempt to kill *_submodule ref
api). But I think for now I'll just put a TODO or FIXME comment here.
So we'd have get_*_ref_store() for various cases and then will have
a unifying for_each_ref_in_refstore() that takes a ref-store, which
supersedes all the ad-hoc iterators like for_each_ref_submodule(),
for_each_namespaced_ref(), etc?

That's a very sensible longer-term goal, methinks.
Ah I forgot about ref namespace. I'll need to try something out in that area.
I am wondering what we should do to for_each_{tag,branch,...}_ref().
Would that become

        ref_store = get_ref_main_store();
        tag_ref_store = filter_ref_store(ref_store, "refs/tags/");
        for_each_ref_in_refstore(tag_ref_store, ...);

or do you plan to have some other pattern?
Long term, I think that's what Mike wants. Though the filter_ref_store
might return an (opaque) iterator instead of a ref store and
for_each_refstore() becomes a thin wrapper around the iterator
interface.
-- 
Duy
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help