2323/* Set a default date-time format for git log ("log.date" config variable) */
2424static const char * default_date_mode = NULL ;
2525
26+ static int default_abbrev_commit ;
2627static int default_show_root = 1 ;
2728static int decoration_style ;
2829static int decoration_given ;
@@ -77,6 +78,7 @@ static void cmd_log_init_defaults(struct rev_info *rev)
7778 get_commit_format (fmt_pretty , rev );
7879 rev -> verbose_header = 1 ;
7980 DIFF_OPT_SET (& rev -> diffopt , RECURSIVE );
81+ rev -> abbrev_commit = default_abbrev_commit ;
8082 rev -> show_root_diff = default_show_root ;
8183 rev -> subject_prefix = fmt_patch_subject_prefix ;
8284 DIFF_OPT_SET (& rev -> diffopt , ALLOW_TEXTCONV );
@@ -92,7 +94,7 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
9294 int quiet = 0 , source = 0 ;
9395
9496 const struct option builtin_log_options [] = {
95- OPT_BOOLEAN (0 , "quiet" , & quiet , "supress diff output" ),
97+ OPT_BOOLEAN (0 , "quiet" , & quiet , "suppress diff output" ),
9698 OPT_BOOLEAN (0 , "source" , & source , "show source" ),
9799 { OPTION_CALLBACK , 0 , "decorate" , NULL , NULL , "decorate options" ,
98100 PARSE_OPT_OPTARG , decorate_callback },
@@ -129,13 +131,16 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
129131 if (source )
130132 rev -> show_source = 1 ;
131133
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+ }
139144
140145 if (decoration_style ) {
141146 rev -> show_decorations = 1 ;
@@ -323,6 +328,10 @@ static int git_log_config(const char *var, const char *value, void *cb)
323328 return git_config_string (& fmt_pretty , var , value );
324329 if (!strcmp (var , "format.subjectprefix" ))
325330 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+ }
326335 if (!strcmp (var , "log.date" ))
327336 return git_config_string (& default_date_mode , var , value );
328337 if (!strcmp (var , "log.decorate" )) {
@@ -516,11 +525,11 @@ int cmd_log_reflog(int argc, const char **argv, const char *prefix)
516525
517526 init_revisions (& rev , prefix );
518527 init_reflog_walk (& rev .reflog_info );
519- rev .abbrev_commit = 1 ;
520528 rev .verbose_header = 1 ;
521529 memset (& opt , 0 , sizeof (opt ));
522530 opt .def = "HEAD" ;
523531 cmd_log_init_defaults (& rev );
532+ rev .abbrev_commit = 1 ;
524533 rev .commit_format = CMIT_FMT_ONELINE ;
525534 rev .use_terminator = 1 ;
526535 rev .always_show_header = 1 ;
0 commit comments