Git Mailing List Archive mirror
 help / color / mirror / Atom feed
From: Felipe Contreras <felipe.contreras@gmail.com>
To: Sergey Organov <sorganov@gmail.com>, Junio C Hamano <gitster@pobox.com>
Cc: Felipe Contreras <felipe.contreras@gmail.com>,
	git@vger.kernel.org, Matthieu Moy <matthieu.moy@univ-lyon1.fr>
Subject: Re: Can we clarify the purpose of `git diff -s`?
Date: Thu, 11 May 2023 12:36:09 -0600	[thread overview]
Message-ID: <645d3599e037c_2606922948b@chronos.notmuch> (raw)
In-Reply-To: <87lehu219c.fsf@osv.gnss.ru>

Sergey Organov wrote:
> Junio C Hamano <gitster@pobox.com> writes:
> 
> > 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.

That's because it's not true.

The intention wasn't to make `--no-patch` a synonym, the intention was to make
disabling the patch output of `git diff` more accessible.

The cover letter makes it clear [1].

  "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.

The code at the time did not allow turning off only one output, using
DIFF_FORMAT_NO_OUTPUT was easy, so that's what they did.

> > 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.

I agree.

I bet there's very few people relying on this behavior (if any), which is
precisely why nobody noticed the bug until now.

If we are going to break backwards-compatibility, we should break it correctly:
split `--no-patch` from `-s`, and make it only negate `--patch`.

> > 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!

And you were correct.

I did write a patch series that actually fixes the problem correctly, and the
maintainer completely ignored it in favor of his partial solution.

So you would have wasted your time trying to fix this correctly, as I probably
did.

Cheers.

[1] https://lore.kernel.org/git/1373893639-13413-1-git-send-email-Matthieu.Moy@imag.fr/

-- 
Felipe Contreras

  parent reply	other threads:[~2023-05-11 18:37 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-11  3:14 Can we clarify the purpose of `git diff -s`? Felipe Contreras
2023-05-11 11:59 ` Sergey Organov
2023-05-11 16:26   ` Junio C Hamano
2023-05-11 17:37   ` Junio C Hamano
2023-05-11 18:04     ` Sergey Organov
2023-05-11 18:27       ` Junio C Hamano
2023-05-11 18:36       ` Felipe Contreras [this message]
2023-05-11 18:17     ` Felipe Contreras
2023-05-11 17:41   ` Felipe Contreras
2023-05-11 18:31     ` Sergey Organov
2023-05-11 19:10       ` Felipe Contreras
2023-05-11 19:32         ` Sergey Organov
2023-05-11 19:54           ` Felipe Contreras
2023-05-11 20:24             ` Sergey Organov
2023-05-11 20:59               ` Felipe Contreras
2023-05-11 22:49                 ` Sergey Organov
2023-05-11 23:28                   ` Felipe Contreras
2023-05-12  8:40                     ` Sergey Organov
2023-05-12 19:19                       ` Felipe Contreras
     [not found]   ` <5bb24e0208dd4a8ca5f6697d578f3ae0@SAMBXP02.univ-lyon1.fr>
2023-05-12  8:15     ` Matthieu Moy
2023-05-12 17:03       ` Junio C Hamano
2023-05-12 18:21         ` Sergey Organov
2023-05-12 19:21           ` Junio C Hamano
2023-05-12 19:34             ` Junio C Hamano
2023-05-12 20:28             ` Felipe Contreras
2023-05-12 20:47               ` Junio C Hamano
2023-05-12 21:01                 ` Felipe Contreras
2023-05-12 21:47                   ` Junio C Hamano
2023-05-12 21:48                     ` Junio C Hamano
2023-05-12 23:21                     ` Felipe Contreras
2023-05-12 21:41                 ` Sergey Organov
2023-05-12 22:17                   ` Junio C Hamano
2023-05-12 22:47                     ` Sergey Organov
2023-05-12 23:07                   ` Felipe Contreras
2023-05-13 14:58                     ` Philip Oakley
2023-05-13 17:45                       ` Sergey Organov
2023-05-12 19:47           ` Felipe Contreras
2023-05-12 19:34         ` Felipe Contreras
2023-05-12 19:17       ` Felipe Contreras

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=645d3599e037c_2606922948b@chronos.notmuch \
    --to=felipe.contreras@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=matthieu.moy@univ-lyon1.fr \
    --cc=sorganov@gmail.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).