Subject: An annoying "Bug" that we would probably leave as-is

From: Junio C Hamano <[email-masked]>
Date: Fri, 06 Mar 2026 15:10:34 -0800

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