Skip to content

Commit a7b9430

Browse files
sorganovgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3a238e5 commit a7b9430

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

log-tree.c

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -922,21 +922,10 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log
922922
return 0;
923923
else if (opt->combine_merges)
924924
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;
936928
}
937-
938-
/* If we show individual diffs, show the parent info */
939-
log->parent = parents->item;
940929
}
941930

942931
showed_log = 0;
@@ -952,7 +941,7 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log
952941

953942
/* Set up the log info for the next parent, if any.. */
954943
parents = parents->next;
955-
if (!parents)
944+
if (!parents || opt->first_parent_only)
956945
break;
957946
log->parent = parents->item;
958947
opt->loginfo = log;

0 commit comments

Comments
 (0)