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

Re: [PATCH] fetch: print an error when declining to request an unadvertised object

From
Matt McCutchen <matt@mattmccutchen.net>
Date
Feb 12, 2017, 21:13 UTC
Message-ID
<1486934007.8517.10.camel@mattmccutchen.net>
In-Reply-To
<xmqqwpcxlwpv.fsf@gitster.mtv.corp.google.com>
On Fri, 2017-02-10 at 10:36 -0800, Junio C Hamano wrote:
Show 11 quoted lines
> > 
> There is this piece of code near the end of builtin/fetch-pack.c:
> 
> [...]
> 
> that happens before the command shows the list of fetched refs, and
> this code is prepared to inspect what happend to the requests it (in
> response to the user request) made to the underlying fetch
> machinery, and issue the error message.
> If you change your command line to "git fetch-pack REMOTE SHA1", you
> do see an error from the above.

Yes, "error: no such remote ref NNNN", which at least makes clear that the operation didn't work, though it would be nice to give a more specific error message.

> This all happens in transport.c::fetch_refs_via_pack().
> I think that function is a much better place to error or die than
> filter_refs().

I confirmed that checking the sought refs there works. However, in filter_refs, it's easy to give a more specific error message that the server doesn't allow requests for unadvertised objects, and that code works for "git fetch-pack" too. To do the same in fetch_refs_via_pack, we'd have to duplicate a few lines of code from filter_refs and expose the allow_unadvertised_object_request variable, or just set a flag on the "struct ref" in filter_refs and check it in fetch_refs_via_pack.

What do you think? Do you not care about having a more specific error, in which case I can copy the code from builtin/fetch-pack.c to fetch_refs_via_pack? Or shall I add code to filter_refs to set a flag and add code to builtin/fetch-pack.c and fetch_refs_via_pack to check the flag? Or what?

Matt
Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 17 in “fetch: print an error when declining to request an unadvertised object”
  1. fetch: print an error when declining to request an unadvertised objectMatt McCutchen, Feb 10, 2017
  2. Junio C HamanoFeb 10, 2017
  3. Matt McCutchenFeb 12, 2017
  4. Junio C HamanoFeb 12, 2017
  5. Matt McCutchenFeb 19, 2017
  6. fetch: print an error when declining to request an unadvertised objectMatt McCutchen, Feb 19, 2017
  7. Junio C HamanoFeb 21, 2017
  8. Matt McCutchenFeb 22, 2017
  9. Junio C HamanoFeb 22, 2017
  10. 2/3 fetch_refs_via_pack: call report_unmatched_refsMatt McCutchen, Feb 22, 2017
  11. 1/3 fetch-pack: move code to report unmatched refs to a functionMatt McCutchen, Feb 22, 2017
  12. Junio C HamanoFeb 22, 2017
  13. 1/3 fetch-pack: move code to report unmatched refs to a functionMatt McCutchen, Feb 22, 2017
  14. 3/3 fetch-pack: add specific error for fetching an unadvertised objectMatt McCutchen, Feb 22, 2017
  15. 2/3 fetch_refs_via_pack: call report_unmatched_refsMatt McCutchen, Feb 22, 2017
  16. Matt McCutchenFeb 22, 2017
  17. 3/3 fetch-pack: add specific error for fetching an unadvertised objectMatt McCutchen, Feb 22, 2017

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.