git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] reflog: specify default pretty format in config
@ 2019-01-30 14:47 Roland Hieber
  2019-01-30 18:22 ` Matthieu Moy
  2019-02-08 18:31 ` [PATCH v2] " Roland Hieber
  0 siblings, 2 replies; 5+ messages in thread
From: Roland Hieber @ 2019-01-30 14:47 UTC (permalink / raw)
  To: git
  Cc: Michael Haggerty, Junio C Hamano, Matthieu Moy, Stefan Beller,
	Roland Hieber

The output of git-reflog is currently only customizable by calling
reflog with --pretty=... or overriding the default "oneline" pretty
format in the configuration. To save typing, teach reflog to fall back
to a default format specified in the config option "reflog.pretty"
unless a different pretty format is given on the command line. (This is
similar to the "format.pretty" option for git-log and git-show.)
When this config option is not set, fall back to the old default of
--pretty=oneline --abbrev-hash.

Signed-off-by: Roland Hieber <rhi@pengutronix.de>
---
 Documentation/git-reflog.txt |  2 ++
 builtin/log.c                | 12 +++++++++---
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/Documentation/git-reflog.txt b/Documentation/git-reflog.txt
index ff487ff77d..9dccd4bcfd 100644
--- a/Documentation/git-reflog.txt
+++ b/Documentation/git-reflog.txt
@@ -41,6 +41,8 @@ command-line (or `HEAD`, by default). The reflog covers all recent
 actions, and in addition the `HEAD` reflog records branch switching.
 `git reflog show` is an alias for `git log -g --abbrev-commit
 --pretty=oneline`; see linkgit:git-log[1] for more information.
+The config option `reflog.pretty` is used as the default pretty
+format if nothing else is specified.
 
 The "expire" subcommand prunes older reflog entries. Entries older
 than `expire` time, or entries older than `expire-unreachable` time
diff --git a/builtin/log.c b/builtin/log.c
index a479642eb9..0fbd324016 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -667,6 +667,7 @@ int cmd_log_reflog(int argc, const char **argv, const char *prefix)
 {
 	struct rev_info rev;
 	struct setup_revision_opt opt;
+	int cfg_have_pretty;
 
 	init_log_defaults();
 	git_config(git_log_config, NULL);
@@ -676,11 +677,16 @@ int cmd_log_reflog(int argc, const char **argv, const char *prefix)
 	rev.verbose_header = 1;
 	memset(&opt, 0, sizeof(opt));
 	opt.def = "HEAD";
+
+	cfg_have_pretty = git_config_get_string_const("reflog.pretty", &fmt_pretty);
 	cmd_log_init_defaults(&rev);
-	rev.abbrev_commit = 1;
-	rev.commit_format = CMIT_FMT_ONELINE;
-	rev.use_terminator = 1;
+	if (cfg_have_pretty != 0) {
+		rev.abbrev_commit = 1;
+		rev.commit_format = CMIT_FMT_ONELINE;
+		rev.use_terminator = 1;
+	}
 	rev.always_show_header = 1;
+
 	cmd_log_init_finish(argc, argv, prefix, &rev, &opt);
 
 	return cmd_log_walk(&rev);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-02-11 19:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-30 14:47 [PATCH] reflog: specify default pretty format in config Roland Hieber
2019-01-30 18:22 ` Matthieu Moy
2019-01-31 10:12   ` Roland Hieber
2019-02-08 18:31 ` [PATCH v2] " Roland Hieber
2019-02-11 19:54   ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).