Merge branch 'so/log-diff-merge'

"git log" learned a new "--diff-merges=<how>" option.

* so/log-diff-merge: (32 commits)
  t4013: add tests for --diff-merges=first-parent
  doc/git-show: include --diff-merges description
  doc/rev-list-options: document --first-parent changes merges format
  doc/diff-generate-patch: mention new --diff-merges option
  doc/git-log: describe new --diff-merges options
  diff-merges: add '--diff-merges=1' as synonym for 'first-parent'
  diff-merges: add old mnemonic counterparts to --diff-merges
  diff-merges: let new options enable diff without -p
  diff-merges: do not imply -p for new options
  diff-merges: implement new values for --diff-merges
  diff-merges: make -m/-c/--cc explicitly mutually exclusive
  diff-merges: refactor opt settings into separate functions
  diff-merges: get rid of now empty diff_merges_init_revs()
  diff-merges: group diff-merge flags next to each other inside 'rev_info'
  diff-merges: split 'ignore_merges' field
  diff-merges: fix -m to properly override -c/--cc
  t4013: add tests for -m failing to override -c/--cc
  t4013: support test_expect_failure through ':failure' magic
  diff-merges: revise revs->diff flag handling
  diff-merges: handle imply -p on -c/--cc logic for log.c
  ...
This commit is contained in:
Junio C Hamano
2021-02-05 16:40:44 -08:00
21 changed files with 893 additions and 116 deletions

View File

@ -899,15 +899,21 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log
int showed_log;
struct commit_list *parents;
struct object_id *oid;
int is_merge;
int all_need_diff = opt->diff || opt->diffopt.flags.exit_with_status;
if (!opt->diff && !opt->diffopt.flags.exit_with_status)
if (!all_need_diff && !opt->merges_need_diff)
return 0;
parse_commit_or_die(commit);
oid = get_commit_tree_oid(commit);
/* Root commit? */
parents = get_saved_parents(opt, commit);
is_merge = parents && parents->next;
if (!is_merge && !all_need_diff)
return 0;
/* Root commit? */
if (!parents) {
if (opt->show_root_diff) {
diff_root_tree_oid(oid, "", &opt->diffopt);
@ -916,16 +922,16 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log
return !opt->loginfo;
}
/* More than one parent? */
if (parents->next) {
if (opt->ignore_merges)
return 0;
else if (opt->combine_merges)
if (is_merge) {
if (opt->combine_merges)
return do_diff_combined(opt, commit);
else if (!opt->first_parent_only) {
/* If we show multiple diffs, show the parent info */
log->parent = parents->item;
}
if (opt->separate_merges) {
if (!opt->first_parent_merges) {
/* Show parent info for multiple diffs */
log->parent = parents->item;
}
} else
return 0;
}
showed_log = 0;
@ -941,7 +947,7 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log
/* Set up the log info for the next parent, if any.. */
parents = parents->next;
if (!parents || opt->first_parent_only)
if (!parents || opt->first_parent_merges)
break;
log->parent = parents->item;
opt->loginfo = log;