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

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

From
Sergey Organov <sorganov@gmail.com>
Date
May 11, 2023, 18:04 UTC
Message-ID
<87lehu219c.fsf@osv.gnss.ru>
In-Reply-To
<xmqqwn1ewyzx.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
Show 29 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.
>
> I forgot to write about this part.
>
> tl;dr.  While I do not think the current "--no-patch" that turns off
> things other than "--patch" is intuitive, an "immediate" change is
> not possible.  Let's do one fix at a time.
>
> The behaviour came in the v1.8.4 days with a series that was merged
> by e2ecd252 (Merge branch 'mm/diff-no-patch-synonym-to-s',
> 2013-07-22), which
>
>  * made "--no-patch" a synonym for "-s";
>
>  * fixed "-s --patch", in which the effect of "-s" got stuck and did
>    not allow the patch output to be re-enabled again with "--patch";
>
>  * updated documentation to explain "--no-patch" as a synonym for
>    "-s".
>
> 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,
> that is what we've run with for the past 10 years.  You identified
> bugs related the "-s got stuck" problem and we recently fixed that.

I wonder, why this intention of the author has not been opposed at that time is beyond my understanding, sorry! What exactly did it bring to make --no-patch a synonym for -s? Not only it's illogical, it's even not useful as being more lengthy.

Probably nobody actually cared at that time, me thinks.
>
> "Should --no-patch be changed" can be treated as a separate issue,
> and whenever we can treat two things separately, I want to do so, to
> keep the potential blast radius smaller.

Sure it's a separate change. When I said "immediate" I meant that there is no need for some transition measures like config variables, not that it is to be included in the "fix -s".

Show 20 quoted lines
> That way, if an earlier change turns out OK but the other change
> causes severe regression, we can only revert or rework the latter. An
> exception is if committing to one change (e.g. "fix '-s'") makes the
> other change (e.g. "redefine --no-patch") impossible, but we all know
> it is not the case here. I gave an outline of how to go about it in
> the log message of that "fix '-s'" patch.
>
> 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, 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.
>
> But "git diff --stat --patch --no-patch", which suddenly starts
> showing diffstat after you make "--no-patch" no longer a synonym for
> "-s", has a much larger potential to break the existing workflows.
> And I do not think asking the users who followed the documented
> "--no-patch is a synonym for -s" to change their script because we
> decided to make "--no-patch" no longer a synonym is much harder.

Why somebody would use --no-patch instead of -s when she means -s? Is't it obvious that

   git diff --stat --patch -s
is not only shorter but dramatically more clear than
   git diff --stat --patch --no-patch
???
Taking this into account, I'd predict no breakage at all.
> 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.

This has been expected, and this is one of the things that stops me from trying to "fix" anything in the Git UI recently. I think that perfectly legit carefulness from the maintainer to be conservative in accepting of such changes goes a bit too far, sorry!

Thanks, -- Sergey Organov

Previous: Junio C HamanoNext: Junio C Hamano
Message 5 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.