Changes default behaviour of `git log` and `git show` when no command-line options are given. Doesn't affect behaviour otherwise (same behaviour as with stash.showStat). --- I've wanted to have `show` and `log` show --stat by default, and I couldn't find any better solution for it. And I've discovered that there is stash.showStat, which is exactly what I want. So I wanted to bring stash.showStat to `show` and `log`. So far, setting log.showStat affects behaviour as described in the commit message. But it does so for `show` and `log` at the same time. I think they should be configurable separately. (log.showStat and show.showStat) Before I do all the work, please tell me if this is the right approach so far, and if the feature - when ready - would be accepted. (I'm aware that documentation and tests are missing.) builtin/log.c | 22 ++++++++++++++++++---- revision.h | 1 + 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/builtin/log.c b/builtin/log.c index 0a7ed4bef9..225252f0b4 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -45,6 +45,7 @@ static int default_abbrev_commit; static int default_show_root = 1; static int default_follow; static int default_show_signature; +static int default_show_stat; static int default_encode_email_headers = 1; static int decoration_style; static int decoration_given; @@ -151,6 +152,7 @@ static void cmd_log_init_defaults(struct rev_info *rev) rev->show_root_diff = default_show_root; rev->subject_prefix = fmt_patch_subject_prefix; rev->show_signature = default_show_signature; + rev->show_stat = default_show_stat; rev->encode_email_headers = default_encode_email_headers; rev->diffopt.flags.allow_textconv = 1; @@ -488,6 +490,10 @@ static int git_log_config(const char *var, const char *value, void *cb) default_show_signature = git_config_bool(var, value); return 0; } + if (!strcmp(var, "log.showstat")) { + default_show_stat = git_config_bool(var, value); + return 0; + } if (grep_config(var, value, cb) < 0) return -1; @@ -607,8 +613,11 @@ static void show_setup_revisions_tweak(struct rev_info *rev, rev->dense_combined_merges = 1; } } - if (!rev->diffopt.output_format) + if (!rev->diffopt.output_format) { rev->diffopt.output_format = DIFF_FORMAT_PATCH; + if (rev->show_stat) + rev->diffopt.output_format |= DIFF_FORMAT_DIFFSTAT; + } } int cmd_show(int argc, const char **argv, const char *prefix) @@ -727,9 +736,14 @@ static void log_setup_revisions_tweak(struct rev_info *rev, rev->prune_data.nr == 1) rev->diffopt.flags.follow_renames = 1; - /* Turn --cc/-c into -p --cc/-c when -p was not given */ - if (!rev->diffopt.output_format && rev->combine_merges) - rev->diffopt.output_format = DIFF_FORMAT_PATCH; + if (!rev->diffopt.output_format) { + /* Turn --cc/-c into -p --cc/-c when -p was not given */ + if (rev->combine_merges) + rev->diffopt.output_format = DIFF_FORMAT_PATCH; + + if (rev->show_stat) + rev->diffopt.output_format |= DIFF_FORMAT_DIFFSTAT; + } if (rev->first_parent_only && rev->ignore_merges < 0) rev->ignore_merges = 0; diff --git a/revision.h b/revision.h index f6bf860d19..e402c519d8 100644 --- a/revision.h +++ b/revision.h @@ -204,6 +204,7 @@ struct rev_info { show_merge:1, show_notes_given:1, show_signature:1, + show_stat:1, pretty_given:1, abbrev_commit:1, abbrev_commit_given:1, -- 2.28.0