1 #include "diff-merges.h"
5 static void suppress(struct rev_info *revs)
7 revs->separate_merges = 0;
8 revs->first_parent_merges = 0;
9 revs->combine_merges = 0;
10 revs->dense_combined_merges = 0;
13 static void set_dense_combined(struct rev_info *revs)
15 revs->combine_merges = 1;
16 revs->dense_combined_merges = 1;
21 * Public functions. They are in the order they are called.
24 void diff_merges_init_revs(struct rev_info *revs)
28 int diff_merges_parse_opts(struct rev_info *revs, const char **argv)
32 const char *arg = argv[0];
34 if (!strcmp(arg, "-m")) {
37 * To "diff-index", "-m" means "match missing", and to the "log"
38 * family of commands, it means "show full diff for merges". Set
39 * both fields appropriately.
41 revs->separate_merges = 1;
42 revs->match_missing = 1;
43 } else if (!strcmp(arg, "-c")) {
44 revs->dense_combined_merges = 0;
45 revs->combine_merges = 1;
46 } else if (!strcmp(arg, "--cc")) {
47 set_dense_combined(revs);
48 } else if (!strcmp(arg, "--no-diff-merges")) {
50 } else if (!strcmp(arg, "--combined-all-paths")) {
51 revs->combined_all_paths = 1;
52 } else if ((argcount = parse_long_opt("diff-merges", argv, &optarg))) {
53 if (!strcmp(optarg, "off")) {
56 die(_("unknown value for --diff-merges: %s"), optarg);
61 revs->explicit_diff_merges = 1;
65 void diff_merges_suppress(struct rev_info *revs)
70 void diff_merges_default_to_first_parent(struct rev_info *revs)
72 if (!revs->explicit_diff_merges)
73 revs->separate_merges = 1;
74 if (revs->separate_merges)
75 revs->first_parent_merges = 1;
78 void diff_merges_default_to_dense_combined(struct rev_info *revs)
80 if (!revs->explicit_diff_merges)
81 set_dense_combined(revs);
84 void diff_merges_set_dense_combined_if_unset(struct rev_info *revs)
86 if (!revs->combine_merges)
87 set_dense_combined(revs);
90 void diff_merges_setup_revs(struct rev_info *revs)
92 if (revs->combine_merges == 0)
93 revs->dense_combined_merges = 0;
94 if (revs->separate_merges == 0)
95 revs->first_parent_merges = 0;
96 if (revs->combined_all_paths && !revs->combine_merges)
97 die("--combined-all-paths makes no sense without -c or --cc");
98 if (revs->combine_merges) {
100 /* Turn --cc/-c into -p --cc/-c when -p was not given */
101 if (!revs->diffopt.output_format)
102 revs->diffopt.output_format = DIFF_FORMAT_PATCH;