Add log.abbrev-commit (and log.abbrevCommit synonym) config option as a convenience for users who often use --abbrev-commit with git log and git show (but not git whatchanged, as its output is more likely to be parsed even though it is not technically plumbing). Allow the option to be overridden via --no-abbrev-commit. (Also, a drive-by spelling correction in git log's short help.) Signed-off-by: Jay Soffian <jaysoffian@xxxxxxxxx> --- Documentation/config.txt | 6 ++++++ Documentation/git-log.txt | 3 +++ builtin/log.c | 17 +++++++++++++++-- t/t4202-log.sh | 8 ++++++++ 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/Documentation/config.txt b/Documentation/config.txt index 285c7f73ca..85f00f6bb1 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -1314,6 +1314,12 @@ interactive.singlekey:: linkgit:git-checkout[1]. Note that this setting is silently ignored if portable keystroke input is not available. +log.abbrev-commit:: +log.abbrevCommit:: + If true, act as if --abbrev-commit were specified on the command + line. May be overridden with --no-abbrev-commit. Note that this setting + is ignored by rev-list. + log.date:: Set the default date-time mode for the 'log' command. Setting a value for log.date is similar to using 'git log''s diff --git a/Documentation/git-log.txt b/Documentation/git-log.txt index de5c0d37a5..3061eec9b7 100644 --- a/Documentation/git-log.txt +++ b/Documentation/git-log.txt @@ -38,6 +38,9 @@ OPTIONS Continue listing the history of a file beyond renames (works only for a single file). +--no-abbrev-commit:: + Don't abbreviate commit name. Useful for overridding log.abbrevCommit. + --no-decorate:: --decorate[=short|full|no]:: Print out the ref names of any commits that are shown. If 'short' is diff --git a/builtin/log.c b/builtin/log.c index f6219909a7..cfac510b24 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -23,6 +23,7 @@ /* Set a default date-time format for git log ("log.date" config variable) */ static const char *default_date_mode = NULL; +static int default_abbrev_commit = 0; static int default_show_root = 1; static int decoration_style; static int decoration_given; @@ -77,6 +78,7 @@ static void cmd_log_init_defaults(struct rev_info *rev) get_commit_format(fmt_pretty, rev); rev->verbose_header = 1; DIFF_OPT_SET(&rev->diffopt, RECURSIVE); + rev->abbrev_commit = default_abbrev_commit; rev->show_root_diff = default_show_root; rev->subject_prefix = fmt_patch_subject_prefix; DIFF_OPT_SET(&rev->diffopt, ALLOW_TEXTCONV); @@ -89,11 +91,13 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix, struct rev_info *rev, struct setup_revision_opt *opt) { struct userformat_want w; - int quiet = 0, source = 0; + int quiet = 0, source = 0, no_abbrev_commit = 0; const struct option builtin_log_options[] = { - OPT_BOOLEAN(0, "quiet", &quiet, "supress diff output"), + OPT_BOOLEAN(0, "quiet", &quiet, "suppress diff output"), OPT_BOOLEAN(0, "source", &source, "show source"), + OPT_BOOLEAN(0, "no-abbrev-commit", &no_abbrev_commit, + "don't abbreviate commit name"), { OPTION_CALLBACK, 0, "decorate", NULL, NULL, "decorate options", PARSE_OPT_OPTARG, decorate_callback}, OPT_END() @@ -129,6 +133,9 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix, if (source) rev->show_source = 1; + if (no_abbrev_commit) + rev->abbrev_commit = 0; + /* * defeat log.decorate configuration interacting with --pretty=raw * from the command line. @@ -323,6 +330,11 @@ static int git_log_config(const char *var, const char *value, void *cb) return git_config_string(&fmt_pretty, var, value); if (!strcmp(var, "format.subjectprefix")) return git_config_string(&fmt_patch_subject_prefix, var, value); + if (!strcasecmp(var, "log.abbrevcommit") || + !strcasecmp(var, "log.abbrev-commit")) { + default_abbrev_commit = git_config_bool(var, value); + return 0; + } if (!strcmp(var, "log.date")) return git_config_string(&default_date_mode, var, value); if (!strcmp(var, "log.decorate")) { @@ -347,6 +359,7 @@ int cmd_whatchanged(int argc, const char **argv, const char *prefix) struct setup_revision_opt opt; git_config(git_log_config, NULL); + default_abbrev_commit = 0; if (diff_use_color_default == -1) diff_use_color_default = git_use_color_default; diff --git a/t/t4202-log.sh b/t/t4202-log.sh index 2fcc31a6f3..83c6576feb 100755 --- a/t/t4202-log.sh +++ b/t/t4202-log.sh @@ -450,6 +450,14 @@ test_expect_success 'log.decorate configuration' ' ' +test_expect_success 'log.abbrev-commit configuration' ' + test_might_fail git config --remove-section log && + git log --abbrev-commit >expect && + git config log.abbrev-commit true && + git log >actual && + test_cmp expect actual +' + test_expect_success 'show added path under "--follow -M"' ' # This tests for a regression introduced in v1.7.2-rc0~103^2~2 test_create_repo regression && -- 1.7.5 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html