From: Sergey Organov <sorganov@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Jeff King <peff@peff.net>,
git@vger.kernel.org, Sergey Organov <sorganov@gmail.com>
Subject: [PATCH v4] revision: add separate field for "-m" of "diff-index -m"
Date: Mon, 31 Aug 2020 23:14:22 +0300 [thread overview]
Message-ID: <20200831201422.27189-1-sorganov@gmail.com> (raw)
In-Reply-To: <20200829194634.23306-1-sorganov@gmail.com>
Add separate 'match_missing' field for diff-index to use and set it when we
encounter "-m" option. This field won't then be cleared when another meaning of
"-m" is reverted (e.g., by "--no-diff-merges"), nor it will be affected by
future option(s) that might drive 'ignore_merges' field.
Use this new field from diff-lib:do_oneway_diff() instead of reusing
'ignore_merges' field.
Signed-off-by: Sergey Organov <sorganov@gmail.com>
---
v4: fix new field name to be 'match_missing', and improve comment in the code to
treat both involved bits similarily
v3: improve commit message
v2: rebased from 'maint' onto 'master'
diff-lib.c | 10 ++--------
revision.c | 6 ++++++
revision.h | 1 +
3 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/diff-lib.c b/diff-lib.c
index 50521e2093fc..5d5d3dafab33 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -405,14 +405,8 @@ static void do_oneway_diff(struct unpack_trees_options *o,
/* if the entry is not checked out, don't examine work tree */
cached = o->index_only ||
(idx && ((idx->ce_flags & CE_VALID) || ce_skip_worktree(idx)));
- /*
- * Backward compatibility wart - "diff-index -m" does
- * not mean "do not ignore merges", but "match_missing".
- *
- * But with the revision flag parsing, that's found in
- * "!revs->ignore_merges".
- */
- match_missing = !revs->ignore_merges;
+
+ match_missing = revs->match_missing;
if (cached && idx && ce_stage(idx)) {
struct diff_filepair *pair;
diff --git a/revision.c b/revision.c
index 96630e31867d..73e3d14cc165 100644
--- a/revision.c
+++ b/revision.c
@@ -2344,7 +2344,13 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
revs->diffopt.flags.recursive = 1;
revs->diffopt.flags.tree_in_recursive = 1;
} else if (!strcmp(arg, "-m")) {
+ /*
+ * To "diff-index", "-m" means "match missing", and to the "log"
+ * family of commands, it means "show full diff for merges". Set
+ * both fields appropriately.
+ */
revs->ignore_merges = 0;
+ revs->match_missing = 1;
} else if ((argcount = parse_long_opt("diff-merges", argv, &optarg))) {
if (!strcmp(optarg, "off")) {
revs->ignore_merges = 1;
diff --git a/revision.h b/revision.h
index c1e5bcf139d7..f6bf860d19e5 100644
--- a/revision.h
+++ b/revision.h
@@ -188,6 +188,7 @@ struct rev_info {
unsigned int diff:1,
full_diff:1,
show_root_diff:1,
+ match_missing:1,
no_commit_id:1,
verbose_header:1,
combine_merges:1,
--
2.25.1
next prev parent reply other threads:[~2020-08-31 20:14 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-29 19:46 [PATCH] revision: add separate field for "-m" of "diff-index -m" Sergey Organov
2020-08-29 20:11 ` [PATCH v2] " Sergey Organov
2020-08-31 4:49 ` Junio C Hamano
2020-08-31 12:45 ` Sergey Organov
2020-08-31 17:00 ` Junio C Hamano
2020-08-31 12:53 ` [PATCH v3] " Sergey Organov
2020-08-31 17:23 ` Junio C Hamano
2020-08-31 19:41 ` Sergey Organov
2020-08-31 20:14 ` Sergey Organov [this message]
2020-08-31 20:42 ` [PATCH v4] " Junio C Hamano
2020-08-31 21:01 ` Sergey Organov
2020-10-23 4:03 ` [PATCH] revision: wording tweak in comment for parsing "-m" Junio C Hamano
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=20200831201422.27189-1-sorganov@gmail.com \
--to=sorganov@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
/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).