git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC PATCH v2 4/4] fetch: do not list refs if fetching only hashes

From
JTJonathan 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.

Previous: Stefan BellerNext: Junio C Hamano
Message 11 of 12 in “transport: list refs before fetch if necessary”
  1. transport: list refs before fetch if necessaryJonathan Tan, Sep 25, 2018
  2. Junio C HamanoSep 25, 2018
  3. 0/4 Avoid ls-refs when possible in protocol v2Jonathan Tan, Sep 27, 2018
  4. 1/4 transport: allow skipping of ref listingJonathan Tan, Sep 27, 2018
  5. 2/4 transport: do not list refs if possibleJonathan Tan, Sep 27, 2018
  6. Stefan BellerSep 27, 2018
  7. Junio C HamanoOct 7, 2018
  8. 3/4 transport: list refs before fetch if necessaryJonathan Tan, Sep 27, 2018
  9. 4/4 fetch: do not list refs if fetching only hashesJonathan Tan, Sep 27, 2018
  10. Stefan BellerSep 27, 2018
  11. Jonathan TanSep 28, 2018
  12. Junio C HamanoSep 27, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.