@matheusbsbs / matheus-bagliano / commits / 572fc9aa54
Fork 0

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 <sorganov@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Sergey Organov committed Aug 31, 2020 at 23:14 UTC 572fc9aa5471ce7a9888f03a32d556350f88a5cf
3 files changed +9 -8
diff-lib.c
+2 -8
@@ -405,14 +405,8 @@ static void do_oneway_diff(struct unpack_trees_options *o,
405 /* if the entry is not checked out, don't examine work tree */
406 cached = o->index_only ||
407 (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;
410
411 if (cached && idx && ce_stage(idx)) {
412 struct diff_filepair *pair;
revision.c
+6
@@ -2344,7 +2344,13 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
2344 revs->diffopt.flags.recursive = 1;
2345 revs->diffopt.flags.tree_in_recursive = 1;
2346 } 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 + */
2352 revs->ignore_merges = 0;
2353 + revs->match_missing = 1;
2354 } else if ((argcount = parse_long_opt("diff-merges", argv, &optarg))) {
2355 if (!strcmp(optarg, "off")) {
2356 revs->ignore_merges = 1;
revision.h
+1
@@ -188,6 +188,7 @@ struct rev_info {
188 unsigned int diff:1,
189 full_diff:1,
190 show_root_diff:1,
191 + match_missing:1,
192 no_commit_id:1,
193 verbose_header:1,
194 combine_merges:1,