From eed5332a13ef15391039e5e953462201978058ec Mon Sep 17 00:00:00 2001 From: Jeff King Date: Wed, 29 Jul 2020 16:10:17 -0400 Subject: log: drop "--cc implies -m" logic 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 Signed-off-by: Junio C Hamano --- builtin/log.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'builtin/log.c') 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) -- cgit v1.2.3 From 6fae74b418da05a80897487805c833fd0b253df3 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Wed, 29 Jul 2020 16:10:20 -0400 Subject: revision: add "--no-diff-merges" option to counteract "-m" 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 Signed-off-by: Junio C Hamano --- builtin/log.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'builtin/log.c') 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" */ -- cgit v1.2.3 From 9ab89a2439064720cc790c4477b8e981832c43f5 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Wed, 29 Jul 2020 16:10:28 -0400 Subject: log: enable "-m" automatically with "--first-parent" 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 Signed-off-by: Junio C Hamano --- builtin/log.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'builtin/log.c') 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) -- cgit v1.2.3