From: Robert Karszniewicz <avoidr@posteo.de>
To: git@vger.kernel.org
Subject: [RFC PATCH] log: add log.showStat configuration variable
Date: Thu, 8 Oct 2020 18:20:15 +0200 [thread overview]
Message-ID: <20201008162015.23898-1-avoidr@posteo.de> (raw)
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
next reply other threads:[~2020-10-08 16:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-08 16:20 Robert Karszniewicz [this message]
2020-10-08 17:58 ` [RFC PATCH] log: add log.showStat configuration variable Junio C Hamano
2020-10-10 14:02 ` Robert Karszniewicz
2020-10-08 18:12 ` Derrick Stolee
2020-10-11 9:59 ` Robert Karszniewicz
2020-10-12 12:50 ` Derrick Stolee
2020-10-12 16:14 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201008162015.23898-1-avoidr@posteo.de \
--to=avoidr@posteo.de \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.