|
23 | 23 | /* Set a default date-time format for git log ("log.date" config variable) */ |
24 | 24 | static const char *default_date_mode = NULL; |
25 | 25 |
|
| 26 | +static int default_abbrev_commit; |
26 | 27 | static int default_show_root = 1; |
27 | 28 | static int decoration_style; |
28 | 29 | static int decoration_given; |
@@ -77,6 +78,7 @@ static void cmd_log_init_defaults(struct rev_info *rev) |
77 | 78 | get_commit_format(fmt_pretty, rev); |
78 | 79 | rev->verbose_header = 1; |
79 | 80 | DIFF_OPT_SET(&rev->diffopt, RECURSIVE); |
| 81 | + rev->abbrev_commit = default_abbrev_commit; |
80 | 82 | rev->show_root_diff = default_show_root; |
81 | 83 | rev->subject_prefix = fmt_patch_subject_prefix; |
82 | 84 | DIFF_OPT_SET(&rev->diffopt, ALLOW_TEXTCONV); |
@@ -129,13 +131,16 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix, |
129 | 131 | if (source) |
130 | 132 | rev->show_source = 1; |
131 | 133 |
|
132 | | - /* |
133 | | - * defeat log.decorate configuration interacting with --pretty=raw |
134 | | - * from the command line. |
135 | | - */ |
136 | | - if (!decoration_given && rev->pretty_given |
137 | | - && rev->commit_format == CMIT_FMT_RAW) |
138 | | - decoration_style = 0; |
| 134 | + if (rev->pretty_given && rev->commit_format == CMIT_FMT_RAW) { |
| 135 | + /* |
| 136 | + * "log --pretty=raw" is special; ignore UI oriented |
| 137 | + * configuration variables such as decoration. |
| 138 | + */ |
| 139 | + if (!decoration_given) |
| 140 | + decoration_style = 0; |
| 141 | + if (!rev->abbrev_commit_given) |
| 142 | + rev->abbrev_commit = 0; |
| 143 | + } |
139 | 144 |
|
140 | 145 | if (decoration_style) { |
141 | 146 | rev->show_decorations = 1; |
@@ -323,6 +328,10 @@ static int git_log_config(const char *var, const char *value, void *cb) |
323 | 328 | return git_config_string(&fmt_pretty, var, value); |
324 | 329 | if (!strcmp(var, "format.subjectprefix")) |
325 | 330 | return git_config_string(&fmt_patch_subject_prefix, var, value); |
| 331 | + if (!strcmp(var, "log.abbrevcommit")) { |
| 332 | + default_abbrev_commit = git_config_bool(var, value); |
| 333 | + return 0; |
| 334 | + } |
326 | 335 | if (!strcmp(var, "log.date")) |
327 | 336 | return git_config_string(&default_date_mode, var, value); |
328 | 337 | if (!strcmp(var, "log.decorate")) { |
@@ -516,11 +525,11 @@ int cmd_log_reflog(int argc, const char **argv, const char *prefix) |
516 | 525 |
|
517 | 526 | init_revisions(&rev, prefix); |
518 | 527 | init_reflog_walk(&rev.reflog_info); |
519 | | - rev.abbrev_commit = 1; |
520 | 528 | rev.verbose_header = 1; |
521 | 529 | memset(&opt, 0, sizeof(opt)); |
522 | 530 | opt.def = "HEAD"; |
523 | 531 | cmd_log_init_defaults(&rev); |
| 532 | + rev.abbrev_commit = 1; |
524 | 533 | rev.commit_format = CMIT_FMT_ONELINE; |
525 | 534 | rev.use_terminator = 1; |
526 | 535 | rev.always_show_header = 1; |
|
0 commit comments