diff options
author | Sergey Organov <sorganov@gmail.com> | 2020-12-21 18:19:32 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-12-22 00:47:30 +0300 |
commit | 3d4fd9436337d1688e7e2c2b2da4f7b7e3e8591e (patch) | |
tree | 77e732ff66e52a74abf2cc59b0cd90ba9ccccc46 | |
parent | 027c4783d73bbaff0a3c494b886cd8fa20ba8372 (diff) |
revision: provide implementation for diff merges tweaks
Use these implementations from show_setup_revisions_tweak() and
log_setup_revisions_tweak() in builtin/log.c.
This completes moving of management of diff merges parameters to a
single place, where we can finally observe them simultaneously.
Signed-off-by: Sergey Organov <sorganov@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | builtin/log.c | 13 | ||||
-rw-r--r-- | revision.c | 19 | ||||
-rw-r--r-- | revision.h | 3 |
3 files changed, 24 insertions, 11 deletions
diff --git a/builtin/log.c b/builtin/log.c index 0a7ed4bef9..717855a49e 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -598,15 +598,7 @@ static int show_tree_object(const struct object_id *oid, static void show_setup_revisions_tweak(struct rev_info *rev, struct setup_revision_opt *opt) { - if (rev->ignore_merges < 0) { - /* There was no "-m" variant on the command line */ - rev->ignore_merges = 0; - if (!rev->first_parent_only && !rev->combine_merges) { - /* No "--first-parent", "-c", or "--cc" */ - rev->combine_merges = 1; - rev->dense_combined_merges = 1; - } - } + rev_diff_merges_default_to_dense_combined(rev); if (!rev->diffopt.output_format) rev->diffopt.output_format = DIFF_FORMAT_PATCH; } @@ -731,8 +723,7 @@ static void log_setup_revisions_tweak(struct rev_info *rev, if (!rev->diffopt.output_format && rev->combine_merges) rev->diffopt.output_format = DIFF_FORMAT_PATCH; - if (rev->first_parent_only && rev->ignore_merges < 0) - rev->ignore_merges = 0; + rev_diff_merges_first_parent_defaults_to_enable(rev); } int cmd_log(int argc, const char **argv, const char *prefix) diff --git a/revision.c b/revision.c index 3250b2d7e1..1c224d2764 100644 --- a/revision.c +++ b/revision.c @@ -2209,6 +2209,25 @@ static void setup_diff_merges_revs(struct rev_info *revs) die("--combined-all-paths makes no sense without -c or --cc"); } +void rev_diff_merges_first_parent_defaults_to_enable(struct rev_info *revs) +{ + if (revs->first_parent_only && revs->ignore_merges < 0) + revs->ignore_merges = 0; +} + +void rev_diff_merges_default_to_dense_combined(struct rev_info *revs) +{ + if (revs->ignore_merges < 0) { + /* There was no "-m" variant on the command line */ + revs->ignore_merges = 0; + if (!revs->first_parent_only && !revs->combine_merges) { + /* No "--first-parent", "-c", or "--cc" */ + revs->combine_merges = 1; + revs->dense_combined_merges = 1; + } + } +} + static int handle_revision_opt(struct rev_info *revs, int argc, const char **argv, int *unkc, const char **unkv, const struct setup_revision_opt* opt) diff --git a/revision.h b/revision.h index f6bf860d19..3dd0229f4e 100644 --- a/revision.h +++ b/revision.h @@ -456,4 +456,7 @@ int rewrite_parents(struct rev_info *revs, */ struct commit_list *get_saved_parents(struct rev_info *revs, const struct commit *commit); +void rev_diff_merges_default_to_dense_combined(struct rev_info *revs); +void rev_diff_merges_first_parent_defaults_to_enable(struct rev_info *revs); + #endif |