git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Sergey Organov <sorganov@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Alex Henrie <alexhenrie24@gmail.com>,
	Git mailing list <git@vger.kernel.org>
Subject: Re: Why doesn't `git log -m` imply `-p`?
Date: Mon, 03 May 2021 20:42:00 +0300	[thread overview]
Message-ID: <87czu7u32v.fsf@osv.gnss.ru> (raw)
In-Reply-To: <xmqqzgxfb80r.fsf@gitster.g> (Junio C. Hamano's message of "Sat, 01 May 2021 09:41:08 +0900")

Junio C Hamano <gitster@pobox.com> writes:

> Sergey Organov <sorganov@gmail.com> writes:
>
>>> Luckily,
>>>
>>>     $ git log [--stat] --diff-merges=first-parent master..seen
>>>
>>> seems to do almost the right thing, with respect to the "It is
>>> probably OK to special case" I gave above.
>>
>> I believe any special-casing is to be a last resort, and definitely is
>> not the right thing to do in this particular case.
>
> I do not know if I get it.  "log --diff-merges=<kind>" giving the
> same output as "log" (i.e. no trace of any kind of diff) would be
> puzzling to users, and to help them, it is OK to say that

I thought (apparently wrong) that the idea was to special-case "-m", and
only "-m". I.e., if -m is alone, let it imply -p, otherwise not. That
was the thing I was in opposition to.

>
>  * "--diff-merges=<kind>" enables some kind of diff output
>    automatially (for both merges and non-merges), and

No, I don't think this is OK, sorry. I fail to see why --diff-merges
should affect non-merge commits. I believe it shouldn't.

>
>  * when there is no user preference given as to what kind of diff is
>    desired, we default to "-p".

What kind of diff "-p" gives for merge commits, exactly? As far as I can
tell, it's "none".

>
> As it is natural to expect "--stat --diff-merges=<kind> would give
> only the diffstat without patch, we end up "special casing"
> "--diff-merges=<kind>" that is given alone, without specifying what
> kind of diff is desired, and behave as if "-p" was given.

In general, I hate dependencies between options. The only thing that is
actually needed for convenience is an ability for an option to imply
other options. What's currently there is already too complex for my
personal taste, and I'd hate to add even more complexity on top.

Right now --diff-merges is pretty simple and straightforward: it
specifies diff output for merge commits, and only for merge commits. If
any other option disables diff machinery altogether, it will disable
diff for merges as well.

OTOH, we have --patch that deals with non-merge commits.

Personally, I don't like the resulting interface very much, but it's
historical, and can't be easily changed.

> So I would have expected you to call this kind of "special casing" a
> good thing.

Well, even though I was originally commenting about -m only, I must
admit I'm in general against any "special casing", unless there is
extremely strong reason to consider it.

>
>>> It only "enables diff" for merge commits, which does not quite feel
>>> right and we may want to do the same "enable diff" for single parent
>>> commits,

I fail to see why --diff-merges should ever affect non-merge commits.
It'd be at least counter-intuitive, not to say directly opposite to the
original design goal.

>>> but the good part is that it does not blindly imply "-p".

Yep.

>>>
>>> It seems to do the "enable diff" the right way by honoring other
>>> command line options that specify the format of the diff, so with
>>> "--stat" included in the sample command line above, we get the
>>> diffstat for single parent commits (because we ask for "--stat" from
>>> the command line to show it throughout the history) and also for
>>> merge commits (because --diff-merges=first-parent does *not* blindly
>>> turn the textual patch '-p' on).
>>
>> Good to know! I must admit I did nothing special in this regard, just
>> paid attention to avoid breaking any existing logic, at least knowingly.
>>
>>>
>>>> [Footnote]
>>>>
>>>> *1* They are not limited to "-p", "--stat" and "--summary", but
>>>> you'd need to also pay attention to "--raw", "--name-only", etc.)
>>>
>>> I've merged the so/log-diff-merge topic to 'master', with this
>>> (possibly) known breakage that it does not do anything for single
>>> parent commits.  We may want to fix this last mile before the
>>> release that is scheduled to happen around early June.
>>
>> I have no idea what the breakage is or could be.
>
> Because I view
>
>  * "--diff-merges" is a way to specify how merge commits are passed
>    to the diff machinery (e.g. pass nothing to the diff machinery,
>    compare only with the first parent, etc.), and

As I see it, it only defines the way they are to be represented by the
diff machinery once passed to it, though it obviously depends on where
we put the margin of "diff machinery".

>
>  * "--patch", "--stat", "--cc" etc are to specify if we use the diff
>    machinery and what kind of output is desired.

So, in your view, --cc output is not a product of "diff machinery"?

> but we are conflating the "enable diff" feature into the former to
> match end-user expectation, if "--diff-merges" without any of the
> "--patch", "--stat", etc. enables the "--patch" output for merge
> commits, it would be confusing if we do not give the same "--patch"
> output for single-parent commits, too.
>
> But the current code gives "--patch" output only for merge commits,
> doesn't it?  E.g.

No, as far as I understand it, "--patch" output is for non-merge commits
only. One can't sensibly use patch utility to pick merge commits anyway,
so "--patch" makes no sense for merge commits and doesn't affect them,
at least for now.

>
>     $ git log --diff-merges=first-parent master..next
>
> would give patches only for merge commits, but

It will give the output similar to what "--patch" would give for
non-merge commits, yes, but in fact it's not "--patch" output, I think,
so I doubt it should be called "give patches". It's just happens to be
the same diff format.

>
>     $ git log --stat --diff-merges=first-parent master..next
>
> would give us diffstat for all commits, including merges (against
> their first parents).

Yep, but I think it just matches the old behavior that has been always
there, see below.

I'd start from the behavior even before my patches. Let's see:

  git log -n1 -p <merge_commit>
  git log -n1 --stat <merge_commit>
  git log -n1 --stat -p <merge_commit>

all give no diff no stat. No surprise for diff, though not that sure about
stat, but it could be argued either way.

  git log -n1 -c <merge_commit>

does give diff output in particular format, nice!

  git log -n1 --stat -c <merge_commit>

gives stat output, but no diff! That's not what I expected at all.
Effectively, this looks like --stat *disables* -c/-cc output?

Finally, the way to get both diff and stat for merge commits is... who'd
guess, adding -p to the command, and that provided -p is already
supposedly implied by -c (!):

  git log -n1 --stat -c -p <merge_commit>

In particular, this means that contrary to documentation, -c does not
imply -p in the common sense of the word "imply", and interdependencies
between all these options are already too complex to easily grok for a
human being.

As for newer --diff-merges, they behave similar to -c here that seems
reasonable. Overall, I still don't see any breakage introduced by
--diff-merges, and it seems to behave according to its documentation, so
shouldn't break any expectations either.

Getting back to the original question of letting -m imply -p, it
shouldn't behave differently than -c/-cc, that do imply -p, so I don't
see any significant problem that'd be added to the current status.

Right now the following two give exactly the same output:

  git log -n1 --stat -c <merge_commit>
  git log -n1 --stat -m <merge_commit>

the stat to the first parent, and it shouldn't change if we let -m "imply"
-p the same way -c "implies" -p, whatever it actually means.

Best Regards,

-- Sergey Organov

  reply	other threads:[~2021-05-03 17:42 UTC|newest]

Thread overview: 130+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-29  1:44 Why doesn't `git log -m` imply `-p`? Alex Henrie
2021-04-29  3:22 ` Junio C Hamano
2021-04-29 12:38   ` Sergey Organov
2021-04-29 15:25     ` Alex Henrie
2021-04-29 16:35       ` Sergey Organov
2021-04-29 17:24         ` Alex Henrie
2021-04-29 19:07           ` Sergey Organov
2021-05-04 20:09       ` Felipe Contreras
2021-05-04 20:34         ` Sergey Organov
2021-04-29 23:27     ` Junio C Hamano
2021-04-30  4:50       ` Junio C Hamano
2021-04-30 14:00         ` Sergey Organov
2021-05-01  0:41           ` Junio C Hamano
2021-05-03 17:42             ` Sergey Organov [this message]
2021-05-04  1:15               ` Junio C Hamano
2021-05-04  9:10                 ` Sergey Organov
2021-05-04 12:38                   ` Junio C Hamano
2021-05-04 14:18                     ` Sergey Organov
2021-05-05  0:20                       ` Junio C Hamano
2021-05-05 13:43                         ` Sergey Organov
2021-05-06  0:27                           ` Junio C Hamano
2021-05-06 12:59                             ` Sergey Organov
2021-05-06 20:29                               ` Junio C Hamano
2021-05-06 20:48                                 ` Sergey Organov
2021-05-07  1:31                                   ` Alex Henrie
2021-05-10 12:11 ` Sergey Organov
2021-05-10 16:56   ` Alex Henrie
2021-05-10 15:34 ` [PATCH 0/6] diff-merges: let -m imply -p Sergey Organov
2021-05-10 15:34   ` [PATCH 1/6] t4013: add test for "git diff-index -m" Sergey Organov
2021-05-10 15:34   ` [PATCH 2/6] diff-merges: move specific diff-index "-m" handling to diff-index Sergey Organov
2021-05-11  4:09     ` Junio C Hamano
2021-05-11  5:23       ` Junio C Hamano
2021-05-11  5:41         ` Junio C Hamano
2021-05-11 13:43       ` Sergey Organov
2021-05-10 15:34   ` [PATCH 3/6] git-svn: stop passing "-m" to "git rev-list" Sergey Organov
2021-05-10 15:34   ` [PATCH 4/6] stash list: stop passing "-m" to "git list" Sergey Organov
2021-05-10 15:34   ` [PATCH 5/6] diff-merges: rename "combined_imply_patch" to "merges_imply_patch" Sergey Organov
2021-05-10 15:34   ` [PATCH 6/6] diff-merges: let -m imply -p Sergey Organov
2021-05-11  4:14     ` Junio C Hamano
2021-05-11  4:56       ` Junio C Hamano
2021-05-11 14:03         ` Sergey Organov
2021-05-11 17:13           ` Alex Henrie
2021-05-11 18:46             ` Sergey Organov
2021-05-11 19:53               ` Alex Henrie
2021-05-11 20:27                 ` Sergey Organov
2021-05-12  1:16                   ` Felipe Contreras
2021-05-11 18:31           ` Elijah Newren
2021-05-11 19:00             ` Sergey Organov
2021-05-11 19:56               ` Elijah Newren
2021-05-11 20:32                 ` Sergey Organov
2021-05-11 20:43             ` Junio C Hamano
2021-05-11 21:38               ` Sergey Organov
2021-05-11 23:40                 ` Junio C Hamano
2021-05-19 21:44             ` Jonathan Nieder
2021-05-20 20:39               ` Sergey Organov
2021-05-21 18:14                 ` Felipe Contreras
2021-05-11 16:29         ` Sergey Organov
2021-05-17 12:57         ` Sergey Organov
2021-05-11 16:30       ` Sergey Organov
2021-05-19 21:48     ` Jonathan Nieder
2021-05-19 22:03       ` Sergey Organov
2021-05-19 23:32       ` Junio C Hamano
2021-05-20 13:14         ` Sergey Organov
2021-05-20 18:50           ` Jonathan Nieder
2021-05-20 19:38             ` Sergey Organov
2021-05-17 15:58 ` [PATCH v1 0/9] " Sergey Organov
2021-05-17 15:58   ` [PATCH v1 1/9] t4013: test that "-m" alone has no effect in "git log" Sergey Organov
2021-05-17 15:58   ` [PATCH v1 2/9] t4013: test "git -m --raw" Sergey Organov
2021-05-18  3:27     ` Bagas Sanjaya
2021-05-18 12:13       ` Sergey Organov
2021-05-17 15:58   ` [PATCH v1 3/9] t4013: test "git -m --stat" Sergey Organov
2021-05-17 15:58   ` [PATCH v1 4/9] t4013: test "git diff-index -m" Sergey Organov
2021-05-17 15:58   ` [PATCH v1 5/9] diff-merges: move specific diff-index "-m" handling to diff-index Sergey Organov
2021-05-17 20:10     ` Junio C Hamano
2021-05-17 20:24       ` Sergey Organov
2021-05-17 20:29     ` Junio C Hamano
2021-05-17 21:00       ` Sergey Organov
2021-05-17 15:58   ` [PATCH v1 6/9] git-svn: stop passing "-m" to "git rev-list" Sergey Organov
2021-05-17 15:58   ` [PATCH v1 7/9] stash list: stop passing "-m" to "git list" Sergey Organov
2021-05-17 15:58   ` [PATCH v1 8/9] diff-merges: rename "combined_imply_patch" to "merges_imply_patch" Sergey Organov
2021-05-17 15:58   ` [PATCH v1 9/9] diff-merges: let "-m" imply "-p" Sergey Organov
2021-05-17 19:51   ` [PATCH v1 0/9] diff-merges: let -m imply -p Junio C Hamano
2021-05-17 20:11     ` Sergey Organov
2021-05-18  3:18   ` Bagas Sanjaya
2021-05-18 12:03     ` Sergey Organov
2021-05-18 12:17     ` Sergey Organov
2021-05-18 14:17   ` Junio C Hamano
2021-05-18 15:52     ` Sergey Organov
2021-05-19 11:45 ` [PATCH v2 " Sergey Organov
2021-05-19 11:45   ` [PATCH v2 1/9] t4013: test that "-m" alone has no effect in "git log" Sergey Organov
2021-05-19 11:45   ` [PATCH v2 2/9] t4013: test "git log -m --raw" Sergey Organov
2021-05-19 11:45   ` [PATCH v2 3/9] t4013: test "git log -m --stat" Sergey Organov
2021-05-19 11:45   ` [PATCH v2 4/9] t4013: test "git diff-index -m" Sergey Organov
2021-05-19 11:45   ` [PATCH v2 5/9] diff-merges: move specific diff-index "-m" handling to diff-index Sergey Organov
2021-05-19 11:45   ` [PATCH v2 6/9] git-svn: stop passing "-m" to "git rev-list" Sergey Organov
2021-05-19 11:45   ` [PATCH v2 7/9] stash list: stop passing "-m" to "git log" Sergey Organov
2021-05-19 11:45   ` [PATCH v2 8/9] diff-merges: rename "combined_imply_patch" to "merges_imply_patch" Sergey Organov
2021-05-19 11:45   ` [PATCH v2 9/9] diff-merges: let "-m" imply "-p" Sergey Organov
2021-05-20 21:46 ` [PATCH v3 00/10] diff-merges: let -m imply -p Sergey Organov
2021-05-20 21:46   ` [PATCH v3 01/10] t4013: test that "-m" alone has no effect in "git log" Sergey Organov
2021-05-20 21:46   ` [PATCH v3 02/10] t4013: test "git log -m --raw" Sergey Organov
2021-05-20 21:46   ` [PATCH v3 03/10] t4013: test "git log -m --stat" Sergey Organov
2021-05-20 21:46   ` [PATCH v3 04/10] t4013: test "git diff-tree -m" Sergey Organov
2021-05-20 21:46   ` [PATCH v3 05/10] t4013: test "git diff-index -m" Sergey Organov
2021-05-20 21:46   ` [PATCH v3 06/10] diff-merges: move specific diff-index "-m" handling to diff-index Sergey Organov
2021-05-20 21:47   ` [PATCH v3 07/10] git-svn: stop passing "-m" to "git rev-list" Sergey Organov
2021-05-20 21:47   ` [PATCH v3 08/10] stash list: stop passing "-m" to "git log" Sergey Organov
2021-05-20 21:47   ` [PATCH v3 09/10] diff-merges: rename "combined_imply_patch" to "merges_imply_patch" Sergey Organov
2021-05-20 21:47   ` [PATCH v3 10/10] diff-merges: let "-m" imply "-p" Sergey Organov
2021-08-05  3:16     ` Jonathan Nieder
2021-08-06  1:45       ` [PATCH] Revert 'diff-merges: let "-m" imply "-p"' Jonathan Nieder
2021-08-06 17:21         ` Junio C Hamano
2021-08-06 17:55           ` Junio C Hamano
2021-08-06 19:57             ` Jonathan Nieder
2021-08-08 17:55               ` Junio C Hamano
2021-08-17  9:13                 ` Sergey Organov
2021-08-17 22:10                   ` Junio C Hamano
2021-08-18  8:56                     ` Sergey Organov
2021-08-19 18:50                       ` Junio C Hamano
2021-08-19 18:51                         ` Junio C Hamano
2021-08-20 10:24                         ` Sergey Organov
2021-08-07  1:55           ` Jonathan Nieder
2021-08-07  6:49             ` Johannes Sixt
2021-08-07 13:51               ` Jonathan Nieder
2021-08-07 17:00                 ` Junio C Hamano
2021-08-07 18:08                   ` Jonathan Nieder
2021-08-08  0:42                     ` Junio C Hamano
2021-08-17  9:17                       ` Sergey Organov
2021-08-16  9:09       ` [PATCH v3 10/10] diff-merges: let "-m" imply "-p" Sergey Organov
     [not found] <CANvKV6anT0MV7GDeY_Cd2r+BwvMjsTdmjK+s_DKth7ZqL0XRUQ@mail.gmail.com>
2021-05-19 17:03 ` Why doesn't `git log -m` imply `-p`? Sergey Organov

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87czu7u32v.fsf@osv.gnss.ru \
    --to=sorganov@gmail.com \
    --cc=alexhenrie24@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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