|
24 | 24 | static const char *default_date_mode = NULL;
|
25 | 25 |
|
26 | 26 | static int default_show_root = 1;
|
27 |
| -static int decoration_style = 0; |
| 27 | +static int decoration_style; |
28 | 28 | static const char *fmt_patch_subject_prefix = "PATCH";
|
29 | 29 | static const char *fmt_pretty;
|
30 | 30 |
|
31 | 31 | static const char * const builtin_log_usage =
|
32 | 32 | "git log [<options>] [<since>..<until>] [[--] <path>...]\n"
|
33 | 33 | " or: git show [options] <object>...";
|
34 | 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 | + |
35 | 52 | static void cmd_log_init(int argc, const char **argv, const char *prefix,
|
36 | 53 | struct rev_info *rev)
|
37 | 54 | {
|
@@ -74,12 +91,11 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,
|
74 | 91 | decoration_style = DECORATE_SHORT_REFS;
|
75 | 92 | } else if (!prefixcmp(arg, "--decorate=")) {
|
76 | 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) |
82 | 96 | die("invalid --decorate option: %s", arg);
|
| 97 | + } else if (!strcmp(arg, "--no-decorate")) { |
| 98 | + decoration_style = 0; |
83 | 99 | } else if (!strcmp(arg, "--source")) {
|
84 | 100 | rev->show_source = 1;
|
85 | 101 | } else if (!strcmp(arg, "-h")) {
|
@@ -253,10 +269,9 @@ static int git_log_config(const char *var, const char *value, void *cb)
|
253 | 269 | if (!strcmp(var, "log.date"))
|
254 | 270 | return git_config_string(&default_date_mode, var, value);
|
255 | 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? */ |
260 | 275 | return 0;
|
261 | 276 | }
|
262 | 277 | if (!strcmp(var, "log.showroot")) {
|
|
0 commit comments