diff options
-rw-r--r-- | builtin/diff-files.c | 5 | ||||
-rw-r--r-- | builtin/diff.c | 9 | ||||
-rw-r--r-- | diff-merges.c | 16 | ||||
-rw-r--r-- | diff-merges.h | 2 |
4 files changed, 24 insertions, 8 deletions
diff --git a/builtin/diff-files.c b/builtin/diff-files.c index 1e352dd8f7..4742a4559b 100644 --- a/builtin/diff-files.c +++ b/builtin/diff-files.c @@ -7,6 +7,7 @@ #include "cache.h" #include "config.h" #include "diff.h" +#include "diff-merges.h" #include "commit.h" #include "revision.h" #include "builtin.h" @@ -69,9 +70,9 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix) * was not asked to. "diff-files -c -p" should not densify * (the user should ask with "diff-files --cc" explicitly). */ - if (rev.max_count == -1 && !rev.combine_merges && + if (rev.max_count == -1 && (rev.diffopt.output_format & DIFF_FORMAT_PATCH)) - rev.combine_merges = rev.dense_combined_merges = 1; + diff_merges_set_dense_combined_if_unset(&rev); if (read_cache_preload(&rev.diffopt.pathspec) < 0) { perror("read_cache_preload"); diff --git a/builtin/diff.c b/builtin/diff.c index cd4083fed9..2f570a3131 100644 --- a/builtin/diff.c +++ b/builtin/diff.c @@ -13,6 +13,7 @@ #include "blob.h" #include "tag.h" #include "diff.h" +#include "diff-merges.h" #include "diffcore.h" #include "revision.h" #include "log-tree.h" @@ -199,8 +200,8 @@ static int builtin_diff_combined(struct rev_info *revs, if (argc > 1) usage(builtin_diff_usage); - if (!revs->dense_combined_merges && !revs->combine_merges) - revs->dense_combined_merges = revs->combine_merges = 1; + diff_merges_set_dense_combined_if_unset(revs); + for (i = 1; i < ents; i++) oid_array_append(&parents, &ent[i].item->oid); diff_tree_combined(&ent[0].item->oid, &parents, revs); @@ -248,9 +249,9 @@ static int builtin_diff_files(struct rev_info *revs, int argc, const char **argv * dense one, --cc can be explicitly asked for, or just rely * on the default). */ - if (revs->max_count == -1 && !revs->combine_merges && + if (revs->max_count == -1 && (revs->diffopt.output_format & DIFF_FORMAT_PATCH)) - revs->combine_merges = revs->dense_combined_merges = 1; + diff_merges_set_dense_combined_if_unset(revs); setup_work_tree(); if (read_cache_preload(&revs->diffopt.pathspec) < 0) { diff --git a/diff-merges.c b/diff-merges.c index 23e6cb11d1..24f922cf8a 100644 --- a/diff-merges.c +++ b/diff-merges.c @@ -10,6 +10,13 @@ static void suppress(struct rev_info *revs) revs->dense_combined_merges = 0; } +static void set_dense_combined(struct rev_info *revs) +{ + revs->combine_merges = 1; + revs->dense_combined_merges = 1; +} + + /* * Public functions. They are in the order they are called. */ @@ -39,8 +46,7 @@ int diff_merges_parse_opts(struct rev_info *revs, const char **argv) revs->combine_merges = 1; } else if (!strcmp(arg, "--cc")) { revs->diff = 1; - revs->dense_combined_merges = 1; - revs->combine_merges = 1; + set_dense_combined(revs); } else if (!strcmp(arg, "--no-diff-merges")) { suppress(revs); } else if (!strcmp(arg, "--combined-all-paths")) { @@ -80,6 +86,12 @@ void diff_merges_default_to_dense_combined(struct rev_info *revs) } } +void diff_merges_set_dense_combined_if_unset(struct rev_info *revs) +{ + if (!revs->combine_merges) + set_dense_combined(revs); +} + void diff_merges_setup_revs(struct rev_info *revs) { if (revs->combine_merges && revs->ignore_merges < 0) diff --git a/diff-merges.h b/diff-merges.h index a031240576..f92de137d3 100644 --- a/diff-merges.h +++ b/diff-merges.h @@ -19,6 +19,8 @@ void diff_merges_default_to_first_parent(struct rev_info *revs); void diff_merges_default_to_dense_combined(struct rev_info *revs); +void diff_merges_set_dense_combined_if_unset(struct rev_info *revs); + void diff_merges_setup_revs(struct rev_info *revs); #endif |