From patchwork Wed Jul 29 20:10:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff King X-Patchwork-Id: 11691645 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7492113B6 for ; Wed, 29 Jul 2020 20:10:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 630C12067D for ; Wed, 29 Jul 2020 20:10:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726671AbgG2UKS (ORCPT ); Wed, 29 Jul 2020 16:10:18 -0400 Received: from cloud.peff.net ([104.130.231.41]:41468 "EHLO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726365AbgG2UKS (ORCPT ); Wed, 29 Jul 2020 16:10:18 -0400 Received: (qmail 8780 invoked by uid 109); 29 Jul 2020 20:10:18 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Wed, 29 Jul 2020 20:10:18 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 7784 invoked by uid 111); 29 Jul 2020 20:10:17 -0000 Received: from coredump.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.2) by peff.net (qpsmtpd/0.94) with (TLS_AES_256_GCM_SHA384 encrypted) ESMTPS; Wed, 29 Jul 2020 16:10:17 -0400 Authentication-Results: peff.net; auth=none Date: Wed, 29 Jul 2020 16:10:17 -0400 From: Jeff King To: git@vger.kernel.org Cc: Junio C Hamano , Chris Torek Subject: [PATCH v2 1/7] log: drop "--cc implies -m" logic Message-ID: <20200729201017.GA2989342@coredump.intra.peff.net> References: <20200729201002.GA2989059@coredump.intra.peff.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200729201002.GA2989059@coredump.intra.peff.net> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org This was added by 82dee4160c (log: show merge commit when --cc is given, 2015-08-20), which explains why we need it. But that commit failed to notice that setup_revisions() already does the same thing, since cd2bdc5309 (Common option parsing for "git log --diff" and friends, 2006-04-14). Signed-off-by: Jeff King --- builtin/log.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/builtin/log.c b/builtin/log.c index d104d5c688..281d2ae8eb 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -731,10 +731,6 @@ static void log_setup_revisions_tweak(struct rev_info *rev, /* Turn --cc/-c into -p --cc/-c when -p was not given */ if (!rev->diffopt.output_format && rev->combine_merges) rev->diffopt.output_format = DIFF_FORMAT_PATCH; - - /* Turn -m on when --cc/-c was given */ - if (rev->combine_merges) - rev->ignore_merges = 0; } int cmd_log(int argc, const char **argv, const char *prefix) From patchwork Wed Jul 29 20:10:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff King X-Patchwork-Id: 11691647 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5283213B6 for ; Wed, 29 Jul 2020 20:10:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 42C62206D7 for ; Wed, 29 Jul 2020 20:10:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726787AbgG2UKW (ORCPT ); Wed, 29 Jul 2020 16:10:22 -0400 Received: from cloud.peff.net ([104.130.231.41]:41476 "EHLO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726365AbgG2UKW (ORCPT ); Wed, 29 Jul 2020 16:10:22 -0400 Received: (qmail 8790 invoked by uid 109); 29 Jul 2020 20:10:21 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Wed, 29 Jul 2020 20:10:21 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 7795 invoked by uid 111); 29 Jul 2020 20:10:20 -0000 Received: from coredump.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.2) by peff.net (qpsmtpd/0.94) with (TLS_AES_256_GCM_SHA384 encrypted) ESMTPS; Wed, 29 Jul 2020 16:10:20 -0400 Authentication-Results: peff.net; auth=none Date: Wed, 29 Jul 2020 16:10:20 -0400 From: Jeff King To: git@vger.kernel.org Cc: Junio C Hamano , Chris Torek Subject: [PATCH v2 2/7] revision: add "--no-diff-merges" option to counteract "-m" Message-ID: <20200729201020.GB2989342@coredump.intra.peff.net> References: <20200729201002.GA2989059@coredump.intra.peff.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200729201002.GA2989059@coredump.intra.peff.net> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The "-m" option sets revs->ignore_merges to "0", but there's no way to undo it. This probably isn't something anybody overly cares about, since "1" is already the default, but it will serve as an escape hatch when we flip the default for ignore_merges to "0" in more situations. We'll also add a few extra niceties: - initialize the value to "-1" to indicate "not set", and then resolve it to the normal 0/1 bool in setup_revisions(). This lets any tweak functions, as well as setup_revisions() itself, avoid clobbering the user's preference (which until now they couldn't actually express). - since we now have --no-diff-merges, let's add the matching --diff-merges, which is just a synonym for "-m". Then we don't even need to document --no-diff-merges separately; it countermands the long form of "-m" in the usual way. The new test shows that this behaves just the same as the current behavior without "-m". Signed-off-by: Jeff King --- Documentation/rev-list-options.txt | 1 + builtin/log.c | 4 +- revision.c | 10 ++- revision.h | 2 +- t/t4013-diff-various.sh | 1 + ..._--no-diff-merges_-p_--first-parent_master | 78 +++++++++++++++++++ 6 files changed, 90 insertions(+), 6 deletions(-) create mode 100644 t/t4013/diff.log_--no-diff-merges_-p_--first-parent_master diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt index b01b2b6773..0785a0cfe9 100644 --- a/Documentation/rev-list-options.txt +++ b/Documentation/rev-list-options.txt @@ -1148,6 +1148,7 @@ options may be given. See linkgit:git-diff-files[1] for more options. rename or copy detection have been requested). -m:: +--diff-merges:: This flag makes the merge commits show the full diff like regular commits; for each merge parent, a separate log entry and diff is generated. An exception is that only diff against diff --git a/builtin/log.c b/builtin/log.c index 281d2ae8eb..39b3d773a9 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -599,8 +599,8 @@ static int show_tree_object(const struct object_id *oid, static void show_setup_revisions_tweak(struct rev_info *rev, struct setup_revision_opt *opt) { - if (rev->ignore_merges) { - /* There was no "-m" on the command line */ + if (rev->ignore_merges < 0) { + /* There was no "-m" variant on the command line */ rev->ignore_merges = 0; if (!rev->first_parent_only && !rev->combine_merges) { /* No "--first-parent", "-c", or "--cc" */ diff --git a/revision.c b/revision.c index 6aa7f4f567..669bc85669 100644 --- a/revision.c +++ b/revision.c @@ -1795,7 +1795,7 @@ void repo_init_revisions(struct repository *r, revs->repo = r; revs->abbrev = DEFAULT_ABBREV; - revs->ignore_merges = 1; + revs->ignore_merges = -1; revs->simplify_history = 1; revs->pruning.repo = r; revs->pruning.flags.recursive = 1; @@ -2323,8 +2323,10 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg revs->diff = 1; revs->diffopt.flags.recursive = 1; revs->diffopt.flags.tree_in_recursive = 1; - } else if (!strcmp(arg, "-m")) { + } else if (!strcmp(arg, "-m") || !strcmp(arg, "--diff-merges")) { revs->ignore_merges = 0; + } else if (!strcmp(arg, "--no-diff-merges")) { + revs->ignore_merges = 1; } else if (!strcmp(arg, "-c")) { revs->diff = 1; revs->dense_combined_merges = 0; @@ -2834,8 +2836,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s copy_pathspec(&revs->diffopt.pathspec, &revs->prune_data); } - if (revs->combine_merges) + if (revs->combine_merges && revs->ignore_merges < 0) revs->ignore_merges = 0; + if (revs->ignore_merges < 0) + revs->ignore_merges = 1; if (revs->combined_all_paths && !revs->combine_merges) die("--combined-all-paths makes no sense without -c or --cc"); diff --git a/revision.h b/revision.h index f412ae85eb..5258024743 100644 --- a/revision.h +++ b/revision.h @@ -190,11 +190,11 @@ struct rev_info { show_root_diff:1, no_commit_id:1, verbose_header:1, - ignore_merges:1, combine_merges:1, combined_all_paths:1, dense_combined_merges:1, always_show_header:1; + int ignore_merges:2; /* Format info */ int show_notes; diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh index 43267d6024..40e222c945 100755 --- a/t/t4013-diff-various.sh +++ b/t/t4013-diff-various.sh @@ -297,6 +297,7 @@ log --root --patch-with-stat --summary master log --root -c --patch-with-stat --summary master # improved by Timo's patch log --root --cc --patch-with-stat --summary master +log --no-diff-merges -p --first-parent master log -p --first-parent master log -m -p --first-parent master log -m -p master diff --git a/t/t4013/diff.log_--no-diff-merges_-p_--first-parent_master b/t/t4013/diff.log_--no-diff-merges_-p_--first-parent_master new file mode 100644 index 0000000000..94bf1850b2 --- /dev/null +++ b/t/t4013/diff.log_--no-diff-merges_-p_--first-parent_master @@ -0,0 +1,78 @@ +$ git log --no-diff-merges -p --first-parent master +commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 +Merge: 9a6d494 c7a2ab9 +Author: A U Thor +Date: Mon Jun 26 00:04:00 2006 +0000 + + Merge branch 'side' into master + +commit 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0 +Author: A U Thor +Date: Mon Jun 26 00:02:00 2006 +0000 + + Third + +diff --git a/dir/sub b/dir/sub +index 8422d40..cead32e 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -2,3 +2,5 @@ A + B + C + D ++E ++F +diff --git a/file1 b/file1 +new file mode 100644 +index 0000000..b1e6722 +--- /dev/null ++++ b/file1 +@@ -0,0 +1,3 @@ ++A ++B ++C + +commit 1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44 +Author: A U Thor +Date: Mon Jun 26 00:01:00 2006 +0000 + + Second + + This is the second commit. + +diff --git a/dir/sub b/dir/sub +index 35d242b..8422d40 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++C ++D +diff --git a/file0 b/file0 +index 01e79c3..b414108 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++4 ++5 ++6 +diff --git a/file2 b/file2 +deleted file mode 100644 +index 01e79c3..0000000 +--- a/file2 ++++ /dev/null +@@ -1,3 +0,0 @@ +-1 +-2 +-3 + +commit 444ac553ac7612cc88969031b02b3767fb8a353a +Author: A U Thor +Date: Mon Jun 26 00:00:00 2006 +0000 + + Initial +$ From patchwork Wed Jul 29 20:10:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff King X-Patchwork-Id: 11691649 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0D3A813B1 for ; Wed, 29 Jul 2020 20:10:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E995D206D7 for ; Wed, 29 Jul 2020 20:10:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726800AbgG2UKa (ORCPT ); Wed, 29 Jul 2020 16:10:30 -0400 Received: from cloud.peff.net ([104.130.231.41]:41488 "EHLO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726365AbgG2UK3 (ORCPT ); Wed, 29 Jul 2020 16:10:29 -0400 Received: (qmail 8806 invoked by uid 109); 29 Jul 2020 20:10:29 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Wed, 29 Jul 2020 20:10:29 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 7826 invoked by uid 111); 29 Jul 2020 20:10:29 -0000 Received: from coredump.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.2) by peff.net (qpsmtpd/0.94) with (TLS_AES_256_GCM_SHA384 encrypted) ESMTPS; Wed, 29 Jul 2020 16:10:29 -0400 Authentication-Results: peff.net; auth=none Date: Wed, 29 Jul 2020 16:10:28 -0400 From: Jeff King To: git@vger.kernel.org Cc: Junio C Hamano , Chris Torek Subject: [PATCH v2 3/7] log: enable "-m" automatically with "--first-parent" Message-ID: <20200729201028.GC2989342@coredump.intra.peff.net> References: <20200729201002.GA2989059@coredump.intra.peff.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200729201002.GA2989059@coredump.intra.peff.net> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When using "--first-parent" to consider history as a single line of commits, git-log still defaults to treating merges specially, even though they could be considered as single commits in the linearized history (that just introduce all of the changes from the second and higher parents). Let's instead have "--first-parent" imply "-m", which makes something like: git log --first-parent -p do what you'd expect. Likewise: git log --first-parent -Sfoo will find "foo" in merge commits. No new test is needed; we'll tweak the output of the existing "--first-parent -p" test, which now matches the "-m --first-parent -p" test. The unchanged existing test for "--no-diff-merges" confirms that the user can get the old behavior if they want. Signed-off-by: Jeff King --- builtin/log.c | 3 +++ t/t4013/diff.log_-p_--first-parent_master | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/builtin/log.c b/builtin/log.c index 39b3d773a9..83b147c23a 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -731,6 +731,9 @@ static void log_setup_revisions_tweak(struct rev_info *rev, /* Turn --cc/-c into -p --cc/-c when -p was not given */ if (!rev->diffopt.output_format && rev->combine_merges) rev->diffopt.output_format = DIFF_FORMAT_PATCH; + + if (rev->first_parent_only && rev->ignore_merges < 0) + rev->ignore_merges = 0; } int cmd_log(int argc, const char **argv, const char *prefix) diff --git a/t/t4013/diff.log_-p_--first-parent_master b/t/t4013/diff.log_-p_--first-parent_master index c6a5876d80..fe044399f0 100644 --- a/t/t4013/diff.log_-p_--first-parent_master +++ b/t/t4013/diff.log_-p_--first-parent_master @@ -6,6 +6,28 @@ Date: Mon Jun 26 00:04:00 2006 +0000 Merge branch 'side' into master +diff --git a/dir/sub b/dir/sub +index cead32e..992913c 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -4,3 +4,5 @@ C + D + E + F ++1 ++2 +diff --git a/file0 b/file0 +index b414108..10a8a9f 100644 +--- a/file0 ++++ b/file0 +@@ -4,3 +4,6 @@ + 4 + 5 + 6 ++A ++B ++C + commit 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0 Author: A U Thor Date: Mon Jun 26 00:02:00 2006 +0000 From patchwork Wed Jul 29 20:11:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff King X-Patchwork-Id: 11691651 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1BEA213B1 for ; Wed, 29 Jul 2020 20:11:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0CDAC206D7 for ; Wed, 29 Jul 2020 20:11:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726757AbgG2ULS (ORCPT ); Wed, 29 Jul 2020 16:11:18 -0400 Received: from cloud.peff.net ([104.130.231.41]:41498 "EHLO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726365AbgG2ULS (ORCPT ); Wed, 29 Jul 2020 16:11:18 -0400 Received: (qmail 8822 invoked by uid 109); 29 Jul 2020 20:11:17 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Wed, 29 Jul 2020 20:11:17 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 7844 invoked by uid 111); 29 Jul 2020 20:11:16 -0000 Received: from coredump.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.2) by peff.net (qpsmtpd/0.94) with (TLS_AES_256_GCM_SHA384 encrypted) ESMTPS; Wed, 29 Jul 2020 16:11:16 -0400 Authentication-Results: peff.net; auth=none Date: Wed, 29 Jul 2020 16:11:16 -0400 From: Jeff King To: git@vger.kernel.org Cc: Junio C Hamano , Chris Torek Subject: [PATCH v2 4/7] doc/git-log: move "Diff Formatting" from rev-list-options Message-ID: <20200729201116.GD2989342@coredump.intra.peff.net> References: <20200729201002.GA2989059@coredump.intra.peff.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200729201002.GA2989059@coredump.intra.peff.net> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Our rev-list-options.txt include has a "Diff Formatting" section, but it is ifndef'd out for all manpages except git-log. And a few bits of the text are rather out of date. We say "some of these options are specific to git-rev-list". That's obviously silly since we (even before this patch) show the content only for git-log. But moreover, it's not true; each of the listed options is meaningful for other diff commands. We also say "...however other diff options may be given. See git-diff-files for more options." But there's no need to do so; git-log already has a "Common Diff Options" section which includes diff-options.txt. So let's move these options over to git-log and put them with the other diff options, giving a single "diff" section for the git-log documentation. We'll call it "Diff Formatting" but use the all-caps top-level header to match its sibling sections. And we'll rewrite the section intro to remove the useless bits and give a more generic overview of the section which can be later extended. Signed-off-by: Jeff King --- Documentation/git-log.txt | 42 +++++++++++++++++++++++++-- Documentation/rev-list-options.txt | 46 ------------------------------ 2 files changed, 40 insertions(+), 48 deletions(-) diff --git a/Documentation/git-log.txt b/Documentation/git-log.txt index 20e6d21a74..fb3998d8e0 100644 --- a/Documentation/git-log.txt +++ b/Documentation/git-log.txt @@ -111,8 +111,46 @@ include::rev-list-options.txt[] include::pretty-formats.txt[] -COMMON DIFF OPTIONS -------------------- +DIFF FORMATTING +--------------- + +By default, `git log` does not generate any diff output. The options +below can be used to show the changes made by each commit. + +-c:: + With this option, diff output for a merge commit + shows the differences from each of the parents to the merge result + simultaneously instead of showing pairwise diff between a parent + and the result one at a time. Furthermore, it lists only files + which were modified from all parents. + +--cc:: + This flag implies the `-c` option and further compresses the + patch output by omitting uninteresting hunks whose contents in + the parents have only two variants and the merge result picks + one of them without modification. + +--combined-all-paths:: + This flag causes combined diffs (used for merge commits) to + list the name of the file from all parents. It thus only has + effect when -c or --cc are specified, and is likely only + useful if filename changes are detected (i.e. when either + rename or copy detection have been requested). + +-m:: +--diff-merges:: + This flag makes the merge commits show the full diff like + regular commits; for each merge parent, a separate log entry + and diff is generated. An exception is that only diff against + the first parent is shown when `--first-parent` option is given; + in that case, the output represents the changes the merge + brought _into_ the then-current branch. + +-r:: + Show recursive diffs. + +-t:: + Show the tree objects in the diff output. This implies `-r`. :git-log: 1 include::diff-options.txt[] diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt index 0785a0cfe9..398178d72a 100644 --- a/Documentation/rev-list-options.txt +++ b/Documentation/rev-list-options.txt @@ -1117,49 +1117,3 @@ ifdef::git-rev-list[] by a tab. endif::git-rev-list[] endif::git-shortlog[] - -ifndef::git-shortlog[] -ifndef::git-rev-list[] -Diff Formatting -~~~~~~~~~~~~~~~ - -Listed below are options that control the formatting of diff output. -Some of them are specific to linkgit:git-rev-list[1], however other diff -options may be given. See linkgit:git-diff-files[1] for more options. - --c:: - With this option, diff output for a merge commit - shows the differences from each of the parents to the merge result - simultaneously instead of showing pairwise diff between a parent - and the result one at a time. Furthermore, it lists only files - which were modified from all parents. - ---cc:: - This flag implies the `-c` option and further compresses the - patch output by omitting uninteresting hunks whose contents in - the parents have only two variants and the merge result picks - one of them without modification. - ---combined-all-paths:: - This flag causes combined diffs (used for merge commits) to - list the name of the file from all parents. It thus only has - effect when -c or --cc are specified, and is likely only - useful if filename changes are detected (i.e. when either - rename or copy detection have been requested). - --m:: ---diff-merges:: - This flag makes the merge commits show the full diff like - regular commits; for each merge parent, a separate log entry - and diff is generated. An exception is that only diff against - the first parent is shown when `--first-parent` option is given; - in that case, the output represents the changes the merge - brought _into_ the then-current branch. - --r:: - Show recursive diffs. - --t:: - Show the tree objects in the diff output. This implies `-r`. -endif::git-rev-list[] -endif::git-shortlog[] From patchwork Wed Jul 29 20:11:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff King X-Patchwork-Id: 11691653 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1353813B1 for ; Wed, 29 Jul 2020 20:11:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0600220809 for ; Wed, 29 Jul 2020 20:11:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726804AbgG2UL3 (ORCPT ); Wed, 29 Jul 2020 16:11:29 -0400 Received: from cloud.peff.net ([104.130.231.41]:41510 "EHLO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726365AbgG2UL3 (ORCPT ); Wed, 29 Jul 2020 16:11:29 -0400 Received: (qmail 8838 invoked by uid 109); 29 Jul 2020 20:11:28 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Wed, 29 Jul 2020 20:11:28 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 7863 invoked by uid 111); 29 Jul 2020 20:11:28 -0000 Received: from coredump.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.2) by peff.net (qpsmtpd/0.94) with (TLS_AES_256_GCM_SHA384 encrypted) ESMTPS; Wed, 29 Jul 2020 16:11:28 -0400 Authentication-Results: peff.net; auth=none Date: Wed, 29 Jul 2020 16:11:27 -0400 From: Jeff King To: git@vger.kernel.org Cc: Junio C Hamano , Chris Torek Subject: [PATCH v2 5/7] doc/git-log: drop "-r" diff option Message-ID: <20200729201127.GE2989342@coredump.intra.peff.net> References: <20200729201002.GA2989059@coredump.intra.peff.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200729201002.GA2989059@coredump.intra.peff.net> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org This has been the default since 170c04383b (Porcelain level "log" family should recurse when diffing., 2007-08-27). There's not even a way to turn it off, so you'd never even want "-r" to override that. It's not the default for plumbing like diff-tree, of course, but the option is documented separately there. Signed-off-by: Jeff King --- Documentation/git-log.txt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Documentation/git-log.txt b/Documentation/git-log.txt index fb3998d8e0..2cbe636b2b 100644 --- a/Documentation/git-log.txt +++ b/Documentation/git-log.txt @@ -146,11 +146,8 @@ below can be used to show the changes made by each commit. in that case, the output represents the changes the merge brought _into_ the then-current branch. --r:: - Show recursive diffs. - -t:: - Show the tree objects in the diff output. This implies `-r`. + Show the tree objects in the diff output. :git-log: 1 include::diff-options.txt[] From patchwork Wed Jul 29 20:12:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff King X-Patchwork-Id: 11691657 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B73C113B1 for ; Wed, 29 Jul 2020 20:12:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A7001206D7 for ; Wed, 29 Jul 2020 20:12:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726644AbgG2UMM (ORCPT ); Wed, 29 Jul 2020 16:12:12 -0400 Received: from cloud.peff.net ([104.130.231.41]:41520 "EHLO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726365AbgG2UMM (ORCPT ); Wed, 29 Jul 2020 16:12:12 -0400 Received: (qmail 8853 invoked by uid 109); 29 Jul 2020 20:12:11 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Wed, 29 Jul 2020 20:12:11 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 7881 invoked by uid 111); 29 Jul 2020 20:12:11 -0000 Received: from coredump.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.2) by peff.net (qpsmtpd/0.94) with (TLS_AES_256_GCM_SHA384 encrypted) ESMTPS; Wed, 29 Jul 2020 16:12:11 -0400 Authentication-Results: peff.net; auth=none Date: Wed, 29 Jul 2020 16:12:10 -0400 From: Jeff King To: git@vger.kernel.org Cc: Junio C Hamano , Chris Torek Subject: [PATCH v2 6/7] doc/git-log: move "-t" into diff-options list Message-ID: <20200729201210.GF2989342@coredump.intra.peff.net> References: <20200729201002.GA2989059@coredump.intra.peff.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200729201002.GA2989059@coredump.intra.peff.net> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The "-t" option is infrequently used; it doesn't deserve a spot near the top of the options list. Let's push it down into the diff-options include, near the definition of --raw. We'll protect it with a git-log ifdef, since it doesn't make any sense for non-tree diff commands. Note that this means it also shows up in git-show, but that's a good thing; it applies equally well there. Signed-off-by: Jeff King --- I'm open to suggestions of a better spot to put it. The diff options list is a rather unwieldy mess. Documentation/diff-options.txt | 5 +++++ Documentation/git-log.txt | 3 --- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt index 7987d72b02..b7af973d9c 100644 --- a/Documentation/diff-options.txt +++ b/Documentation/diff-options.txt @@ -73,6 +73,11 @@ ifndef::git-format-patch[] Synonym for `-p --raw`. endif::git-format-patch[] +ifdef::git-log[] +-t:: + Show the tree objects in the diff output. +endif::git-log[] + --indent-heuristic:: Enable the heuristic that shifts diff hunk boundaries to make patches easier to read. This is the default. diff --git a/Documentation/git-log.txt b/Documentation/git-log.txt index 2cbe636b2b..0a4c99e5f8 100644 --- a/Documentation/git-log.txt +++ b/Documentation/git-log.txt @@ -146,9 +146,6 @@ below can be used to show the changes made by each commit. in that case, the output represents the changes the merge brought _into_ the then-current branch. --t:: - Show the tree objects in the diff output. - :git-log: 1 include::diff-options.txt[] From patchwork Wed Jul 29 20:12:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff King X-Patchwork-Id: 11691659 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 85B7E13B6 for ; Wed, 29 Jul 2020 20:12:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6E84320809 for ; Wed, 29 Jul 2020 20:12:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726711AbgG2UMV (ORCPT ); Wed, 29 Jul 2020 16:12:21 -0400 Received: from cloud.peff.net ([104.130.231.41]:41528 "EHLO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726664AbgG2UMV (ORCPT ); Wed, 29 Jul 2020 16:12:21 -0400 Received: (qmail 8869 invoked by uid 109); 29 Jul 2020 20:12:21 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Wed, 29 Jul 2020 20:12:21 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 7899 invoked by uid 111); 29 Jul 2020 20:12:20 -0000 Received: from coredump.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.2) by peff.net (qpsmtpd/0.94) with (TLS_AES_256_GCM_SHA384 encrypted) ESMTPS; Wed, 29 Jul 2020 16:12:20 -0400 Authentication-Results: peff.net; auth=none Date: Wed, 29 Jul 2020 16:12:20 -0400 From: Jeff King To: git@vger.kernel.org Cc: Junio C Hamano , Chris Torek Subject: [PATCH v2 7/7] doc/git-log: clarify handling of merge commit diffs Message-ID: <20200729201220.GG2989342@coredump.intra.peff.net> References: <20200729201002.GA2989059@coredump.intra.peff.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200729201002.GA2989059@coredump.intra.peff.net> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org It can be surprising that git-log doesn't show any diff for merge commits by default. Arguably "--cc" would be a reasonable default, but it's very expensive (which is why we turn it on for "git show" but not for "git log"). Let's at least document the current behavior, including the recent "--first-parent implies -m" case Signed-off-by: Jeff King --- Documentation/git-log.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Documentation/git-log.txt b/Documentation/git-log.txt index 0a4c99e5f8..9ccba65469 100644 --- a/Documentation/git-log.txt +++ b/Documentation/git-log.txt @@ -117,6 +117,13 @@ DIFF FORMATTING By default, `git log` does not generate any diff output. The options below can be used to show the changes made by each commit. +Note that unless one of `-c`, `--cc`, or `-m` is given, merge commits +will never show a diff, even if a diff format like `--patch` is +selected, nor will they match search options like `-S`. The exception is +when `--first-parent` is in use, in which merges are treated like normal +single-parent commits (this can be overridden by providing a +combined-diff option or with `--no-diff-merges`). + -c:: With this option, diff output for a merge commit shows the differences from each of the parents to the merge result