From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: An annoying "Bug" that we would probably leave as-is
Date: Fri, 06 Mar 2026 15:10:34 -0800 [thread overview]
Message-ID: <xmqqh5qswo45.fsf@gitster.g> (raw)
"git show -U" does not complain. In an ideal world, it should say
"-U wants a number", just like "git show -Unan" does.
Unfortunately t/t4013/ actually has tests that break if we start
tightening the command line parser for this.
This falls into the "if it hurts, do not do it" category that
somebody might be taking advantage of out there that we might be
better off leaving them broken.
diff.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git c/diff.c w/diff.c
index a1961526c0..ff79a41cfc 100644
--- c/diff.c
+++ w/diff.c
@@ -5581,15 +5581,14 @@ static int diff_opt_unified(const struct option *opt,
const char *arg, int unset)
{
struct diff_options *options = opt->value;
- char *s;
+ char *s = NULL;
BUG_ON_OPT_NEG(unset);
- if (arg) {
+ if (arg)
options->context = strtol(arg, &s, 10);
- if (*s)
- return error(_("%s expects a numerical value"), "--unified");
- }
+ if (!s || *s)
+ return error(_("%s expects a numerical value"), "--unified");
enable_patch_output(&options->output_format);
return 0;
next reply other threads:[~2026-03-06 23:10 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-06 23:10 Junio C Hamano [this message]
2026-03-09 17:10 ` An annoying "Bug" that we would probably leave as-is Tian Yuchen
2026-03-09 17:27 ` [PATCH v1] diff: document -U without <n> as using default context Tian Yuchen
2026-03-09 22:00 ` D. Ben Knoble
2026-03-10 4:55 ` Tian Yuchen
2026-03-09 22:17 ` Junio C Hamano
2026-03-10 4:51 ` Tian Yuchen
2026-03-10 5:30 ` [PATCH v2] " Tian Yuchen
2026-03-10 9:15 ` Oswald Buddenhagen
2026-03-10 9:43 ` Tian Yuchen
2026-03-10 13:14 ` Junio C Hamano
2026-03-10 9:50 ` [PATCH v3] " Tian Yuchen
2026-03-10 17:31 ` [PATCH v1] " Jean-Noël AVILA
2026-03-11 4:33 ` Tian Yuchen
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=xmqqh5qswo45.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
/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