From: Tian Yuchen <a3205153416@gmail.com>
To: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: An annoying "Bug" that we would probably leave as-is
Date: Tue, 10 Mar 2026 01:10:01 +0800 [thread overview]
Message-ID: <8d0ca4db-3745-49fd-8373-2d3d71aeea78@gmail.com> (raw)
In-Reply-To: <xmqqh5qswo45.fsf@gitster.g>
Hi Junio,
On 3/7/26 07:10, Junio C Hamano wrote:
> "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.
Out of curiosity, I applied your patch and ran t4013 to see exactly what
would break. It turns out it's 'not ok 157 - git diff -U initial..side'.
The suite explicitly relies on 'git diff -U' (without a number) to
implicitly default to 3 lines of context, behaving identically to '-u'.
With your patch, it correctly but fatally throws 'error: --unified
expects a numerical value' instead of generating the diff, causing the
test to fail.
I looked at diff-context-options.adoc, and it says:
`-U<n>`::
`--unified=<n>`::
Generate diffs with _<n>_ lines of context. Defaults to `diff.context`
or 3 if the config option is unset.
I believe this description needs revision, as in actual practice (as you
described), the number following '-U' is not strictly required.
(I was taken aback, especially when you mentioned “somebody might be
taking advantage of out there.” It made me realize how an inadvertent
little bug or minor error can become a daily habit for many people, or
even foundations of millions of scripts. Just a thought. ;)
Regards,
Yuchen
next prev parent reply other threads:[~2026-03-09 17:10 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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=8d0ca4db-3745-49fd-8373-2d3d71aeea78@gmail.com \
--to=a3205153416@gmail.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox