From: Jeff King <peff@peff.net>
To: "René Scharfe" <l.s.r@web.de>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: [Bug?] "git diff --no-rename A B"
Date: Mon, 22 Jan 2024 18:00:51 -0500 [thread overview]
Message-ID: <20240122230051.GB814674@coredump.intra.peff.net> (raw)
In-Reply-To: <579fd5bc-3bfd-427f-b22d-dab5e7e56eb2@web.de>
On Sat, Jan 20, 2024 at 03:39:38PM +0100, René Scharfe wrote:
> > The issue is that we have "--rename-empty", which of course also
> > provides "--no-rename-empty". And parse-options is happy to let you
> > abbreviate names as long as they are unambiguous. But "--no-rename" _is_
> > ambiguous with "--no-renames". Why don't we catch it?
>
> Because diff_opt_parse() passes PARSE_OPT_KEEP_UNKNOWN_OPT, which makes
> parse_long_opt() skip abbreviation detection. Which it does since
> baa4adc66a (parse-options: disable option abbreviation with
> PARSE_OPT_KEEP_UNKNOWN, 2019-01-27).
OK, it makes sense to me that we should avoid abbreviation entirely with
KEEP_UNKNOWN_OPT, for the reasons given in that commit. But if adding
--rename fixed it, is there another bug lurking? That is, would we do
the wrong thing on a case without KEEP_UNKNOWN_OPT but which had
"--renames" and "--no-rename" defined? Or was it simply the
inconsistency in how KEEP_UNKNOWN_OPT is being applied?
I think it might just be the latter. If I do this:
diff --git a/t/helper/test-parse-options.c b/t/helper/test-parse-options.c
index ded8116cc5..e908c7386d 100644
--- a/t/helper/test-parse-options.c
+++ b/t/helper/test-parse-options.c
@@ -124,6 +124,7 @@ int cmd__parse_options(int argc, const char **argv)
struct option options[] = {
OPT_BOOL(0, "yes", &boolean, "get a boolean"),
OPT_BOOL('D', "no-doubt", &boolean, "begins with 'no-'"),
+ OPT_BOOL(0, "do-it", &boolean, "'do' ambiguous with 'doubt'"),
{ OPTION_SET_INT, 'B', "no-fear", &boolean, NULL,
"be brave", PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL, 1 },
OPT_COUNTUP('b', "boolean", &boolean, "increment by one"),
then running:
t/helper/test-tool parse-options --do
correctly complains about the ambiguity (though amusingly it mentions
"--no-no-doubt" in the error message). And if I add KEEP_UNKNOWN_OPT,
then it gives the wrong behavior. But curiously it does so even with
your patch applied. So I think there may be further fixes needed.
-Peff
next prev parent reply other threads:[~2024-01-22 23:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-18 1:07 [Bug?] "git diff --no-rename A B" Junio C Hamano
2024-01-18 6:26 ` Dragan Simic
2024-01-20 1:18 ` Jeff King
2024-01-20 14:39 ` René Scharfe
2024-01-20 17:55 ` Junio C Hamano
2024-01-21 17:56 ` René Scharfe
2024-01-22 23:00 ` Jeff King [this message]
2024-01-23 0:28 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240122230051.GB814674@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=l.s.r@web.de \
/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.
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 NNTP newsgroup(s).