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
Junio C Hamano <gitster@pobox.com>
Date
Feb 12, 2017, 23:49 UTC
Message-ID
<xmqq60kfezr9.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<1486934007.8517.10.camel@mattmccutchen.net>
Matt McCutchen <matt@mattmccutchen.net> writes:
Show 5 quoted lines
> 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?

The fact that we have the above two choices tells me that a two-step approach may be an appropriate approach.

The first step is to teach fetch_refs_via_pack() that it should not ignore the information returned in sought[]. It would add new code similar to what cmd_fetch_pack() uses to notice and report errors [*1*] to the function. It would be a sensible first step, but would not let the user know which of multiple causes of "not matched" we noticed.

By "a more specific error", I think you are envisioning that the current boolean "matched" is made into an enum that allows the caller to tell how each request did not match [*2*]. That can be the topic of the second patch and would have to touch filter_refs() [*3*], cmd_fetch_pack() and fetch_refs_via_pack().

I do not have strong preference myself offhand between stopping at the first step or completing both.

Even if you did only the first step, as long as the second step can be done without reverting what the first step did [*4*] by somebody who cares the "specific error" deeply enough, I am OK with that. Of course if you did both steps, that is fine by me as well ;-)

[Footnote]
*1* While I know that it is not right to die() in filter_refs(), and
    fetch_refs_via_pack() is a better place to notice errors, I do
    not offhand know if it is the right place to report errors, or a
    caller higher in the callchain may want the callee to be silent
    and wants to show its own error message (in which case the error
    may have to percolate upwards in the callchain).
*2* e.g. "was it a ref but they did not advertise?  Did it request
    an explicit object name and they did not allow it?"  We may want
    to support other "more specific" errors that can be detected in
    the future.
*3* The current code flips the sought[i]->matched bit on for matched
    ones (relying on the initial state of the bit being false), but
    it now needs to stuff different kind of "not matched" to the
    field to allow the caller to act on it.
*4* IOW, I am OK with an initial "small" improvement, but I'd want
    to make sure that such an initial step does not make future
    enhancements by others harder.
Previous: Matt McCutchenNext: Matt McCutchen
Message 4 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.