Re: [RFC PATCH v2 4/4] fetch: do not list refs if fetching only hashes
- From
Stefan Beller <sbeller@google.com>
- Date
- Sep 27, 2018, 21:43 UTC
- Message-ID
- <CAGZ79kZOecyJzXoD0ghZFKFWuWf-V0Sb0bYbBangTcbLGr_xVw@mail.gmail.com>
- In-Reply-To
- <1ae00ea1fdd1118b92ac90d67f27a988750b60f2.1538075680.git.jonathantanmy@google.com>
On Thu, Sep 27, 2018 at 12:24 PM Jonathan Tan <jonathantanmy@google.com> wrote:
Show 6 quoted lines
> > If only hash literals are given on a "git fetch" command-line, tag > following is not requested, and the fetch is done using protocol v2, a > list of refs is not required from the remote. Therefore, optimize by > invoking transport_get_remote_refs() only if we need the refs. >
Makes sense
Show 12 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
}