@matheusbsbs / matheus-bagliano / commits / 94c22a5e7b
Fork 0

log/show/whatchanged: introduce format.pretty configuration

When running log/show/whatchanged from the command line, the user may want to use a preferred format without having to pass --pretty=<fmt> option every time from the command line. This teaches these three commands to honor a new configuration variable, format.pretty. The --pretty option given from the command line will override the configured format. The earlier patch fixed the in-tree callers that run these commands for purposes other than showing the output directly to the end user (the only other in-tree caller is "git bisect visualize", whose output directly goes to the end user and should be affected by this patch). Similar fixes will be needed for end-user scripts that parse the output from these commands and expect them to be in the default pretty format. Signed-off-by: Denis Cheng <crquan@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Denis Cheng committed Mar 2, 2008 at 17:05 UTC 94c22a5e7b4247d7d6453272c4425d81071d2689
3 files changed +13
Documentation/config.txt
+5
@@ -556,6 +556,11 @@ format.suffix::
556 `.patch`. Use this variable to change that suffix (make sure to
557 include the dot if you want it).
558
559 +format.pretty::
560 + The default pretty format for log/show/whatchanged command,
561 + See linkgit:git-log[1], linkgit:git-show[1],
562 + linkgit:git-whatchanged[1].
563 +
564 gc.aggressiveWindow::
565 The window size parameter used in the delta compression
566 algorithm used by 'git gc --aggressive'. This defaults
Documentation/pretty-options.txt
+3
@@ -4,6 +4,9 @@
4 where '<format>' can be one of 'oneline', 'short', 'medium',
5 'full', 'fuller', 'email', 'raw' and 'format:<string>'.
6 When omitted, the format defaults to 'medium'.
7 ++
8 +Note: you can specify the default pretty format in the repository
9 +configuration (see linkgit:git-config[1]).
10
11 --abbrev-commit::
12 Instead of showing the full 40-byte hexadecimal commit object
builtin-log.c
+5
@@ -20,6 +20,7 @@
20
21 static int default_show_root = 1;
22 static const char *fmt_patch_subject_prefix = "PATCH";
23 +static const char *fmt_pretty;
24
25 static void add_name_decoration(const char *prefix, const char *name, struct object *obj)
26 {
@@ -54,6 +55,8 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,
55
56 rev->abbrev = DEFAULT_ABBREV;
57 rev->commit_format = CMIT_FMT_DEFAULT;
58 + if (fmt_pretty)
59 + rev->commit_format = get_commit_format(fmt_pretty);
60 rev->verbose_header = 1;
61 DIFF_OPT_SET(&rev->diffopt, RECURSIVE);
62 rev->show_root_diff = default_show_root;
@@ -221,6 +224,8 @@ static int cmd_log_walk(struct rev_info *rev)
224
225 static int git_log_config(const char *var, const char *value)
226 {
227 + if (!strcmp(var, "format.pretty"))
228 + return git_config_string(&fmt_pretty, var, value);
229 if (!strcmp(var, "format.subjectprefix")) {
230 if (!value)
231 config_error_nonbool(var);