Elijah Newren <newren@xxxxxxxxx> writes: > On Fri, Dec 18, 2020 at 6:42 AM Sergey Organov <sorganov@xxxxxxxxx> wrote: >> >> Elijah Newren <newren@xxxxxxxxx> writes: >> >> > On Wed, Dec 16, 2020 at 10:50 AM Sergey Organov <sorganov@xxxxxxxxx> wrote: >> >> >> >> New options don't have any visible effect unless -p is either given or >> >> implied, as unlike -c/-cc we don't imply -p with --diff-merges. To fix >> >> this, this patch adds new functionality by letting new options enable >> >> output of diffs for merge commits only. >> >> >> >> Add 'merges_need_diff' field and set it whenever diff output for merges is >> >> enabled by any of the new options. >> >> >> >> Extend diff output logic accordingly, to output diffs for merges when >> >> 'merges_need_diff' is set even when no -p has been provided. >> >> >> >> Signed-off-by: Sergey Organov <sorganov@xxxxxxxxx> >> >> --- >> >> diff-merges.c | 16 ++++++++++------ >> >> log-tree.c | 13 +++++++++---- >> >> revision.h | 1 + >> >> 3 files changed, 20 insertions(+), 10 deletions(-) [...] >> >> diff --git a/log-tree.c b/log-tree.c >> >> index f9385b1dae6f..67060492ca0a 100644 >> >> --- a/log-tree.c >> >> +++ b/log-tree.c >> >> @@ -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 regulars_need_diff = opt->diff || opt->diffopt.flags.exit_with_status; >> > >> > So rev_info.diff has changed in meaning from >> > commits-need-to-show-a-diff, to non-merge-commits-need-to-show-a-diff. >> > That's a somewhat subtle semantic shift. Perhaps it's worth adding a >> > comment to the declaration of rev_info.diff to highlight this? (And >> > perhaps even rename the flag?) >> >> No, the meaning of rev_info.diff hopefully didn't change. rev_info.diff >> still enables all the commits to pass further once set. It is still >> exactly the same old condition, just assigned to a variable for reuse. >> My aim was to avoid touching existing logic of this function and only >> add a new functionality when opt->merges_need_diff is set. >> >> It looks like I rather choose confusing name for the variable, and it'd >> be more clear if I'd call this, say: >> >> int need_diff = opt->diff || opt->diffopt.flags.exit_with_status; >> >> ? >> >> What do you think? > > I think need_diff would actually be confusing. It can be false when > you need diffs (e.g. --diff-merges=cc with no -p, because then you'd > need diffs for merge commits and not for non-merge commits). I'd > stick with your original local variable name. The problem is that original name I've used lies to the reader, or, more precisely, tells half-truth. True meaning of the variable is "do run diff for any commit, no matter if it's merge or not". So "need_diff" is already better than "regulars_need_diff". Maybe "diff_all_commits" will do? Thanks, -- Sergey