From: Sergey Organov <sorganov@gmail.com>
To: Glen Choo <chooglen@google.com>
Cc: "Junio C Hamano" <gitster@pobox.com>, "Jeff King" <peff@peff.net>,
"Philip Oakley" <philipoakley@iee.email>,
"Elijah Newren" <newren@gmail.com>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
"Alex Henrie" <alexhenrie24@gmail.com>,
"Jonathan Nieder" <jrnieder@gmail.com>,
"huang guanlong" <gl041188@gmail.com>,
git@vger.kernel.org
Subject: Re: [PATCH 0/5] diff-merges: more features
Date: Sat, 10 Dec 2022 23:45:32 +0300 [thread overview]
Message-ID: <87ilijt2c3.fsf@osv.gnss.ru> (raw)
In-Reply-To: <kl6lcz8tebtk.fsf@chooglen-macbookpro.roam.corp.google.com> (Glen Choo's message of "Thu, 08 Dec 2022 15:05:11 -0800")
Glen Choo <chooglen@google.com> writes:
> Sergey Organov <sorganov@gmail.com> writes:
>
>> The last time '-m' issue appeared on the list, it all started here:
>>
>> https://lore.kernel.org/git/CAMMLpeR-W35Qq6a343ifrxJ=mwBc_VcXZtVrBYDpJTySNBroFw@mail.gmail.com/
>>
>> In particular, the final patch and its revert is deeper down this tread:
>>
>> https://lore.kernel.org/git/20210520214703.27323-11-sorganov@gmail.com/#t
>>
>> and
>>
>> https://lore.kernel.org/git/YQyUM2uZdFBX8G0r@google.com/
>
> Thanks, these provide extremely helpful context :) In particular:
>
> - Junio describes this "do nothing unless -p" is given behavior as an
> accident [1].
I rather read it as Junio saying that "-m does not imply -p" is
historical accident, and yes, it is, provided '-c/--cc' were fixed at
some point, and '-m' was not, so in fact I figure Junio meant: "-m
differs from -c/--cc in not implying '-p'" is historical accident. And
then he suggests to leave it as is, with which I disagree.
In addition, in all the discussions, I believe Junio at least once said
he does see valid usages for current hush '-m':
<quote>
But "stash list" example shows that "log --first-parent -m" without
"-p" in a script has a valid reason, and a change that hurts those
who correctly used a command and an option in a way they were
intended to do _is_ problematic.
</quote>
here:
https://lore.kernel.org/git/xmqqy29chim6.fsf@gitster.g/
> - Jonathan Nieder notes that this change accidentally broke scripts
> where "-m" probably wasn't doing anything useful, but we wanted to
> avoid breaking the scripts for backwards compatibility anyway [2].
>
> I got the sense that the closest thing to an intentional use case of
> "-m" is for users who thought that "-m" would affect path limiting [3],
> although it doesn't actually do that.
I don't think so. Dunno why you got such feeling. It's rather that for
some time "--first-parent -m" was the only way to produce *most* useful
form of "-m" format: show diff with respect to the *first* parent only,
whereas without "--first-parent" "-m" produced diff output for *every*
parent in turn(!) giving extremely confusing result. Please notice how
--first-parent appears in most of those discussions.
Overall, the (simplified) history of '-m' goes like this, as far as I
can tell:
0. Original '-m', documented only for 'diff-tree'. The diffs were
produced to all the parents that was probably very logical for
plumbing 'diff-tree', as it reflects symmetric nature of merge
commits in the DAG, that is the core of git data model.
However, while "git log -p" does not produce patches for merge
commits (apparently to get rid of often large output), '-m' in fact
enforces the output for merge commits, in the format produced by
'diff-tree -m', i.e., diffs to all the parents in turn.
[The latter was probably the first mistake, it should have rather
produced the diff with respect to the first parent that is more
suitable for "git log" being porcelain, to show changes introduced by
the commit to the mainline, exactly as for non-merge commits]
1. '-c' is introduced, then '--cc' is introduced, with semantics similar
to '-m' with respect to '-p', but different kinds of output.
At this point we have consistent behavior of '-m', '-c', and '--cc'
with respect to '-p', none of which produce any output unless '-p' is
specified as well.
2. '-c' and '--cc' are changed to imply '-p'[0]. '-m' is left alone,
supposedly forgotten as being undocumented for "git log" and of
limited use, due to its large and surprising output.
[I think that was the second mistake, forgetting to change '-m'
accordingly]
3. '-m' is changed to produce diff with respect to the first parent only
when '--first-parent' is specified [1]. '-m' finally starts to
(sometimes) give useful output, and starts to be actually used,
but only together with '--first-parent' most of times.
BTW, this is the first time '-m' has been documented as part of "git
log": "This patch properly documents the -m switch, which has so far
been mentioned only as a fairly special diff-tree flag."
[I think there are more mistakes here: not changing '-m' to imply
'-p' at this point, and not producing single-parent diff even without
'--first-parent']
4. "--first-parent" is suggested to imply "-m"(!) to let "--first-parent
-p" to produce diff for merge commits[2]. That in turn needed an
option that will negate implied "-m", and that's where
--[no-]diff-merges was suggested.
Please notice that if '-m' implied '-p' (as it should) at this point,
there should be little needed for these patches, as just saying "git
log --first-parent -m" would produce required result. So, mistakes
above caused a need to fix them.
5. At this point, in the referenced discussion I suggested
'--diff-merges=on|off' instead of '--[no-]diff-merges', to allow for
further extensions.
6. '--diff-merges=' option actually born to provide some missing
functionality and to get rid of inconsistencies[3].
7. '-m' format becomes configurable using new "log.diffMerges"
configuration[4] so that we can make it conveniently useful even
without "--first-parent". This was immediately implemented in
generalized manner to allow to configure '-m' to produce not only
single-parent diff, but any supported format.
8. As a reply to yet another request on the mailing list "why '-m'
produces no output", I tried "-m imply -p" patch series[5], which
were accepted, but then the last patch only(!) from the series, that
actually introduced required behavior, has been reverted.
This left me feel I got some unfinished job to do.
9. These patch series, trying "-m imply -p" again, now more carefully.
> So what I've reads so far suggests that "do nothing unless -p" (aka
> --diff-merges=hide) is not actually useful, and we should just drop
> it.
Again, I've tried exactly this before, and that was first accepted, and
then reverted, that's why --diff-merges=hide has been introduced in
these series, to address the issues raised during revert request.
References:
[0]: Showing merges easier with "git log":
https://lore.kernel.org/git/1440110591-12941-1-git-send-email-gitster@pobox.com/
[1]: git log -p -m: Document, honor --first-parent
https://lore.kernel.org/git/20100210011149.GR9553@machine.or.cz/
[2]: making --first-parent imply -m:
https://lore.kernel.org/git/20200728163617.GA2649887@coredump.intra.peff.net/
[3]: git-log: implement new --diff-merge options:
https://lore.kernel.org/git/20201221152000.13134-1-sorganov@gmail.com/
[4]: git log: configurable default format for merge diffs
https://lore.kernel.org/git/20210413114118.25693-1-sorganov@gmail.com/
[5]: diff-merges: let -m imply -p
https://lore.kernel.org/git/20210520214703.27323-1-sorganov@gmail.com/
Thanks,
-- Sergey Organov
next prev parent reply other threads:[~2022-12-10 20:45 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-27 9:37 [PATCH 0/5] diff-merges: more features Sergey Organov
2022-11-27 9:37 ` [PATCH 1/5] diff-merges: implement [no-]hide option and log.diffMergesHide config Sergey Organov
2022-12-08 0:06 ` Glen Choo
2022-12-08 18:13 ` Sergey Organov
2022-11-27 9:37 ` [PATCH 2/5] diff-merges: implement log.diffMerges-m-imply-p config Sergey Organov
2022-11-27 9:37 ` [PATCH 3/5] diff-merges: implement log.diffMergesForce config Sergey Organov
2022-11-28 2:35 ` Junio C Hamano
2022-11-28 14:44 ` Sergey Organov
2022-11-29 15:30 ` Junio C Hamano
2022-11-29 17:59 ` Ævar Arnfjörð Bjarmason
2022-11-30 13:01 ` Sergey Organov
2022-11-30 13:28 ` Junio C Hamano
2022-11-29 18:48 ` Jeff King
2022-11-30 13:02 ` Sergey Organov
2022-11-29 5:10 ` Elijah Newren
2022-11-30 12:58 ` Sergey Organov
2022-11-27 9:37 ` [PATCH 4/5] diff-merges: support list of values for --diff-merges Sergey Organov
2022-11-27 9:37 ` [PATCH 5/5] diff-merges: issue warning on lone '-m' option Sergey Organov
2022-11-28 7:51 ` [PATCH 0/5] diff-merges: more features Junio C Hamano
2022-11-28 14:42 ` Sergey Organov
2022-11-29 4:50 ` Elijah Newren
2022-11-30 13:16 ` Sergey Organov
2022-12-01 2:21 ` Elijah Newren
2022-12-01 9:36 ` Sergey Organov
2022-12-07 23:55 ` Glen Choo
2022-12-08 14:29 ` Sergey Organov
2022-12-08 23:05 ` Glen Choo
2022-12-10 20:45 ` Sergey Organov [this message]
2022-12-08 23:06 ` Glen Choo
2022-12-08 16:18 ` Sergey Organov
2022-12-17 13:29 ` [PATCH v1 0/5] diff-merges: more features to fix '-m' Sergey Organov
2022-12-17 13:29 ` [PATCH v1 1/5] diff-merges: implement [no-]hide option and log.diffMergesHide config Sergey Organov
2022-12-17 13:29 ` [PATCH v1 2/5] diff-merges: implement log.diffMerges-m-imply-p config Sergey Organov
2022-12-17 13:29 ` [PATCH v1 3/5] diff-merges: support list of values for --diff-merges Sergey Organov
2022-12-17 13:29 ` [PATCH v1 4/5] diff-merges: issue warning on lone '-m' option Sergey Organov
2022-12-17 13:29 ` [PATCH v1 5/5] diff-merges: improve --diff-merges documentation Sergey Organov
2022-12-18 3:10 ` [PATCH v1 0/5] diff-merges: more features to fix '-m' Junio C Hamano
2022-12-19 14:22 ` Sergey Organov
2022-12-19 14:29 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ilijt2c3.fsf@osv.gnss.ru \
--to=sorganov@gmail.com \
--cc=alexhenrie24@gmail.com \
--cc=avarab@gmail.com \
--cc=chooglen@google.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=gl041188@gmail.com \
--cc=jrnieder@gmail.com \
--cc=newren@gmail.com \
--cc=peff@peff.net \
--cc=philipoakley@iee.email \
/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 NNTP newsgroup(s).