Re: [RFC PATCH v2 4/4] fetch: do not list refs if fetching only hashes
- From
- Jonathan Tan <jonathantanmy@google.com>
- Date
- Sep 28, 2018, 17:50 UTC
- Message-ID
- <20180928175027.181442-1-jonathantanmy@google.com>
- In-Reply-To
- <CAGZ79kZOecyJzXoD0ghZFKFWuWf-V0Sb0bYbBangTcbLGr_xVw@mail.gmail.com>
Show 19 quoted lines
> > + /*
> > + * We can avoid listing refs if all of them are exact
> > + * OIDs
> > + */
> > + must_list_refs = 0;
> > + for (i = 0; i < rs->nr; i++) {
> > + if (!rs->items[i].exact_sha1) {
> > + must_list_refs = 1;
> > + break;
> > + }
> > + }
>
> This seems to be a repeat pattern, Is it worth it to encapsulate it
> as a function in transport or refs?
>
> int must_list_refs(struct ref **to_fetch)
> {
> // body as the loop above
> }The repetition is unfortunate - I tried to think of a better way to do it but couldn't. We can't do what you suggest because this one loops over refspecs but the other one loops over refs.