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

Re: Can we clarify the purpose of `git diff -s`?

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
May 11, 2023, 18:17 UTC
Message-ID
<645d3122bd1d2_26011a2947a@chronos.notmuch>
In-Reply-To
<xmqqwn1ewyzx.fsf@gitster.g>
Junio C Hamano wrote:
Show 6 quoted lines
> Sergey Organov <sorganov@gmail.com> writes:
> 
> > I entirely agree with your conclusion: obviously, -s (--silent) and
> > --no-patch are to be different for UI to be even remotely intuitive, and
> > I'd vote for immediate fix of --no-patch semantics even though it's a
> > backward-incompatible change.
> While it is very clear that the intent of the author was to make it
> a synonym for "-s" and not a "feature-wise enable/disable" option,

I disgree, it's very clear the intention was to negate --patch, he explicitely said so multiple times:

 * This follows the usual convention of having a --no-foo option to
   negate --foo.
 * to cancel the effect of `--patch`.

In particular, the purpose was to make silencing the output of `git diff` more accessible, the cover letter makes it abundantly clear [1]:

====
  > Stefan Beller <stefanbeller@googlemail.com> writes:
  >
  >> However I sometimes also get:
  >> sb@sb:~/OSS/git$ git show --format="%ad" 0da7a53
  >> Fri Jul 12 10:49:34 2013 -0700
  >>
  >> diff --git a/Documentation/RelNotes/1.8.4.txt
  >> b/Documentation/RelNotes/1.8.4.txt
  >> index 0e50df8..4250e5a 100644
  >> --- a/Documentation/RelNotes/1.8.4.txt
  >> +++ b/Documentation/RelNotes/1.8.4.txt
  >
  > "git show" will show the diff by default. For merge commits, it shows
  > the --cc diff which is often empty, hence the behavior you see.
  >
  > You want to use "git show -s", which suppresses the patch output.
  ... and this "git show -s" is extraordinarily hard to discover, as it
  is only documented in "git log --help". Google has been my friend
  here, but we should really improve that.
  This patch series does essentially two things:
  * Add a --no-patch synonym for -s. I'm actually wondering why the
    option wasn't called this way from the beginning.
  * Reorganize the doc so that "git show" actually mentions it.
====
Making it a synonym of `-s` was a means, not an end.
> I do not think it will break established use cases too badly to fix
> the behaviour of "-s" so that it does not get stuck.  We saw an
> existing breakage in one test,

It's curious that your patch breaks one test case, while my approach breaks *zero* cases.

> but asking the owners of scripts that make the same mistake of
> assuming "-s" gets stuck for some but not other options to fix that
> assumption based on an earlier faulty implementation is much easier.

"The users are using the interface wrong" is an euphemism for "I want to break backwards-compatibility".

According to Linus Torvalds if your users are relying on a bug in your interface, that bug is now a feature.

If we want to break backwards-compatibility then let's do so.
> So, no, I do not think we can immediately "fix".  I do not think
> anybody knows if it can be done "immediately" or needs a careful
> planning to transition, and I offhand do not know if it is even
> possible to transition without fallout.

I know it can be done immediately, because my patch series already did it.

[1] https://lore.kernel.org/git/1373893639-13413-1-git-send-email-Matthieu.Moy@imag.fr/
-- 
Felipe Contreras
Previous: Felipe ContrerasNext: Felipe Contreras
Message 8 of 39 in “Can we clarify the purpose of `git diff -s`?”
  1. Felipe ContrerasMay 11, 2023
  2. Sergey OrganovMay 11, 2023
  3. Junio C HamanoMay 11, 2023
  4. Junio C HamanoMay 11, 2023
  5. Sergey OrganovMay 11, 2023
  6. Junio C HamanoMay 11, 2023
  7. Felipe ContrerasMay 11, 2023
  8. Felipe ContrerasMay 11, 2023
  9. Felipe ContrerasMay 11, 2023
  10. Sergey OrganovMay 11, 2023
  11. Felipe ContrerasMay 11, 2023
  12. Sergey OrganovMay 11, 2023
  13. Felipe ContrerasMay 11, 2023
  14. Sergey OrganovMay 11, 2023
  15. Felipe ContrerasMay 11, 2023
  16. Sergey OrganovMay 11, 2023
  17. Felipe ContrerasMay 11, 2023
  18. Sergey OrganovMay 12, 2023
  19. Felipe ContrerasMay 12, 2023
  20. Matthieu MoyMay 12, 2023
  21. Junio C HamanoMay 12, 2023
  22. Sergey OrganovMay 12, 2023
  23. Junio C HamanoMay 12, 2023
  24. Junio C HamanoMay 12, 2023
  25. Felipe ContrerasMay 12, 2023
  26. Junio C HamanoMay 12, 2023
  27. Felipe ContrerasMay 12, 2023
  28. Junio C HamanoMay 12, 2023
  29. Junio C HamanoMay 12, 2023
  30. Felipe ContrerasMay 12, 2023
  31. Sergey OrganovMay 12, 2023
  32. Junio C HamanoMay 12, 2023
  33. Sergey OrganovMay 12, 2023
  34. Felipe ContrerasMay 12, 2023
  35. Philip OakleyMay 13, 2023
  36. Sergey OrganovMay 13, 2023
  37. Felipe ContrerasMay 12, 2023
  38. Felipe ContrerasMay 12, 2023
  39. Felipe ContrerasMay 12, 2023

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.