git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: Sergey Organov <sorganov@gmail.com>
Cc: "Junio C Hamano" <gitster@pobox.com>, "Jeff King" <peff@peff.net>,
	"Philip Oakley" <philipoakley@iee.email>,
	"Elijah Newren" <newren@gmail.com>,
	"Felipe Contreras" <felipe.contreras@gmail.com>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"Alex Henrie" <alexhenrie24@gmail.com>,
	"huang guanlong" <gl041188@gmail.com>,
	git@vger.kernel.org, "Hudson Ayers" <hudsonayers@google.com>,
	"Taylor Yu" <tlyu@mit.edu>, "Joshua Nelson" <jyn514@gmail.com>
Subject: [PATCH] Revert 'diff-merges: let "-m" imply "-p"'
Date: Thu, 5 Aug 2021 18:45:23 -0700	[thread overview]
Message-ID: <YQyUM2uZdFBX8G0r@google.com> (raw)
In-Reply-To: <YQtYEftByY8cNMml@google.com>

This reverts commit f5bfcc823ba242a46e20fb6f71c9fbf7ebb222fe, which
made "git log -m" imply "--patch" by default.  The logic was that
"-m", which makes diff generation for merges perform a diff against
each parent, has no use unless I am viewing the diff, so we could save
the user some typing by turning on display of the resulting diff
automatically.  That wasn't expected to adversely affect scripts
because scripts would either be using a command like "git diff-tree"
that already emits diffs by default or would be combining -m with a
diff generation option such as --name-status.  By saving typing for
interactive use without adversely affecting scripts in the wild, it
would be a pure improvement.

The problem is that although diff generation options are only relevant
for the displayed diff, a script author can imagine them affecting
path limiting.  For example, I might run

	git log -w --format=%H -- README

hoping to list commits that edited README, excluding whitespace-only
changes.  In fact, a whitespace-only change is not TREESAME so the use
of -w here has no effect (since we don't apply these diff generation
flags to the diff_options struct rev_info::pruning used for this
purpose), but the documentation suggests that it should work

	Suppose you specified foo as the <paths>. We shall call
	commits that modify foo !TREESAME, and the rest TREESAME. (In
	a diff filtered for foo, they look different and equal,
	respectively.)

and a script author who has not tested whitespace-only changes
wouldn't notice.

Similarly, a script author could include

	git log -m --first-parent --format=%H -- README

to filter the first-parent history for commits that modified README.
The -m is a no-op but it reflects the script author's intent.  For
example, until 1e20a407fe2 (stash list: stop passing "-m" to "git
log", 2021-05-21), "git stash list" did this.

As a result, we can't safely change "-m" to imply "-p" without fear of
breaking such scripts.  Restore the previous behavior.

Noticed because Rust's src/bootstrap/bootstrap.py made use of this
same construct: https://github.com/rust-lang/rust/pull/87513.  That
script has been updated to omit the unnecessary "-m" option, but we
can expect other scripts in the wild to have similar expectations.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Hi,

Joshua Nelson wrote[1]:
> Jonathan Nieder wrote:

>> What happens if someone wants to build an older version of Rust?
>
> For what it's worth, almost no one builds old versions of rust from source
> except for distros, and distros wouldn't ever set download-ci-llvm = true. So
> this shouldn't affect anyone in practice now that we've removed `-m` on master.

Thanks.  With that out of the way, I started thinking more clearly
about the intent behind this use of `-m` and I'm starting to think it
wasn't a typo after all.

As a result, in terms of

>>  a. Revert 'diff-merges: let "-m" imply "-p"'.  This buys us time to
>>     make a more targeted change, make the change more gradually in a
>>     future release, or just stop encouraging use of "-m" in docs.
>>
>>  b. Make "-m" imply "-p", except in some more 'script-ish'
>>     circumstances (e.g. when using log --format with a format string)
>>
>>  c. Go ahead with the change and advertise it in release notes.

now I lean toward (a).  How about this patch?

Thanks,
Jonathan

[1] https://lore.kernel.org/git/CAJ+j++Vj1gY93QuKDhDODXOJGXTiFFEzy0Oew+LWD7a5e7iaTA@mail.gmail.com/

 Documentation/diff-options.txt | 8 ++++----
 diff-merges.c                  | 1 -
 t/t4013-diff-various.sh        | 4 ++--
 3 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
index 0aebe832057..c89d530d3d1 100644
--- a/Documentation/diff-options.txt
+++ b/Documentation/diff-options.txt
@@ -49,9 +49,10 @@ ifdef::git-log[]
 --diff-merges=m:::
 -m:::
 	This option makes diff output for merge commits to be shown in
-	the default format. The default format could be changed using
+	the default format. `-m` will produce the output only if `-p`
+	is given as well. The default format could be changed using
 	`log.diffMerges` configuration parameter, which default value
-	is `separate`. `-m` implies `-p`.
+	is `separate`.
 +
 --diff-merges=first-parent:::
 --diff-merges=1:::
@@ -61,8 +62,7 @@ ifdef::git-log[]
 --diff-merges=separate:::
 	This makes merge commits show the full diff with respect to
 	each of the parents. Separate log entry and diff is generated
-	for each parent. This is the format that `-m` produced
-	historically.
+	for each parent.
 +
 --diff-merges=combined:::
 --diff-merges=c:::
diff --git a/diff-merges.c b/diff-merges.c
index 0dfcaa1b11b..d897fd8a293 100644
--- a/diff-merges.c
+++ b/diff-merges.c
@@ -107,7 +107,6 @@ int diff_merges_parse_opts(struct rev_info *revs, const char **argv)
 
 	if (!strcmp(arg, "-m")) {
 		set_to_default(revs);
-		revs->merges_imply_patch = 1;
 	} else if (!strcmp(arg, "-c")) {
 		set_combined(revs);
 		revs->merges_imply_patch = 1;
diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh
index 7fadc985ccc..e561a8e4852 100755
--- a/t/t4013-diff-various.sh
+++ b/t/t4013-diff-various.sh
@@ -455,8 +455,8 @@ diff-tree --stat --compact-summary initial mode
 diff-tree -R --stat --compact-summary initial mode
 EOF
 
-test_expect_success 'log -m matches log -m -p' '
-	git log -m -p master >result &&
+test_expect_success 'log -m matches pure log' '
+	git log master >result &&
 	process_diffs result >expected &&
 	git log -m >result &&
 	process_diffs result >actual &&
-- 
2.32.0.605.g8dce9f2422-goog


  reply	other threads:[~2021-08-06  1:45 UTC|newest]

Thread overview: 129+ 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
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       ` Jonathan Nieder [this message]
2021-08-06 17:21         ` [PATCH] Revert 'diff-merges: let "-m" imply "-p"' 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

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=YQyUM2uZdFBX8G0r@google.com \
    --to=jrnieder@gmail.com \
    --cc=alexhenrie24@gmail.com \
    --cc=avarab@gmail.com \
    --cc=felipe.contreras@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=gl041188@gmail.com \
    --cc=hudsonayers@google.com \
    --cc=jyn514@gmail.com \
    --cc=newren@gmail.com \
    --cc=peff@peff.net \
    --cc=philipoakley@iee.email \
    --cc=sorganov@gmail.com \
    --cc=tlyu@mit.edu \
    /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).