{"thread":{"id":"27398","subject":"[PATCH v6] Add log.abbrevCommit config variable","startedAt":"2011-05-18T17:48:30Z","lastAt":"2011-05-18T17:51:06Z","messageCount":2,"participants":["Jay Soffian"],"isPatch":true,"patchVersion":6,"patchTotal":null},"messages":[{"id":"168146","messageId":"1305740910-26983-1-git-send-email-jaysoffian@gmail.com","threadId":"27398","inReplyTo":null,"subject":"[PATCH v6] Add log.abbrevCommit config variable","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2011-05-18T17:48:30Z","receivedAt":"2011-05-18T17:48:30Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"Add log.abbrevCommit config variable as a convenience for users who\noften use --abbrev-commit with git log and friends. Allow the option\nto be overridden with --no-abbrev-commit. Per 635530a2fc and 4f62c2bc57,\nthe config variable is ignored when log is given \"--pretty=raw\".\n\n(Also, a drive-by spelling correction in git log's short help.)\n\nSigned-off-by: Jay Soffian <jaysoffian@gmail.com>\n---\n- Added --pretty=raw stanza to log.decorate test\n- Added additional stanzas for --no-abbrev-commit to log.abbrevCommit test\n\n Documentation/config.txt         |    5 +++\n Documentation/pretty-options.txt |    5 +++\n builtin/log.c                    |   24 +++++++++++------\n revision.c                       |    3 ++\n revision.h                       |    1 +\n t/t4202-log.sh                   |   51 ++++++++++++++++++++++++++++++++++++++\n 6 files changed, 80 insertions(+), 9 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 1a060ecbc8..6b93777199 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -1315,6 +1315,11 @@ interactive.singlekey::\n \tsetting is silently ignored if portable keystroke input\n \tis not available.\n \n+log.abbrevCommit::\n+\tIf true, makes linkgit:git-log[1], linkgit:git-show[1], and\n+\tlinkgit:git-whatchanged[1] assume `\\--abbrev-commit`. You may\n+\toverride this option with `\\--no-abbrev-commit`.\n+\n log.date::\n \tSet the default date-time mode for the 'log' command.\n \tSetting a value for log.date is similar to using 'git log''s\ndiff --git a/Documentation/pretty-options.txt b/Documentation/pretty-options.txt\nindex d5c977262a..2a3dc8664f 100644\n--- a/Documentation/pretty-options.txt\n+++ b/Documentation/pretty-options.txt\n@@ -19,6 +19,11 @@ configuration (see linkgit:git-config[1]).\n This should make \"--pretty=oneline\" a whole lot more readable for\n people using 80-column terminals.\n \n+--no-abbrev-commit::\n+\tShow the full 40-byte hexadecimal commit object name. This negates\n+\t`--abbrev-commit` and those options which imply it such as\n+\t\"--oneline\". It also overrides the 'log.abbrevCommit' variable.\n+\n --oneline::\n \tThis is a shorthand for \"--pretty=oneline --abbrev-commit\"\n \tused together.\ndiff --git a/builtin/log.c b/builtin/log.c\nindex f6219909a7..019a44ac86 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -23,6 +23,7 @@\n /* Set a default date-time format for git log (\"log.date\" config variable) */\n static const char *default_date_mode = NULL;\n \n+static int default_abbrev_commit;\n static int default_show_root = 1;\n static int decoration_style;\n static int decoration_given;\n@@ -77,6 +78,7 @@ static void cmd_log_init_defaults(struct rev_info *rev)\n \t\tget_commit_format(fmt_pretty, rev);\n \trev->verbose_header = 1;\n \tDIFF_OPT_SET(&rev->diffopt, RECURSIVE);\n+\trev->abbrev_commit = default_abbrev_commit;\n \trev->show_root_diff = default_show_root;\n \trev->subject_prefix = fmt_patch_subject_prefix;\n \tDIFF_OPT_SET(&rev->diffopt, ALLOW_TEXTCONV);\n@@ -92,7 +94,7 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,\n \tint quiet = 0, source = 0;\n \n \tconst struct option builtin_log_options[] = {\n-\t\tOPT_BOOLEAN(0, \"quiet\", &quiet, \"supress diff output\"),\n+\t\tOPT_BOOLEAN(0, \"quiet\", &quiet, \"suppress diff output\"),\n \t\tOPT_BOOLEAN(0, \"source\", &source, \"show source\"),\n \t\t{ OPTION_CALLBACK, 0, \"decorate\", NULL, NULL, \"decorate options\",\n \t\t  PARSE_OPT_OPTARG, decorate_callback},\n@@ -129,13 +131,13 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,\n \tif (source)\n \t\trev->show_source = 1;\n \n-\t/*\n-\t * defeat log.decorate configuration interacting with --pretty=raw\n-\t * from the command line.\n-\t */\n-\tif (!decoration_given && rev->pretty_given\n-\t    && rev->commit_format == CMIT_FMT_RAW)\n-\t\tdecoration_style = 0;\n+\tif (rev->pretty_given && rev->commit_format == CMIT_FMT_RAW) {\n+\t\t/* \"log --pretty=raw\" is special */\n+\t\tif (!decoration_given)\n+\t\t\tdecoration_style = 0;\n+\t\tif (!rev->abbrev_commit_given)\n+\t\t\trev->abbrev_commit = 0;\n+\t}\n \n \tif (decoration_style) {\n \t\trev->show_decorations = 1;\n@@ -323,6 +325,10 @@ static int git_log_config(const char *var, const char *value, void *cb)\n \t\treturn git_config_string(&fmt_pretty, var, value);\n \tif (!strcmp(var, \"format.subjectprefix\"))\n \t\treturn git_config_string(&fmt_patch_subject_prefix, var, value);\n+\tif (!strcmp(var, \"log.abbrevcommit\")) {\n+\t\tdefault_abbrev_commit = git_config_bool(var, value);\n+\t\treturn 0;\n+\t}\n \tif (!strcmp(var, \"log.date\"))\n \t\treturn git_config_string(&default_date_mode, var, value);\n \tif (!strcmp(var, \"log.decorate\")) {\n@@ -516,11 +522,11 @@ int cmd_log_reflog(int argc, const char **argv, const char *prefix)\n \n \tinit_revisions(&rev, prefix);\n \tinit_reflog_walk(&rev.reflog_info);\n-\trev.abbrev_commit = 1;\n \trev.verbose_header = 1;\n \tmemset(&opt, 0, sizeof(opt));\n \topt.def = \"HEAD\";\n \tcmd_log_init_defaults(&rev);\n+\trev.abbrev_commit = 1;\n \trev.commit_format = CMIT_FMT_ONELINE;\n \trev.use_terminator = 1;\n \trev.always_show_header = 1;\ndiff --git a/revision.c b/revision.c\nindex a7cf79bf2e..be74bf92f5 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -1429,6 +1429,9 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg\n \t\t\trevs->abbrev = 40;\n \t} else if (!strcmp(arg, \"--abbrev-commit\")) {\n \t\trevs->abbrev_commit = 1;\n+\t\trevs->abbrev_commit_given = 1;\n+\t} else if (!strcmp(arg, \"--no-abbrev-commit\")) {\n+\t\trevs->abbrev_commit = 0;\n \t} else if (!strcmp(arg, \"--full-diff\")) {\n \t\trevs->diff = 1;\n \t\trevs->full_diff = 1;\ndiff --git a/revision.h b/revision.h\nindex bca9947977..5e1f5c7e8f 100644\n--- a/revision.h\n+++ b/revision.h\n@@ -90,6 +90,7 @@ struct rev_info {\n \t\t\tshow_notes_given:1,\n \t\t\tpretty_given:1,\n \t\t\tabbrev_commit:1,\n+\t\t\tabbrev_commit_given:1,\n \t\t\tuse_terminator:1,\n \t\t\tmissing_newline:1,\n \t\t\tdate_mode_explicit:1;\ndiff --git a/t/t4202-log.sh b/t/t4202-log.sh\nindex 2fcc31a6f3..4b9b1fa985 100755\n--- a/t/t4202-log.sh\n+++ b/t/t4202-log.sh\n@@ -448,6 +448,57 @@ test_expect_success 'log.decorate configuration' '\n \tgit log --oneline --decorate >actual &&\n \ttest_cmp expect.short actual\n \n+\tgit config --unset-all log.decorate &&\n+\tgit log --pretty=raw >expect.raw &&\n+\tgit config log.decorate full &&\n+\tgit log --pretty=raw >actual &&\n+\ttest_cmp expect.raw actual\n+\n+'\n+\n+test_expect_success 'reflog is expected format' '\n+\ttest_might_fail git config --remove-section log &&\n+\tgit log -g --abbrev-commit --pretty=oneline >expect &&\n+\tgit reflog >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'whatchanged is expected format' '\n+\tgit log --no-merges --raw >expect &&\n+\tgit whatchanged >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'log.abbrev-commit configuration' '\n+\ttest_when_finished \"git config --unset log.abbrevCommit\" &&\n+\n+\tgit log --abbrev-commit >expect.log.abbrev &&\n+\tgit log --no-abbrev-commit >expect.log.full &&\n+\tgit log --pretty=raw >expect.log.raw &&\n+\tgit reflog --abbrev-commit >expect.reflog.abbrev &&\n+\tgit reflog --no-abbrev-commit >expect.reflog.full &&\n+\tgit whatchanged --abbrev-commit >expect.whatchanged.abbrev &&\n+\tgit whatchanged --no-abbrev-commit >expect.whatchanged.full &&\n+\n+\tgit config log.abbrevCommit true &&\n+\n+\tgit log >actual &&\n+\ttest_cmp expect.log.abbrev actual &&\n+\tgit log --no-abbrev-commit >actual &&\n+\ttest_cmp expect.log.full actual &&\n+\n+\tgit log --pretty=raw >actual &&\n+\ttest_cmp expect.log.raw actual &&\n+\n+\tgit reflog >actual &&\n+\ttest_cmp expect.reflog.abbrev actual.reflog\n+\tgit reflog --no-abbrev-commit >actual &&\n+\ttest_cmp expect.reflog.full actual\n+\n+\tgit whatchanged >actual &&\n+\ttest_cmp expect.whatchanged.abbrev actual\n+\tgit whatchanged --no-abbrev-commit >actual &&\n+\ttest_cmp expect.whatchanged.full actual\n '\n \n test_expect_success 'show added path under \"--follow -M\"' '\n-- \n1.7.5.1.340.g53e0.dirty\n"},{"id":"168147","messageId":"BANLkTimiWRAz-RNEbFgip2DQrfsjcJTFLQ@mail.gmail.com","threadId":"27398","inReplyTo":"1305740910-26983-1-git-send-email-jaysoffian@gmail.com","subject":"Re: [PATCH v6] Add log.abbrevCommit config variable","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2011-05-18T17:51:06Z","receivedAt":"2011-05-18T17:51:06Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Wed, May 18, 2011 at 1:48 PM, Jay Soffian <jaysoffian@gmail.com> wrote:\n> +       git reflog >actual &&\n> +       test_cmp expect.reflog.abbrev actual.reflog\n> +       git reflog --no-abbrev-commit >actual &&\n> +       test_cmp expect.reflog.full actual\n\nGrr, why don't I see these typos when I proof them before I send?\n\nj.\n"}]}