Re: An annoying "Bug" that we would probably leave as-is
- From
Tian Yuchen <a3205153416@gmail.com>
- Date
- Mar 9, 2026, 17:10 UTC
- Message-ID
- <8d0ca4db-3745-49fd-8373-2d3d71aeea78@gmail.com>
- In-Reply-To
- <xmqqh5qswo45.fsf@gitster.g>
Hi Junio,
On 3/7/26 07:10, Junio C Hamano wrote:
Show 9 quoted lines
> "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