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 3/5] diff-merges: support list of values for --diff-merges
Date: Sat, 17 Dec 2022 16:29:53 +0300 [thread overview]
Message-ID: <20221217132955.108542-4-sorganov@gmail.com> (raw)
In-Reply-To: <20221217132955.108542-1-sorganov@gmail.com>
Support comma-separated list of options in --diff-merges=. This allows
for shorter:
--diff-merges=on,hide
instead of:
--diff-merges=on --diff-merges=hide
Signed-off-by: Sergey Organov <sorganov@gmail.com>
---
Documentation/diff-options.txt | 5 +++--
diff-merges.c | 22 ++++++++++++++++++----
t/t4013-diff-various.sh | 8 ++++++++
3 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
index fe15693492a2..977f9135b0d6 100644
--- a/Documentation/diff-options.txt
+++ b/Documentation/diff-options.txt
@@ -38,7 +38,8 @@ ifdef::git-log[]
--no-diff-merges::
Specify diff format to be used for merge commits. Default is
{diff-merges-default} unless `--first-parent` is in use, in which case
- `first-parent` is the default.
+ `first-parent` is the default. Comma-separated list of
+ supported values is accepted as well.
+
--diff-merges=(off|none):::
--no-diff-merges:::
@@ -53,7 +54,7 @@ ifdef::git-log[]
`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,hide'.
In addition it implies `-p` when `log.diffMerges-m-imply-p` is
active.
+
diff --git a/diff-merges.c b/diff-merges.c
index 1fbf476d378e..bb2797ff8cc5 100644
--- a/diff-merges.c
+++ b/diff-merges.c
@@ -1,6 +1,7 @@
#include "diff-merges.h"
#include "revision.h"
+#include "strbuf.h"
typedef void (*diff_merges_setup_func_t)(struct rev_info *);
static void set_separate(struct rev_info *revs);
@@ -109,12 +110,25 @@ static diff_merges_setup_func_t func_by_opt(const char *optarg)
static void set_diff_merges(struct rev_info *revs, const char *optarg)
{
- diff_merges_setup_func_t func = func_by_opt(optarg);
+ char const delim = ',';
+ struct strbuf **opts = strbuf_split_str(optarg, delim, -1);
+ struct strbuf **p;
- if (!func)
- die(_("invalid value for '%s': '%s'"), "--diff-merges", optarg);
+ for (p = opts; *p; p++) {
+ diff_merges_setup_func_t func;
+ char *opt = (*p)->buf;
+ int len = (*p)->len;
- func(revs);
+ if (opt[len - 1] == delim)
+ opt[len - 1] = '\0';
+ func = func_by_opt(opt);
+ if (!func) {
+ strbuf_list_free(opts);
+ die(_("invalid value for '%s': '%s'"), "--diff-merges", opt);
+ }
+ func(revs);
+ }
+ strbuf_list_free(opts);
}
/*
diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh
index 1789dd6063c5..a07513e67fd6 100755
--- a/t/t4013-diff-various.sh
+++ b/t/t4013-diff-various.sh
@@ -485,6 +485,14 @@ test_expect_success 'log --diff-merges=on matches --diff-merges=separate' '
test_cmp expected actual
'
+test_expect_success 'log --diff-merges=<V1>,<V2>' '
+ git log --diff-merges=1,hide master >result &&
+ process_diffs result >expected &&
+ git log --diff-merges=1 --diff-merges=hide master >result &&
+ process_diffs result >actual &&
+ test_cmp expected actual
+'
+
test_expect_success 'deny wrong log.diffMerges config' '
test_config log.diffMerges wrong-value &&
test_expect_code 128 git log
--
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 ` [PATCH v1 2/5] diff-merges: implement log.diffMerges-m-imply-p config Sergey Organov
2022-12-17 13:29 ` Sergey Organov [this message]
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-4-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).