Skip to content

Commit 572fc9a

Browse files
sorganovgitster
authored andcommitted
revision: add separate field for "-m" of "diff-index -m"
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d9cd433 commit 572fc9a

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

diff-lib.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -405,14 +405,8 @@ static void do_oneway_diff(struct unpack_trees_options *o,
405405
/* if the entry is not checked out, don't examine work tree */
406406
cached = o->index_only ||
407407
(idx && ((idx->ce_flags & CE_VALID) || ce_skip_worktree(idx)));
408-
/*
409-
* Backward compatibility wart - "diff-index -m" does
410-
* not mean "do not ignore merges", but "match_missing".
411-
*
412-
* But with the revision flag parsing, that's found in
413-
* "!revs->ignore_merges".
414-
*/
415-
match_missing = !revs->ignore_merges;
408+
409+
match_missing = revs->match_missing;
416410

417411
if (cached && idx && ce_stage(idx)) {
418412
struct diff_filepair *pair;

revision.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2344,7 +2344,13 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
23442344
revs->diffopt.flags.recursive = 1;
23452345
revs->diffopt.flags.tree_in_recursive = 1;
23462346
} else if (!strcmp(arg, "-m")) {
2347+
/*
2348+
* To "diff-index", "-m" means "match missing", and to the "log"
2349+
* family of commands, it means "show full diff for merges". Set
2350+
* both fields appropriately.
2351+
*/
23472352
revs->ignore_merges = 0;
2353+
revs->match_missing = 1;
23482354
} else if ((argcount = parse_long_opt("diff-merges", argv, &optarg))) {
23492355
if (!strcmp(optarg, "off")) {
23502356
revs->ignore_merges = 1;

revision.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ struct rev_info {
188188
unsigned int diff:1,
189189
full_diff:1,
190190
show_root_diff:1,
191+
match_missing:1,
191192
no_commit_id:1,
192193
verbose_header:1,
193194
combine_merges:1,

0 commit comments

Comments
 (0)