24
static const char *default_date_mode = NULL;
25
26
static int default_show_root = 1;
27
-static int decoration_style = 0;
27
+static int decoration_style;
28
static const char *fmt_patch_subject_prefix = "PATCH";
29
static const char *fmt_pretty;
30
32
"git log [<options>] [<since>..<until>] [[--] <path>...]\n"
33
" or: git show [options] <object>...";
34
35
+static int parse_decoration_style(const char *var, const char *value)
36
+{
37
+ switch (git_config_maybe_bool(var, value)) {
38
+ case 1:
39
+ return DECORATE_SHORT_REFS;
40
+ case 0:
41
+ return 0;
42
+ default:
43
+ break;
44
+ }
45
+ if (!strcmp(value, "full"))
46
+ return DECORATE_FULL_REFS;
47
+ else if (!strcmp(value, "short"))
48
+ return DECORATE_SHORT_REFS;
49
+ return -1;
50
+}
51
+
52
static void cmd_log_init(int argc, const char **argv, const char *prefix,
53
struct rev_info *rev)
54
{
91
decoration_style = DECORATE_SHORT_REFS;
92
} else if (!prefixcmp(arg, "--decorate=")) {
93
const char *v = skip_prefix(arg, "--decorate=");
77
- if (!strcmp(v, "full"))
78
- decoration_style = DECORATE_FULL_REFS;
79
- else if (!strcmp(v, "short"))
80
- decoration_style = DECORATE_SHORT_REFS;
81
- else
94
+ decoration_style = parse_decoration_style(arg, v);
95
+ if (decoration_style < 0)
96
die("invalid --decorate option: %s", arg);
97
+ } else if (!strcmp(arg, "--no-decorate")) {
98
+ decoration_style = 0;
99
} else if (!strcmp(arg, "--source")) {
100
rev->show_source = 1;
101
} else if (!strcmp(arg, "-h")) {
269
if (!strcmp(var, "log.date"))
270
return git_config_string(&default_date_mode, var, value);
271
if (!strcmp(var, "log.decorate")) {
256
- if (!strcmp(value, "full"))
257
- decoration_style = DECORATE_FULL_REFS;
258
- else if (!strcmp(value, "short"))
259
- decoration_style = DECORATE_SHORT_REFS;
272
+ decoration_style = parse_decoration_style(var, value);
273
+ if (decoration_style < 0)
274
+ decoration_style = 0; /* maybe warn? */
275
return 0;
276
}
277
if (!strcmp(var, "log.showroot")) {