@matheusbsbs / matheus-bagliano / commits / a7b9430940
Fork 0

log_tree_diff: get rid of code duplication for first_parent_only

Handle first_parent_only by breaking from generic loop early rather than by duplicating (part of) the loop body. Signed-off-by: Sergey Organov <sorganov@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Sergey Organov committed Aug 28, 2020 at 14:05 UTC a7b94309406c8f713a061ca8b930179483b12619
1 file changed +4 -15
log-tree.c
+4 -15
@@ -922,21 +922,10 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log
922 return 0;
923 else if (opt->combine_merges)
924 return do_diff_combined(opt, commit);
925 - else if (opt->first_parent_only) {
926 - /*
927 - * Generate merge log entry only for the first
928 - * parent, showing summary diff of the others
929 - * we merged _in_.
930 - */
931 - parse_commit_or_die(parents->item);
932 - diff_tree_oid(get_commit_tree_oid(parents->item),
933 - oid, "", &opt->diffopt);
934 - log_tree_diff_flush(opt);
935 - return !opt->loginfo;
925 + else if (!opt->first_parent_only) {
926 + /* If we show multiple diffs, show the parent info */
927 + log->parent = parents->item;
928 }
937 -
938 - /* If we show individual diffs, show the parent info */
939 - log->parent = parents->item;
929 }
930
931 showed_log = 0;
@@ -952,7 +941,7 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log
941
942 /* Set up the log info for the next parent, if any.. */
943 parents = parents->next;
955 - if (!parents)
944 + if (!parents || opt->first_parent_only)
945 break;
946 log->parent = parents->item;
947 opt->loginfo = log;