{"thread":{"id":"27391","subject":"[PATCH v5] Add log.abbrevCommit config variable","startedAt":"2011-05-18T01:26:31Z","lastAt":"2011-05-18T17:56:43Z","messageCount":3,"participants":["Jay Soffian","Junio C Hamano"],"isPatch":true,"patchVersion":5,"patchTotal":null},"messages":[{"id":"168093","messageId":"1305681991-11699-1-git-send-email-jaysoffian@gmail.com","threadId":"27391","inReplyTo":null,"subject":"[PATCH v5] Add log.abbrevCommit config variable","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2011-05-18T01:26:31Z","receivedAt":"2011-05-18T01:26:31Z","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- Fixed regression in \"git reflog\" output where commit was not abbreviated\n- Added tests for \"git whatchanged\" and \"git reflog\" output formats\n- Added additional stanzas to \"log.abbrevCommit\" test to check output\n  of \"git whatchanged\" and \"git reflog\"\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                   |   40 ++++++++++++++++++++++++++++++++++++++\n 6 files changed, 69 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..f709d5c099 100755\n--- a/t/t4202-log.sh\n+++ b/t/t4202-log.sh\n@@ -450,6 +450,46 @@ test_expect_success 'log.decorate configuration' '\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 >expect.full &&\n+\tgit log --abbrev-commit >expect.abbrev &&\n+\tgit log --pretty=raw >expect.raw &&\n+\tgit log -g --abbrev-commit --pretty=oneline >expect.reflog &&\n+\tgit whatchanged --abbrev-commit >expect.whatchanged &&\n+\n+\tgit config log.abbrevCommit true &&\n+\n+\tgit log --no-abbrev-commit >actual.full &&\n+\ttest_cmp expect.full actual.full &&\n+\n+\tgit log >actual.abbrev &&\n+\ttest_cmp expect.abbrev actual.abbrev &&\n+\n+\tgit log --pretty=raw >actual.raw &&\n+\ttest_cmp expect.raw actual.raw &&\n+\n+\tgit reflog >actual.reflog &&\n+\ttest_cmp expect.reflog actual.reflog\n+\n+\tgit whatchanged >actual.whatchanged &&\n+\ttest_cmp expect.whatchanged actual.whatchanged\n+'\n+\n test_expect_success 'show added path under \"--follow -M\"' '\n \t# This tests for a regression introduced in v1.7.2-rc0~103^2~2\n \ttest_create_repo regression &&\n-- \n1.7.5.1.340.g32d9b\n"},{"id":"168098","messageId":"7vmxikeiyt.fsf@alter.siamese.dyndns.org","threadId":"27391","inReplyTo":"1305681991-11699-1-git-send-email-jaysoffian@gmail.com","subject":"Re: [PATCH v5] Add log.abbrevCommit config variable","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-05-18T04:22:18Z","receivedAt":"2011-05-18T04:22:18Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jay Soffian <jaysoffian@gmail.com> writes:\n\n> +test_expect_success 'log.abbrev-commit configuration' '\n> +\ttest_when_finished \"git config --unset log.abbrevCommit\" &&\n> +\n> +\tgit log >expect.full &&\n> +\tgit log --abbrev-commit >expect.abbrev &&\n> +\tgit log --pretty=raw >expect.raw &&\n> +\tgit log -g --abbrev-commit --pretty=oneline >expect.reflog &&\n> +\tgit whatchanged --abbrev-commit >expect.whatchanged &&\n> +\n> +\tgit config log.abbrevCommit true &&\n> +\n> +\tgit log --no-abbrev-commit >actual.full &&\n> +\ttest_cmp expect.full actual.full &&\n> +\n> +\tgit log >actual.abbrev &&\n> +\ttest_cmp expect.abbrev actual.abbrev &&\n> +\n> +\tgit log --pretty=raw >actual.raw &&\n> +\ttest_cmp expect.raw actual.raw &&\n> +\n> +\tgit reflog >actual.reflog &&\n> +\ttest_cmp expect.reflog actual.reflog\n> +\n> +\tgit whatchanged >actual.whatchanged &&\n> +\ttest_cmp expect.whatchanged actual.whatchanged\n> +'\n\nI can see you are testing all the commands in the \"log\" family for cases\nwhere the new configuration _should_ take effect, but I cannot see the\nsame throughness for the negative case where the configuration should not\nkick in. Is \"log\" the only one that you make sure --no-abbrev-commit\ndefeats the configuration? Please always test both sides of the coin.\n\nOther than that, the patch looked fine from my cursory look.\n\nThanks.\n"},{"id":"168149","messageId":"BANLkTimi1ar0+q2qfq1L0bm=qoRv+=5ZWQ@mail.gmail.com","threadId":"27391","inReplyTo":"7vmxikeiyt.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v5] Add log.abbrevCommit config variable","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2011-05-18T17:56:43Z","receivedAt":"2011-05-18T17:56:43Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Wed, May 18, 2011 at 12:22 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> Other than that, the patch looked fine from my cursory look.\n\nThanks, I hope v7 addresses all concerns.\n\nj.\n"}]}