Browse Source

diff-merges: new function diff_merges_suppress()

This function sets all the relevant flags to disabled state, so that
no code that checks only one of them get it wrong.

Then we call this new function everywhere where diff merges output
suppression is needed.

Signed-off-by: Sergey Organov <sorganov@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Sergey Organov 4 years ago committed by Junio C Hamano
parent
commit
09322b1da9
  1. 3
      builtin/merge.c
  2. 17
      diff-merges.c
  3. 2
      diff-merges.h
  4. 3
      fmt-merge-msg.c

3
builtin/merge.c

@ -14,6 +14,7 @@ @@ -14,6 +14,7 @@
#include "lockfile.h"
#include "run-command.h"
#include "diff.h"
#include "diff-merges.h"
#include "refs.h"
#include "refspec.h"
#include "commit.h"
@ -400,7 +401,7 @@ static void squash_message(struct commit *commit, struct commit_list *remotehead @@ -400,7 +401,7 @@ static void squash_message(struct commit *commit, struct commit_list *remotehead
printf(_("Squash commit -- not updating HEAD\n"));

repo_init_revisions(the_repository, &rev, NULL);
rev.ignore_merges = 1;
diff_merges_suppress(&rev);
rev.commit_format = CMIT_FMT_MEDIUM;

commit->object.flags |= UNINTERESTING;

17
diff-merges.c

@ -2,6 +2,14 @@ @@ -2,6 +2,14 @@

#include "revision.h"

static void suppress(struct rev_info *revs)
{
revs->ignore_merges = 1;
revs->first_parent_merges = 0;
revs->combine_merges = 0;
revs->dense_combined_merges = 0;
}

/*
* Public functions. They are in the order they are called.
*/
@ -34,13 +42,13 @@ int diff_merges_parse_opts(struct rev_info *revs, const char **argv) @@ -34,13 +42,13 @@ int diff_merges_parse_opts(struct rev_info *revs, const char **argv)
revs->dense_combined_merges = 1;
revs->combine_merges = 1;
} else if (!strcmp(arg, "--no-diff-merges")) {
revs->ignore_merges = 1;
suppress(revs);
} else if (!strcmp(arg, "--combined-all-paths")) {
revs->diff = 1;
revs->combined_all_paths = 1;
} else if ((argcount = parse_long_opt("diff-merges", argv, &optarg))) {
if (!strcmp(optarg, "off")) {
revs->ignore_merges = 1;
suppress(revs);
} else {
die(_("unknown value for --diff-merges: %s"), optarg);
}
@ -50,6 +58,11 @@ int diff_merges_parse_opts(struct rev_info *revs, const char **argv) @@ -50,6 +58,11 @@ int diff_merges_parse_opts(struct rev_info *revs, const char **argv)
return argcount;
}

void diff_merges_suppress(struct rev_info *revs)
{
suppress(revs);
}

void diff_merges_default_to_first_parent(struct rev_info *revs)
{
if (revs->ignore_merges < 0) /* No -m */

2
diff-merges.h

@ -13,6 +13,8 @@ void diff_merges_init_revs(struct rev_info *revs); @@ -13,6 +13,8 @@ void diff_merges_init_revs(struct rev_info *revs);

int diff_merges_parse_opts(struct rev_info *revs, const char **argv);

void diff_merges_suppress(struct rev_info *revs);

void diff_merges_default_to_first_parent(struct rev_info *revs);

void diff_merges_default_to_dense_combined(struct rev_info *revs);

3
fmt-merge-msg.c

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
#include "refs.h"
#include "object-store.h"
#include "diff.h"
#include "diff-merges.h"
#include "revision.h"
#include "tag.h"
#include "string-list.h"
@ -668,7 +669,7 @@ int fmt_merge_msg(struct strbuf *in, struct strbuf *out, @@ -668,7 +669,7 @@ int fmt_merge_msg(struct strbuf *in, struct strbuf *out,
head = lookup_commit_or_die(&head_oid, "HEAD");
repo_init_revisions(the_repository, &rev, NULL);
rev.commit_format = CMIT_FMT_ONELINE;
rev.ignore_merges = 1;
diff_merges_suppress(&rev);
rev.limited = 1;

strbuf_complete_line(out);

Loading…
Cancel
Save