public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
* An annoying "Bug" that we would probably leave as-is
@ 2026-03-06 23:10 Junio C Hamano
  2026-03-09 17:10 ` Tian Yuchen
  2026-03-09 17:27 ` [PATCH v1] diff: document -U without <n> as using default context Tian Yuchen
  0 siblings, 2 replies; 14+ messages in thread
From: Junio C Hamano @ 2026-03-06 23:10 UTC (permalink / raw)
  To: git

"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;

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2026-03-11  4:33 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-06 23:10 An annoying "Bug" that we would probably leave as-is Junio C Hamano
2026-03-09 17:10 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox