git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
Previous: Junio C HamanoNext: Tian Yuchen
Message 2 of 14 in “An annoying "Bug" that we would probably leave as-is”
  1. Junio C HamanoMar 6, 2026
  2. Tian YuchenMar 9, 2026
  3. diff: document -U without <n> as using default contextTian Yuchen, Mar 9, 2026
  4. D. Ben KnobleMar 9, 2026
  5. Tian YuchenMar 10, 2026
  6. Junio C HamanoMar 9, 2026
  7. Tian YuchenMar 10, 2026
  8. diff: document -U without <n> as using default contextTian Yuchen, Mar 10, 2026
  9. Oswald BuddenhagenMar 10, 2026
  10. Tian YuchenMar 10, 2026
  11. Junio C HamanoMar 10, 2026
  12. diff: document -U without <n> as using default contextTian Yuchen, Mar 10, 2026
  13. Jean-Noël AVILAMar 10, 2026
  14. Tian YuchenMar 11, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.