git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: "David Burström" <davidburstrom@spotify.com>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: Bug or unexpected behaviour in git show <rev>:a\b
Date: Fri, 24 Jan 2020 19:05:42 -0500	[thread overview]
Message-ID: <20200125000542.GA566779@coredump.intra.peff.net> (raw)
In-Reply-To: <20200124190119.GB1672342@coredump.intra.peff.net>

On Fri, Jan 24, 2020 at 02:01:19PM -0500, Jeff King wrote:

> 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

  parent reply	other threads:[~2020-01-25  0:05 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-24 12:45 Bug or unexpected behaviour in git show <rev>:a\b David Burström
2020-01-24 19:01 ` Jeff King
2020-01-24 19:27   ` Junio C Hamano
2020-01-25  0:00     ` Jeff King
2020-01-25 13:21       ` David Burström
2020-01-27 18:47       ` Junio C Hamano
2020-01-25  0:05   ` Jeff King [this message]
2020-01-25  0:06     ` [PATCH 1/3] t1400: avoid "test" string comparisons Jeff King
2020-01-25  0:06     ` [PATCH 2/3] t1506: drop space after redirection operator Jeff King
2020-01-25  0:13     ` [PATCH 3/3] sha1-name: mark get_oid() error messages for translation Jeff King
2020-01-29 21:30       ` Junio C Hamano
2020-01-29 21:42         ` Junio C Hamano
2020-01-30  7:17           ` Jeff King
2020-01-30 19:16             ` Junio C Hamano
2020-01-31  0:15               ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200125000542.GA566779@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=davidburstrom@spotify.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).