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

Re: Bug or unexpected behaviour in git show <rev>:a\b

From
Jeff King <peff@peff.net>
Date
Jan 25, 2020, 00:05 UTC
Message-ID
<20200125000542.GA566779@coredump.intra.peff.net>
In-Reply-To
<20200124190119.GB1672342@coredump.intra.peff.net>
On Fri, Jan 24, 2020 at 02:01:19PM -0500, Jeff King wrote:
Show 6 quoted lines
> Also, unrelated to your problem, but I find it interesting in the output
> above that "git show HEAD:foo --" produces a less useful error message
> than "git show HEAD:foo" without the separator, even though the user has
> given us even more information about their intent. I think the DWIM
> verify_filename() has grown a lot more diagnosis code over the years
> that could also be used in the other code path.

I took a look at this, but it gets ugly pretty quickly, so I gave up. The problem is that all of the good errors are produced by get_oid() with GET_OID_ONLY_TO_DIE, but the moment where we decide to produce the bad error is sometimes removed from the get_oid() call. E.g., in something like "a..b", we'd want to report on whichever of "a" or "b" caused a problem, but at the point of reporting the error, we only have the unparsed "a..b".

Certainly this can be overcome, but it seemed like a rabbit-hole that I didn't feel like going down today. Anybody is welcome to give it a shot. I suspect the whole thing would be simpler if get_oid() could optionally return an error string to the caller, instead of forcing us to call it a second time with the "only to die" flag.

Speaking of which, I did go part-way down a different rabbit-hole in preparation, and ended up with these patches. So it seemed worth posting them.

  [1/3]: t1400: avoid "test" string comparisons
  [2/3]: t1506: drop space after redirection operator
  [3/3]: sha1-name: mark get_oid() error messages for translation
 sha1-name.c                    | 30 +++++++++++------------
 t/t1400-update-ref.sh          | 36 ++++++++++++++++++----------
 t/t1506-rev-parse-diagnosis.sh | 44 +++++++++++++++++-----------------
 3 files changed, 61 insertions(+), 49 deletions(-)
-Peff
Previous: Junio C HamanoNext: Jeff King
Message 7 of 15 in “Bug or unexpected behaviour in git show <rev>:a\b”
  1. David BurströmJan 24, 2020
  2. Jeff KingJan 24, 2020
  3. Junio C HamanoJan 24, 2020
  4. Jeff KingJan 25, 2020
  5. David BurströmJan 25, 2020
  6. Junio C HamanoJan 27, 2020
  7. Jeff KingJan 25, 2020
  8. 1/3 t1400: avoid "test" string comparisonsJeff King, Jan 25, 2020
  9. 2/3 t1506: drop space after redirection operatorJeff King, Jan 25, 2020
  10. 3/3 sha1-name: mark get_oid() error messages for translationJeff King, Jan 25, 2020
  11. Junio C HamanoJan 29, 2020
  12. Junio C HamanoJan 29, 2020
  13. Jeff KingJan 30, 2020
  14. Junio C HamanoJan 30, 2020
  15. Jeff KingJan 31, 2020

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.