From: Sergey Organov <sorganov@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: "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>,
"Glen Choo" <chooglen@google.com>,
git@vger.kernel.org, "Sergey Organov" <sorganov@gmail.com>
Subject: [PATCH v1 2/5] diff-merges: implement log.diffMerges-m-imply-p config
Date: Sat, 17 Dec 2022 16:29:52 +0300 [thread overview]
Message-ID: <20221217132955.108542-3-sorganov@gmail.com> (raw)
In-Reply-To: <20221217132955.108542-1-sorganov@gmail.com>
Historically, `-m` doesn't imply `-p` whereas similar `-c` and `--cc`
options do. Simply fixing this inconsistency by unconditional
modification of `-m` semantics appeared to be a bad idea, as it broke
some legacy scripts.
Implement "log.diffMerges-m-imply-p" boolean configuration variable
that allows user to enable implication of `-p` by `-m`.
Signed-off-by: Sergey Organov <sorganov@gmail.com>
---
Documentation/config/log.txt | 3 +++
Documentation/diff-options.txt | 6 ++++--
builtin/log.c | 2 ++
diff-merges.c | 8 ++++++++
diff-merges.h | 2 ++
t/t4013-diff-various.sh | 9 +++++++++
t/t9902-completion.sh | 3 +++
7 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/Documentation/config/log.txt b/Documentation/config/log.txt
index 9c6be643bcf6..265a57312e58 100644
--- a/Documentation/config/log.txt
+++ b/Documentation/config/log.txt
@@ -40,6 +40,9 @@ diffs for merge commits when `-p` option is not used.
log.diffMergesHide::
`true` implies `--diff-merges=hide` option.
+log.diffMerges-m-imply-p::
+ `true` enables implication of `-p` by `-m`.
+
log.follow::
If `true`, `git log` will act as if the `--follow` option was used when
a single <path> is given. This has the same limitations as `--follow`,
diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
index b062bdab04d9..fe15693492a2 100644
--- a/Documentation/diff-options.txt
+++ b/Documentation/diff-options.txt
@@ -48,12 +48,14 @@ ifdef::git-log[]
--diff-merges=on:::
--diff-merges=m:::
-m:::
- This option makes diff output for merge commits to be shown in
+ These options make diff output for merge commits to be shown in
the default format. The default format could be changed using
`log.diffMerges` configuration parameter, which default value
is `separate`.
+
- `-m` is a shortcut for '--diff-merges=on --diff-merges=hide'
+ `-m` is a shortcut for '--diff-merges=on --diff-merges=hide'.
+ In addition it implies `-p` when `log.diffMerges-m-imply-p` is
+ active.
+
--diff-merges=first-parent:::
--diff-merges=1:::
diff --git a/builtin/log.c b/builtin/log.c
index e031021e53b2..332b5e478cc5 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -583,6 +583,8 @@ static int git_log_config(const char *var, const char *value, void *cb)
return diff_merges_config(value);
if (!strcmp(var, "log.diffmergeshide"))
return diff_merges_hide_config(git_config_bool(var, value));
+ if (!strcmp(var, "log.diffmerges-m-imply-p"))
+ return diff_merges_m_imply_p_config(git_config_bool(var, value));
if (!strcmp(var, "log.showroot")) {
default_show_root = git_config_bool(var, value);
return 0;
diff --git a/diff-merges.c b/diff-merges.c
index 55fe5b70c102..1fbf476d378e 100644
--- a/diff-merges.c
+++ b/diff-merges.c
@@ -8,6 +8,7 @@ static void set_separate(struct rev_info *revs);
static diff_merges_setup_func_t set_to_default = set_separate;
static int suppress_m_parsing;
static int hide = 0;
+static int m_imply_p = 0;
static void suppress(struct rev_info *revs)
{
@@ -143,6 +144,12 @@ int diff_merges_hide_config(int on)
return 0;
}
+int diff_merges_m_imply_p_config(int on)
+{
+ m_imply_p = on;
+ return 0;
+}
+
void diff_merges_suppress_m_parsing(void)
{
suppress_m_parsing = 1;
@@ -157,6 +164,7 @@ int diff_merges_parse_opts(struct rev_info *revs, const char **argv)
if (!suppress_m_parsing && !strcmp(arg, "-m")) {
set_to_default(revs);
set_hide(revs);
+ revs->merges_imply_patch = m_imply_p;
} else if (!strcmp(arg, "-c")) {
set_combined(revs);
revs->merges_imply_patch = 1;
diff --git a/diff-merges.h b/diff-merges.h
index e86e5381693b..9f0b3901fe82 100644
--- a/diff-merges.h
+++ b/diff-merges.h
@@ -13,6 +13,8 @@ int diff_merges_config(const char *value);
int diff_merges_hide_config(int hide);
+int diff_merges_m_imply_p_config(int on);
+
void diff_merges_suppress_m_parsing(void);
int diff_merges_parse_opts(struct rev_info *revs, const char **argv);
diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh
index 4fc8ba2fc59c..1789dd6063c5 100755
--- a/t/t4013-diff-various.sh
+++ b/t/t4013-diff-various.sh
@@ -548,6 +548,15 @@ test_expect_success 'git config log.diffMerges hide: has no effect on --cc' '
test_cmp expected actual
'
+test_expect_success 'git config log.diffMerges-m-imply-p has proper effect' '
+ git log -m -p master >result &&
+ process_diffs result >expected &&
+ test_config log.diffMerges-m-imply-p true &&
+ git log -m master >result &&
+ process_diffs result >actual &&
+ test_cmp expected actual
+'
+
# -m in "git diff-index" means "match missing", that differs
# from its meaning in "git diff". Let's check it in diff-index.
# The line in the output for removed file should disappear when
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index fc6b0722216a..26a7e4ff877c 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -2498,6 +2498,7 @@ test_expect_success 'git config - variable name' '
log.decorate Z
log.diffMerges Z
log.diffMergesHide Z
+ log.diffMerges-m-imply-p Z
EOF
'
@@ -2527,6 +2528,7 @@ test_expect_success 'git -c - variable name' '
log.decorate=Z
log.diffMerges=Z
log.diffMergesHide=Z
+ log.diffMerges-m-imply-p=Z
EOF
'
@@ -2550,6 +2552,7 @@ test_expect_success 'git clone --config= - variable name' '
log.decorate=Z
log.diffMerges=Z
log.diffMergesHide=Z
+ log.diffMerges-m-imply-p=Z
EOF
'
--
2.25.1
next prev parent reply other threads:[~2022-12-17 13:30 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
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 ` Sergey Organov [this message]
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
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=20221217132955.108542-3-sorganov@gmail.com \
--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.
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).