{"thread":{"id":"25459","subject":"[PATCH] blame: Add option to show author email instead of name","startedAt":"2010-10-16T06:57:51Z","lastAt":"2010-10-21T20:58:59Z","messageCount":11,"participants":["Kevin Ballard","Junio C Hamano","Jonathan Nieder","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"153619","messageId":"1287212271-23545-1-git-send-email-kevin@sb.org","threadId":"25459","inReplyTo":null,"subject":"[PATCH] blame: Add option to show author email instead of name","fromName":"Kevin Ballard","fromEmail":"kevin@sb.org","sentAt":"2010-10-16T06:57:51Z","receivedAt":"2010-10-16T06:57:51Z","isPatch":true,"sender":{"key":"kevin@sb.org","avatar":"https://avatars.githubusercontent.com/u/714?v=4"},"body":"Add a new option -e (or --show-email) to git-blame that will display\nthe author's email instead of name on each line. This option works\nfor both git-blame and git-annotate.\n\nSigned-off-by: Kevin Ballard <kevin@sb.org>\n---\n Documentation/git-blame.txt |    6 +++++-\n builtin/blame.c             |   27 +++++++++++++++++++++------\n t/annotate-tests.sh         |   12 ++++++------\n t/t8002-blame.sh            |    5 +++++\n 4 files changed, 37 insertions(+), 13 deletions(-)\n\ndiff --git a/Documentation/git-blame.txt b/Documentation/git-blame.txt\nindex a27f439..c71671b 100644\n--- a/Documentation/git-blame.txt\n+++ b/Documentation/git-blame.txt\n@@ -8,7 +8,7 @@ git-blame - Show what revision and author last modified each line of a file\n SYNOPSIS\n --------\n [verse]\n-'git blame' [-c] [-b] [-l] [--root] [-t] [-f] [-n] [-s] [-p] [-w] [--incremental] [-L n,m]\n+'git blame' [-c] [-b] [-l] [--root] [-t] [-f] [-n] [-s] [-e] [-p] [-w] [--incremental] [-L n,m]\n \t    [-S <revs-file>] [-M] [-C] [-C] [-C] [--since=<date>]\n \t    [<rev> | --contents <file> | --reverse <rev>] [--] <file>\n \n@@ -65,6 +65,10 @@ include::blame-options.txt[]\n -s::\n \tSuppress the author name and timestamp from the output.\n \n+-e::\n+--show-email::\n+\tShow the author email instead of author name (Default: off).\n+\n -w::\n \tIgnore whitespace when comparing the parent's version and\n \tthe child's to find where the lines came from.\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 1015354..0f0317c 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -1606,6 +1606,7 @@ static const char *format_time(unsigned long time, const char *tz_str,\n #define OUTPUT_SHOW_NUMBER\t040\n #define OUTPUT_SHOW_SCORE      0100\n #define OUTPUT_NO_AUTHOR       0200\n+#define OUTPUT_SHOW_EMAIL\t0400\n \n static void emit_porcelain(struct scoreboard *sb, struct blame_entry *ent)\n {\n@@ -1671,12 +1672,17 @@ static void emit_other(struct scoreboard *sb, struct blame_entry *ent, int opt)\n \t\t}\n \n \t\tprintf(\"%.*s\", length, hex);\n-\t\tif (opt & OUTPUT_ANNOTATE_COMPAT)\n-\t\t\tprintf(\"\\t(%10s\\t%10s\\t%d)\", ci.author,\n+\t\tif (opt & OUTPUT_ANNOTATE_COMPAT) {\n+\t\t\tchar *name;\n+\t\t\tif (opt & OUTPUT_SHOW_EMAIL)\n+\t\t\t\tname = ci.author_mail;\n+\t\t\telse\n+\t\t\t\tname = ci.author;\n+\t\t\tprintf(\"\\t(%10s\\t%10s\\t%d)\", name,\n \t\t\t       format_time(ci.author_time, ci.author_tz,\n \t\t\t\t\t   show_raw_time),\n \t\t\t       ent->lno + 1 + cnt);\n-\t\telse {\n+\t\t} else {\n \t\t\tif (opt & OUTPUT_SHOW_SCORE)\n \t\t\t\tprintf(\" %*d %02d\",\n \t\t\t\t       max_score_digits, ent->score,\n@@ -1689,9 +1695,14 @@ static void emit_other(struct scoreboard *sb, struct blame_entry *ent, int opt)\n \t\t\t\t       ent->s_lno + 1 + cnt);\n \n \t\t\tif (!(opt & OUTPUT_NO_AUTHOR)) {\n-\t\t\t\tint pad = longest_author - utf8_strwidth(ci.author);\n+\t\t\t\tchar *name;\n+\t\t\t\tif (opt & OUTPUT_SHOW_EMAIL)\n+\t\t\t\t\tname = ci.author_mail;\n+\t\t\t\telse\n+\t\t\t\t\tname = ci.author;\n+\t\t\t\tint pad = longest_author - utf8_strwidth(name);\n \t\t\t\tprintf(\" (%s%*s %10s\",\n-\t\t\t\t       ci.author, pad, \"\",\n+\t\t\t\t       name, pad, \"\",\n \t\t\t\t       format_time(ci.author_time,\n \t\t\t\t\t\t   ci.author_tz,\n \t\t\t\t\t\t   show_raw_time));\n@@ -1829,7 +1840,10 @@ static void find_alignment(struct scoreboard *sb, int *option)\n \t\tif (!(suspect->commit->object.flags & METAINFO_SHOWN)) {\n \t\t\tsuspect->commit->object.flags |= METAINFO_SHOWN;\n \t\t\tget_commit_info(suspect->commit, &ci, 1);\n-\t\t\tnum = utf8_strwidth(ci.author);\n+\t\t\tif (*option & OUTPUT_SHOW_EMAIL)\n+\t\t\t\tnum = utf8_strwidth(ci.author_mail);\n+\t\t\telse\n+\t\t\t\tnum = utf8_strwidth(ci.author);\n \t\t\tif (longest_author < num)\n \t\t\t\tlongest_author = num;\n \t\t}\n@@ -2278,6 +2292,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)\n \t\tOPT_BIT('t', NULL, &output_option, \"Show raw timestamp (Default: off)\", OUTPUT_RAW_TIMESTAMP),\n \t\tOPT_BIT('l', NULL, &output_option, \"Show long commit SHA1 (Default: off)\", OUTPUT_LONG_OBJECT_NAME),\n \t\tOPT_BIT('s', NULL, &output_option, \"Suppress author name and timestamp (Default: off)\", OUTPUT_NO_AUTHOR),\n+\t\tOPT_BIT('e', \"show-email\", &output_option, \"Show author email instead of name (Default: off)\", OUTPUT_SHOW_EMAIL),\n \t\tOPT_BIT('w', NULL, &xdl_opts, \"Ignore whitespace differences\", XDF_IGNORE_WHITESPACE),\n \t\tOPT_STRING('S', NULL, &revs_file, \"file\", \"Use revisions from <file> instead of calling git-rev-list\"),\n \t\tOPT_STRING(0, \"contents\", &contents_from, \"file\", \"Use <file>'s contents as the final image\"),\ndiff --git a/t/annotate-tests.sh b/t/annotate-tests.sh\nindex 4e37a66..32dd159 100644\n--- a/t/annotate-tests.sh\n+++ b/t/annotate-tests.sh\n@@ -42,7 +42,7 @@ test_expect_success \\\n     'echo \"1A quick brown fox jumps over the\" >file &&\n      echo \"lazy dog\" >>file &&\n      git add file\n-     GIT_AUTHOR_NAME=\"A\" git commit -a -m \"Initial.\"'\n+     GIT_AUTHOR_NAME=\"A\" GIT_AUTHOR_EMAIL=\"A@test.git\" git commit -a -m \"Initial.\"'\n \n test_expect_success \\\n     'check all lines blamed on A' \\\n@@ -52,7 +52,7 @@ test_expect_success \\\n     'Setup new lines blamed on B' \\\n     'echo \"2A quick brown fox jumps over the\" >>file &&\n      echo \"lazy dog\" >> file &&\n-     GIT_AUTHOR_NAME=\"B\" git commit -a -m \"Second.\"'\n+     GIT_AUTHOR_NAME=\"B\" GIT_AUTHOR_EMAIL=\"B@test.git\" git commit -a -m \"Second.\"'\n \n test_expect_success \\\n     'Two lines blamed on A, two on B' \\\n@@ -63,7 +63,7 @@ test_expect_success \\\n     'git checkout -b branch1 master &&\n      echo \"3A slow green fox jumps into the\" >> file &&\n      echo \"well.\" >> file &&\n-     GIT_AUTHOR_NAME=\"B1\" git commit -a -m \"Branch1-1\"'\n+     GIT_AUTHOR_NAME=\"B1\" GIT_AUTHOR_EMAIL=\"B1@test.git\" git commit -a -m \"Branch1-1\"'\n \n test_expect_success \\\n     'Two lines blamed on A, two on B, two on B1' \\\n@@ -74,7 +74,7 @@ test_expect_success \\\n     'git checkout -b branch2 master &&\n      sed -e \"s/2A quick brown/4A quick brown lazy dog/\" < file > file.new &&\n      mv file.new file &&\n-     GIT_AUTHOR_NAME=\"B2\" git commit -a -m \"Branch2-1\"'\n+     GIT_AUTHOR_NAME=\"B2\" GIT_AUTHOR_EMAIL=\"B2@test.git\" git commit -a -m \"Branch2-1\"'\n \n test_expect_success \\\n     'Two lines blamed on A, one on B, one on B2' \\\n@@ -108,7 +108,7 @@ test_expect_success \\\n test_expect_success \\\n     'an incomplete line added' \\\n     'echo \"incomplete\" | tr -d \"\\\\012\" >>file &&\n-    GIT_AUTHOR_NAME=\"C\" git commit -a -m \"Incomplete\"'\n+    GIT_AUTHOR_NAME=\"C\" GIT_AUTHOR_EMAIL=\"C@test.git\" git commit -a -m \"Incomplete\"'\n \n test_expect_success \\\n     'With incomplete lines.' \\\n@@ -122,7 +122,7 @@ test_expect_success \\\n \techo\n     } | sed -e \"s/^3A/99/\" -e \"/^1A/d\" -e \"/^incomplete/d\" > file &&\n     echo \"incomplete\" | tr -d \"\\\\012\" >>file &&\n-    GIT_AUTHOR_NAME=\"D\" git commit -a -m \"edit\"'\n+    GIT_AUTHOR_NAME=\"D\" GIT_AUTHOR_EMAIL=\"D@test.git\" git commit -a -m \"edit\"'\n \n test_expect_success \\\n     'some edit' \\\ndiff --git a/t/t8002-blame.sh b/t/t8002-blame.sh\nindex 597cf04..d3a51e1 100755\n--- a/t/t8002-blame.sh\n+++ b/t/t8002-blame.sh\n@@ -6,4 +6,9 @@ test_description='git blame'\n PROG='git blame -c'\n . \"$TEST_DIRECTORY\"/annotate-tests.sh\n \n+PROG='git blame -c -e'\n+test_expect_success 'Blame --show-email works' '\n+    check_count \"<A@test.git>\" 1 \"<B@test.git>\" 1 \"<B1@test.git>\" 1 \"<B2@test.git>\" 1 \"<author@example.com>\" 1 \"<C@test.git>\" 1 \"<D@test.git>\" 1\n+'\n+\n test_done\n-- \n1.7.3.1.211.g4f60f\n"},{"id":"153812","messageId":"7vsk02ypj5.fsf@alter.siamese.dyndns.org","threadId":"25459","inReplyTo":"1287212271-23545-1-git-send-email-kevin@sb.org","subject":"Re: [PATCH] blame: Add option to show author email instead of name","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-10-19T19:02:22Z","receivedAt":"2010-10-19T19:02:22Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Kevin Ballard <kevin@sb.org> writes:\n\n> Add a new option -e (or --show-email) to git-blame that will display\n> the author's email instead of name on each line. This option works\n> for both git-blame and git-annotate.\n\nSome nits.\n\n    CC builtin/blame.o\ncc1: warnings being treated as errors\nbuiltin/blame.c: In function 'emit_other':\nbuiltin/blame.c:1678: error: assignment discards qualifiers from pointer target type\nbuiltin/blame.c:1680: error: assignment discards qualifiers from pointer target type\nbuiltin/blame.c:1700: error: assignment discards qualifiers from pointer target type\nbuiltin/blame.c:1702: error: assignment discards qualifiers from pointer target type\nbuiltin/blame.c:1703: error: ISO C90 forbids mixed declarations and code\nmake: *** [builtin/blame.o] Error 1\n\n builtin/blame.c |    7 ++++---\n 1 files changed, 4 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 0f0317c..df45e5c 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -1673,7 +1673,7 @@ static void emit_other(struct scoreboard *sb, struct blame_entry *ent, int opt)\n \n \t\tprintf(\"%.*s\", length, hex);\n \t\tif (opt & OUTPUT_ANNOTATE_COMPAT) {\n-\t\t\tchar *name;\n+\t\t\tconst char *name;\n \t\t\tif (opt & OUTPUT_SHOW_EMAIL)\n \t\t\t\tname = ci.author_mail;\n \t\t\telse\n@@ -1695,12 +1695,13 @@ static void emit_other(struct scoreboard *sb, struct blame_entry *ent, int opt)\n \t\t\t\t       ent->s_lno + 1 + cnt);\n \n \t\t\tif (!(opt & OUTPUT_NO_AUTHOR)) {\n-\t\t\t\tchar *name;\n+\t\t\t\tconst char *name;\n+\t\t\t\tint pad;\n \t\t\t\tif (opt & OUTPUT_SHOW_EMAIL)\n \t\t\t\t\tname = ci.author_mail;\n \t\t\t\telse\n \t\t\t\t\tname = ci.author;\n-\t\t\t\tint pad = longest_author - utf8_strwidth(name);\n+\t\t\t\tpad = longest_author - utf8_strwidth(name);\n \t\t\t\tprintf(\" (%s%*s %10s\",\n \t\t\t\t       name, pad, \"\",\n \t\t\t\t       format_time(ci.author_time,\n"},{"id":"153838","messageId":"1287535323-20347-1-git-send-email-kevin@sb.org","threadId":"25459","inReplyTo":"7vsk02ypj5.fsf@alter.siamese.dyndns.org","subject":"[PATCH v2] blame: Add option to show author email instead of name","fromName":"Kevin Ballard","fromEmail":"kevin@sb.org","sentAt":"2010-10-20T00:42:03Z","receivedAt":"2010-10-20T00:42:03Z","isPatch":true,"sender":{"key":"kevin@sb.org","avatar":"https://avatars.githubusercontent.com/u/714?v=4"},"body":"Add a new option -e (or --show-email) to git-blame that will display\nthe author's email instead of name on each line. This option works\nfor both git-blame and git-annotate.\n\nSigned-off-by: Kevin Ballard <kevin@sb.org>\n---\nThanks for the nitpicks. I should have caught those myself.\nI did notice that you had one more warning than I see when I compile;\nnamely, the ISO C90 warning. What did you set to get that? Both -ansi\nand -pedantic trigger other errors. I also checked CodingGuidelines\nand it doesn't mention what specific flags I should be passing to GCC\nfor things like this.\n\n Documentation/git-blame.txt |    6 +++++-\n builtin/blame.c             |   28 ++++++++++++++++++++++------\n t/annotate-tests.sh         |   12 ++++++------\n t/t8002-blame.sh            |    5 +++++\n 4 files changed, 38 insertions(+), 13 deletions(-)\n\ndiff --git a/Documentation/git-blame.txt b/Documentation/git-blame.txt\nindex a27f439..c71671b 100644\n--- a/Documentation/git-blame.txt\n+++ b/Documentation/git-blame.txt\n@@ -8,7 +8,7 @@ git-blame - Show what revision and author last modified each line of a file\n SYNOPSIS\n --------\n [verse]\n-'git blame' [-c] [-b] [-l] [--root] [-t] [-f] [-n] [-s] [-p] [-w] [--incremental] [-L n,m]\n+'git blame' [-c] [-b] [-l] [--root] [-t] [-f] [-n] [-s] [-e] [-p] [-w] [--incremental] [-L n,m]\n \t    [-S <revs-file>] [-M] [-C] [-C] [-C] [--since=<date>]\n \t    [<rev> | --contents <file> | --reverse <rev>] [--] <file>\n \n@@ -65,6 +65,10 @@ include::blame-options.txt[]\n -s::\n \tSuppress the author name and timestamp from the output.\n \n+-e::\n+--show-email::\n+\tShow the author email instead of author name (Default: off).\n+\n -w::\n \tIgnore whitespace when comparing the parent's version and\n \tthe child's to find where the lines came from.\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 1015354..df45e5c 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -1606,6 +1606,7 @@ static const char *format_time(unsigned long time, const char *tz_str,\n #define OUTPUT_SHOW_NUMBER\t040\n #define OUTPUT_SHOW_SCORE      0100\n #define OUTPUT_NO_AUTHOR       0200\n+#define OUTPUT_SHOW_EMAIL\t0400\n \n static void emit_porcelain(struct scoreboard *sb, struct blame_entry *ent)\n {\n@@ -1671,12 +1672,17 @@ static void emit_other(struct scoreboard *sb, struct blame_entry *ent, int opt)\n \t\t}\n \n \t\tprintf(\"%.*s\", length, hex);\n-\t\tif (opt & OUTPUT_ANNOTATE_COMPAT)\n-\t\t\tprintf(\"\\t(%10s\\t%10s\\t%d)\", ci.author,\n+\t\tif (opt & OUTPUT_ANNOTATE_COMPAT) {\n+\t\t\tconst char *name;\n+\t\t\tif (opt & OUTPUT_SHOW_EMAIL)\n+\t\t\t\tname = ci.author_mail;\n+\t\t\telse\n+\t\t\t\tname = ci.author;\n+\t\t\tprintf(\"\\t(%10s\\t%10s\\t%d)\", name,\n \t\t\t       format_time(ci.author_time, ci.author_tz,\n \t\t\t\t\t   show_raw_time),\n \t\t\t       ent->lno + 1 + cnt);\n-\t\telse {\n+\t\t} else {\n \t\t\tif (opt & OUTPUT_SHOW_SCORE)\n \t\t\t\tprintf(\" %*d %02d\",\n \t\t\t\t       max_score_digits, ent->score,\n@@ -1689,9 +1695,15 @@ static void emit_other(struct scoreboard *sb, struct blame_entry *ent, int opt)\n \t\t\t\t       ent->s_lno + 1 + cnt);\n \n \t\t\tif (!(opt & OUTPUT_NO_AUTHOR)) {\n-\t\t\t\tint pad = longest_author - utf8_strwidth(ci.author);\n+\t\t\t\tconst char *name;\n+\t\t\t\tint pad;\n+\t\t\t\tif (opt & OUTPUT_SHOW_EMAIL)\n+\t\t\t\t\tname = ci.author_mail;\n+\t\t\t\telse\n+\t\t\t\t\tname = ci.author;\n+\t\t\t\tpad = longest_author - utf8_strwidth(name);\n \t\t\t\tprintf(\" (%s%*s %10s\",\n-\t\t\t\t       ci.author, pad, \"\",\n+\t\t\t\t       name, pad, \"\",\n \t\t\t\t       format_time(ci.author_time,\n \t\t\t\t\t\t   ci.author_tz,\n \t\t\t\t\t\t   show_raw_time));\n@@ -1829,7 +1841,10 @@ static void find_alignment(struct scoreboard *sb, int *option)\n \t\tif (!(suspect->commit->object.flags & METAINFO_SHOWN)) {\n \t\t\tsuspect->commit->object.flags |= METAINFO_SHOWN;\n \t\t\tget_commit_info(suspect->commit, &ci, 1);\n-\t\t\tnum = utf8_strwidth(ci.author);\n+\t\t\tif (*option & OUTPUT_SHOW_EMAIL)\n+\t\t\t\tnum = utf8_strwidth(ci.author_mail);\n+\t\t\telse\n+\t\t\t\tnum = utf8_strwidth(ci.author);\n \t\t\tif (longest_author < num)\n \t\t\t\tlongest_author = num;\n \t\t}\n@@ -2278,6 +2293,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)\n \t\tOPT_BIT('t', NULL, &output_option, \"Show raw timestamp (Default: off)\", OUTPUT_RAW_TIMESTAMP),\n \t\tOPT_BIT('l', NULL, &output_option, \"Show long commit SHA1 (Default: off)\", OUTPUT_LONG_OBJECT_NAME),\n \t\tOPT_BIT('s', NULL, &output_option, \"Suppress author name and timestamp (Default: off)\", OUTPUT_NO_AUTHOR),\n+\t\tOPT_BIT('e', \"show-email\", &output_option, \"Show author email instead of name (Default: off)\", OUTPUT_SHOW_EMAIL),\n \t\tOPT_BIT('w', NULL, &xdl_opts, \"Ignore whitespace differences\", XDF_IGNORE_WHITESPACE),\n \t\tOPT_STRING('S', NULL, &revs_file, \"file\", \"Use revisions from <file> instead of calling git-rev-list\"),\n \t\tOPT_STRING(0, \"contents\", &contents_from, \"file\", \"Use <file>'s contents as the final image\"),\ndiff --git a/t/annotate-tests.sh b/t/annotate-tests.sh\nindex 141b60c..e0e5b8a 100644\n--- a/t/annotate-tests.sh\n+++ b/t/annotate-tests.sh\n@@ -39,7 +39,7 @@ test_expect_success \\\n     'echo \"1A quick brown fox jumps over the\" >file &&\n      echo \"lazy dog\" >>file &&\n      git add file\n-     GIT_AUTHOR_NAME=\"A\" git commit -a -m \"Initial.\"'\n+     GIT_AUTHOR_NAME=\"A\" GIT_AUTHOR_EMAIL=\"A@test.git\" git commit -a -m \"Initial.\"'\n \n test_expect_success \\\n     'check all lines blamed on A' \\\n@@ -49,7 +49,7 @@ test_expect_success \\\n     'Setup new lines blamed on B' \\\n     'echo \"2A quick brown fox jumps over the\" >>file &&\n      echo \"lazy dog\" >> file &&\n-     GIT_AUTHOR_NAME=\"B\" git commit -a -m \"Second.\"'\n+     GIT_AUTHOR_NAME=\"B\" GIT_AUTHOR_EMAIL=\"B@test.git\" git commit -a -m \"Second.\"'\n \n test_expect_success \\\n     'Two lines blamed on A, two on B' \\\n@@ -60,7 +60,7 @@ test_expect_success \\\n     'git checkout -b branch1 master &&\n      echo \"3A slow green fox jumps into the\" >> file &&\n      echo \"well.\" >> file &&\n-     GIT_AUTHOR_NAME=\"B1\" git commit -a -m \"Branch1-1\"'\n+     GIT_AUTHOR_NAME=\"B1\" GIT_AUTHOR_EMAIL=\"B1@test.git\" git commit -a -m \"Branch1-1\"'\n \n test_expect_success \\\n     'Two lines blamed on A, two on B, two on B1' \\\n@@ -71,7 +71,7 @@ test_expect_success \\\n     'git checkout -b branch2 master &&\n      sed -e \"s/2A quick brown/4A quick brown lazy dog/\" < file > file.new &&\n      mv file.new file &&\n-     GIT_AUTHOR_NAME=\"B2\" git commit -a -m \"Branch2-1\"'\n+     GIT_AUTHOR_NAME=\"B2\" GIT_AUTHOR_EMAIL=\"B2@test.git\" git commit -a -m \"Branch2-1\"'\n \n test_expect_success \\\n     'Two lines blamed on A, one on B, one on B2' \\\n@@ -105,7 +105,7 @@ test_expect_success \\\n test_expect_success \\\n     'an incomplete line added' \\\n     'echo \"incomplete\" | tr -d \"\\\\012\" >>file &&\n-    GIT_AUTHOR_NAME=\"C\" git commit -a -m \"Incomplete\"'\n+    GIT_AUTHOR_NAME=\"C\" GIT_AUTHOR_EMAIL=\"C@test.git\" git commit -a -m \"Incomplete\"'\n \n test_expect_success \\\n     'With incomplete lines.' \\\n@@ -119,7 +119,7 @@ test_expect_success \\\n \techo\n     } | sed -e \"s/^3A/99/\" -e \"/^1A/d\" -e \"/^incomplete/d\" > file &&\n     echo \"incomplete\" | tr -d \"\\\\012\" >>file &&\n-    GIT_AUTHOR_NAME=\"D\" git commit -a -m \"edit\"'\n+    GIT_AUTHOR_NAME=\"D\" GIT_AUTHOR_EMAIL=\"D@test.git\" git commit -a -m \"edit\"'\n \n test_expect_success \\\n     'some edit' \\\ndiff --git a/t/t8002-blame.sh b/t/t8002-blame.sh\nindex 597cf04..d3a51e1 100755\n--- a/t/t8002-blame.sh\n+++ b/t/t8002-blame.sh\n@@ -6,4 +6,9 @@ test_description='git blame'\n PROG='git blame -c'\n . \"$TEST_DIRECTORY\"/annotate-tests.sh\n \n+PROG='git blame -c -e'\n+test_expect_success 'Blame --show-email works' '\n+    check_count \"<A@test.git>\" 1 \"<B@test.git>\" 1 \"<B1@test.git>\" 1 \"<B2@test.git>\" 1 \"<author@example.com>\" 1 \"<C@test.git>\" 1 \"<D@test.git>\" 1\n+'\n+\n test_done\n-- \n1.7.3.1.211.g4f60f\n"},{"id":"153986","messageId":"20101021180525.GA11501@burratino","threadId":"25459","inReplyTo":"1287535323-20347-1-git-send-email-kevin@sb.org","subject":"Re: [PATCH v2] blame: Add option to show author email instead of name","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-10-21T18:05:25Z","receivedAt":"2010-10-21T18:05:25Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Kevin Ballard wrote:\n\n> +++ b/t/t8002-blame.sh\n> @@ -6,4 +6,9 @@ test_description='git blame'\n>  PROG='git blame -c'\n>  . \"$TEST_DIRECTORY\"/annotate-tests.sh\n>  \n> +PROG='git blame -c -e'\n> +test_expect_success 'Blame --show-email works' '\n> +    check_count \"<A@test.git>\" 1 \"<B@test.git>\" 1 \"<B1@test.git>\" 1 \"<B2@test.git>\" 1 \"<author@example.com>\" 1 \"<C@test.git>\" 1 \"<D@test.git>\" 1\n> +'\n> +\n\nBonus nit: does this belong in annotate-tests.sh or does it only apply\nto \"git blame\" and not \"git annotate\"?  If the latter, a note in the\ncommit message would be helpful.\n\nThanks for your work.\n"},{"id":"154016","messageId":"79AB0864-E151-468E-9C86-EBCAD929938B@sb.org","threadId":"25459","inReplyTo":"20101021180525.GA11501@burratino","subject":"Re: [PATCH v2] blame: Add option to show author email instead of name","fromName":"Kevin Ballard","fromEmail":"kevin@sb.org","sentAt":"2010-10-21T20:28:57Z","receivedAt":"2010-10-21T20:28:57Z","isPatch":true,"sender":{"key":"kevin@sb.org","avatar":"https://avatars.githubusercontent.com/u/714?v=4"},"body":"On Oct 21, 2010, at 11:05 AM, Jonathan Nieder wrote:\n\n> Kevin Ballard wrote:\n> \n>> +++ b/t/t8002-blame.sh\n>> @@ -6,4 +6,9 @@ test_description='git blame'\n>> PROG='git blame -c'\n>> . \"$TEST_DIRECTORY\"/annotate-tests.sh\n>> \n>> +PROG='git blame -c -e'\n>> +test_expect_success 'Blame --show-email works' '\n>> +    check_count \"<A@test.git>\" 1 \"<B@test.git>\" 1 \"<B1@test.git>\" 1 \"<B2@test.git>\" 1 \"<author@example.com>\" 1 \"<C@test.git>\" 1 \"<D@test.git>\" 1\n>> +'\n>> +\n> \n> Bonus nit: does this belong in annotate-tests.sh or does it only apply\n> to \"git blame\" and not \"git annotate\"?  If the latter, a note in the\n> commit message would be helpful.\n\n--show-email originally only applied to git-blame. I tweaked the patch to make it apply to git-annotate simply because check_count can't handle the format of git-blame, but the intention of the change wasn't to make it apply to git-annotate in the first place. You'll note I also didn't document it in the manpage for git-annotate. If you think it's better to move it into annotate-tests.sh, I can do that, but that does mean officially declaring git-annotate as supporting --show-email.\n\n-Kevin Ballard"},{"id":"154017","messageId":"20101021203210.GA12685@burratino","threadId":"25459","inReplyTo":"79AB0864-E151-468E-9C86-EBCAD929938B@sb.org","subject":"Re: [PATCH v2] blame: Add option to show author email instead of name","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-10-21T20:32:10Z","receivedAt":"2010-10-21T20:32:10Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Kevin Ballard wrote:\n> On Oct 21, 2010, at 11:05 AM, Jonathan Nieder wrote:\n\n>> Bonus nit: does this belong in annotate-tests.sh or does it only apply\n>> to \"git blame\" and not \"git annotate\"?  If the latter, a note in the\n>> commit message would be helpful.\n>\n> --show-email originally only applied to git-blame. I tweaked the\n> patch to make it apply to git-annotate simply because check_count\n> can't handle the format of git-blame, but the intention of the\n> change wasn't to make it apply to git-annotate in the first place.\n> You'll note I also didn't document it in the manpage for\n> git-annotate. If you think it's better to move it into\n> annotate-tests.sh, I can do that, but that does mean officially\n> declaring git-annotate as supporting --show-email.\n\nNo preference, since I never use \"git annotate\" myself.  In fact,\nlong term, I'd rather see a \"git blame --format=<template>\" appearing\nand \"git annotate\" replaced with a thin script wrapping \"git blame\".\n\nAnyway, whatever you decide, it would be nice to document it in the\ncommit message, no?  e.g.:\n\n\tThe tests and documentation only affect \"git blame\",\n\tbecause...\n"},{"id":"154020","messageId":"A4458F9B-04F5-42EF-86AB-6744E9DAE1C5@sb.org","threadId":"25459","inReplyTo":"20101021203210.GA12685@burratino","subject":"Re: [PATCH v2] blame: Add option to show author email instead of name","fromName":"Kevin Ballard","fromEmail":"kevin@sb.org","sentAt":"2010-10-21T20:38:17Z","receivedAt":"2010-10-21T20:38:17Z","isPatch":true,"sender":{"key":"kevin@sb.org","avatar":"https://avatars.githubusercontent.com/u/714?v=4"},"body":"On Oct 21, 2010, at 1:32 PM, Jonathan Nieder wrote:\n\n> Kevin Ballard wrote:\n>> On Oct 21, 2010, at 11:05 AM, Jonathan Nieder wrote:\n> \n>>> Bonus nit: does this belong in annotate-tests.sh or does it only apply\n>>> to \"git blame\" and not \"git annotate\"?  If the latter, a note in the\n>>> commit message would be helpful.\n>> \n>> --show-email originally only applied to git-blame. I tweaked the\n>> patch to make it apply to git-annotate simply because check_count\n>> can't handle the format of git-blame, but the intention of the\n>> change wasn't to make it apply to git-annotate in the first place.\n>> You'll note I also didn't document it in the manpage for\n>> git-annotate. If you think it's better to move it into\n>> annotate-tests.sh, I can do that, but that does mean officially\n>> declaring git-annotate as supporting --show-email.\n> \n> No preference, since I never use \"git annotate\" myself.  In fact,\n> long term, I'd rather see a \"git blame --format=<template>\" appearing\n> and \"git annotate\" replaced with a thin script wrapping \"git blame\".\n> \n> Anyway, whatever you decide, it would be nice to document it in the\n> commit message, no?  e.g.:\n> \n> \tThe tests and documentation only affect \"git blame\",\n> \tbecause...\n\nWill do.\n\n-Kevin Ballard\n"},{"id":"154022","messageId":"1287694162-71279-1-git-send-email-kevin@sb.org","threadId":"25459","inReplyTo":"20101021203210.GA12685@burratino","subject":"[PATCH v3] blame: Add option to show author email instead of name","fromName":"Kevin Ballard","fromEmail":"kevin@sb.org","sentAt":"2010-10-21T20:49:22Z","receivedAt":"2010-10-21T20:49:22Z","isPatch":true,"sender":{"key":"kevin@sb.org","avatar":"https://avatars.githubusercontent.com/u/714?v=4"},"body":"Add a new option -e (or --show-email) to git-blame that will display\nthe author's email instead of name on each line.\n\nNote that this option is supported on git-annotate, but there are no\ntests ensuring this, nor is it documented. The support in git-annotate\nonly exists because the tests for git-blame require the -c option\nand thus are really tests for git-annotate. This may change at a future\ndate.\n\nSigned-off-by: Kevin Ballard <kevin@sb.org>\n---\nThe only change here is the commit message, as requested by Jonathan Nieder.\n\n Documentation/git-blame.txt |    6 +++++-\n builtin/blame.c             |   28 ++++++++++++++++++++++------\n t/annotate-tests.sh         |   12 ++++++------\n t/t8002-blame.sh            |    5 +++++\n 4 files changed, 38 insertions(+), 13 deletions(-)\n\ndiff --git a/Documentation/git-blame.txt b/Documentation/git-blame.txt\nindex a27f439..c71671b 100644\n--- a/Documentation/git-blame.txt\n+++ b/Documentation/git-blame.txt\n@@ -8,7 +8,7 @@ git-blame - Show what revision and author last modified each line of a file\n SYNOPSIS\n --------\n [verse]\n-'git blame' [-c] [-b] [-l] [--root] [-t] [-f] [-n] [-s] [-p] [-w] [--incremental] [-L n,m]\n+'git blame' [-c] [-b] [-l] [--root] [-t] [-f] [-n] [-s] [-e] [-p] [-w] [--incremental] [-L n,m]\n \t    [-S <revs-file>] [-M] [-C] [-C] [-C] [--since=<date>]\n \t    [<rev> | --contents <file> | --reverse <rev>] [--] <file>\n \n@@ -65,6 +65,10 @@ include::blame-options.txt[]\n -s::\n \tSuppress the author name and timestamp from the output.\n \n+-e::\n+--show-email::\n+\tShow the author email instead of author name (Default: off).\n+\n -w::\n \tIgnore whitespace when comparing the parent's version and\n \tthe child's to find where the lines came from.\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 1015354..df45e5c 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -1606,6 +1606,7 @@ static const char *format_time(unsigned long time, const char *tz_str,\n #define OUTPUT_SHOW_NUMBER\t040\n #define OUTPUT_SHOW_SCORE      0100\n #define OUTPUT_NO_AUTHOR       0200\n+#define OUTPUT_SHOW_EMAIL\t0400\n \n static void emit_porcelain(struct scoreboard *sb, struct blame_entry *ent)\n {\n@@ -1671,12 +1672,17 @@ static void emit_other(struct scoreboard *sb, struct blame_entry *ent, int opt)\n \t\t}\n \n \t\tprintf(\"%.*s\", length, hex);\n-\t\tif (opt & OUTPUT_ANNOTATE_COMPAT)\n-\t\t\tprintf(\"\\t(%10s\\t%10s\\t%d)\", ci.author,\n+\t\tif (opt & OUTPUT_ANNOTATE_COMPAT) {\n+\t\t\tconst char *name;\n+\t\t\tif (opt & OUTPUT_SHOW_EMAIL)\n+\t\t\t\tname = ci.author_mail;\n+\t\t\telse\n+\t\t\t\tname = ci.author;\n+\t\t\tprintf(\"\\t(%10s\\t%10s\\t%d)\", name,\n \t\t\t       format_time(ci.author_time, ci.author_tz,\n \t\t\t\t\t   show_raw_time),\n \t\t\t       ent->lno + 1 + cnt);\n-\t\telse {\n+\t\t} else {\n \t\t\tif (opt & OUTPUT_SHOW_SCORE)\n \t\t\t\tprintf(\" %*d %02d\",\n \t\t\t\t       max_score_digits, ent->score,\n@@ -1689,9 +1695,15 @@ static void emit_other(struct scoreboard *sb, struct blame_entry *ent, int opt)\n \t\t\t\t       ent->s_lno + 1 + cnt);\n \n \t\t\tif (!(opt & OUTPUT_NO_AUTHOR)) {\n-\t\t\t\tint pad = longest_author - utf8_strwidth(ci.author);\n+\t\t\t\tconst char *name;\n+\t\t\t\tint pad;\n+\t\t\t\tif (opt & OUTPUT_SHOW_EMAIL)\n+\t\t\t\t\tname = ci.author_mail;\n+\t\t\t\telse\n+\t\t\t\t\tname = ci.author;\n+\t\t\t\tpad = longest_author - utf8_strwidth(name);\n \t\t\t\tprintf(\" (%s%*s %10s\",\n-\t\t\t\t       ci.author, pad, \"\",\n+\t\t\t\t       name, pad, \"\",\n \t\t\t\t       format_time(ci.author_time,\n \t\t\t\t\t\t   ci.author_tz,\n \t\t\t\t\t\t   show_raw_time));\n@@ -1829,7 +1841,10 @@ static void find_alignment(struct scoreboard *sb, int *option)\n \t\tif (!(suspect->commit->object.flags & METAINFO_SHOWN)) {\n \t\t\tsuspect->commit->object.flags |= METAINFO_SHOWN;\n \t\t\tget_commit_info(suspect->commit, &ci, 1);\n-\t\t\tnum = utf8_strwidth(ci.author);\n+\t\t\tif (*option & OUTPUT_SHOW_EMAIL)\n+\t\t\t\tnum = utf8_strwidth(ci.author_mail);\n+\t\t\telse\n+\t\t\t\tnum = utf8_strwidth(ci.author);\n \t\t\tif (longest_author < num)\n \t\t\t\tlongest_author = num;\n \t\t}\n@@ -2278,6 +2293,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)\n \t\tOPT_BIT('t', NULL, &output_option, \"Show raw timestamp (Default: off)\", OUTPUT_RAW_TIMESTAMP),\n \t\tOPT_BIT('l', NULL, &output_option, \"Show long commit SHA1 (Default: off)\", OUTPUT_LONG_OBJECT_NAME),\n \t\tOPT_BIT('s', NULL, &output_option, \"Suppress author name and timestamp (Default: off)\", OUTPUT_NO_AUTHOR),\n+\t\tOPT_BIT('e', \"show-email\", &output_option, \"Show author email instead of name (Default: off)\", OUTPUT_SHOW_EMAIL),\n \t\tOPT_BIT('w', NULL, &xdl_opts, \"Ignore whitespace differences\", XDF_IGNORE_WHITESPACE),\n \t\tOPT_STRING('S', NULL, &revs_file, \"file\", \"Use revisions from <file> instead of calling git-rev-list\"),\n \t\tOPT_STRING(0, \"contents\", &contents_from, \"file\", \"Use <file>'s contents as the final image\"),\ndiff --git a/t/annotate-tests.sh b/t/annotate-tests.sh\nindex 141b60c..e0e5b8a 100644\n--- a/t/annotate-tests.sh\n+++ b/t/annotate-tests.sh\n@@ -39,7 +39,7 @@ test_expect_success \\\n     'echo \"1A quick brown fox jumps over the\" >file &&\n      echo \"lazy dog\" >>file &&\n      git add file\n-     GIT_AUTHOR_NAME=\"A\" git commit -a -m \"Initial.\"'\n+     GIT_AUTHOR_NAME=\"A\" GIT_AUTHOR_EMAIL=\"A@test.git\" git commit -a -m \"Initial.\"'\n \n test_expect_success \\\n     'check all lines blamed on A' \\\n@@ -49,7 +49,7 @@ test_expect_success \\\n     'Setup new lines blamed on B' \\\n     'echo \"2A quick brown fox jumps over the\" >>file &&\n      echo \"lazy dog\" >> file &&\n-     GIT_AUTHOR_NAME=\"B\" git commit -a -m \"Second.\"'\n+     GIT_AUTHOR_NAME=\"B\" GIT_AUTHOR_EMAIL=\"B@test.git\" git commit -a -m \"Second.\"'\n \n test_expect_success \\\n     'Two lines blamed on A, two on B' \\\n@@ -60,7 +60,7 @@ test_expect_success \\\n     'git checkout -b branch1 master &&\n      echo \"3A slow green fox jumps into the\" >> file &&\n      echo \"well.\" >> file &&\n-     GIT_AUTHOR_NAME=\"B1\" git commit -a -m \"Branch1-1\"'\n+     GIT_AUTHOR_NAME=\"B1\" GIT_AUTHOR_EMAIL=\"B1@test.git\" git commit -a -m \"Branch1-1\"'\n \n test_expect_success \\\n     'Two lines blamed on A, two on B, two on B1' \\\n@@ -71,7 +71,7 @@ test_expect_success \\\n     'git checkout -b branch2 master &&\n      sed -e \"s/2A quick brown/4A quick brown lazy dog/\" < file > file.new &&\n      mv file.new file &&\n-     GIT_AUTHOR_NAME=\"B2\" git commit -a -m \"Branch2-1\"'\n+     GIT_AUTHOR_NAME=\"B2\" GIT_AUTHOR_EMAIL=\"B2@test.git\" git commit -a -m \"Branch2-1\"'\n \n test_expect_success \\\n     'Two lines blamed on A, one on B, one on B2' \\\n@@ -105,7 +105,7 @@ test_expect_success \\\n test_expect_success \\\n     'an incomplete line added' \\\n     'echo \"incomplete\" | tr -d \"\\\\012\" >>file &&\n-    GIT_AUTHOR_NAME=\"C\" git commit -a -m \"Incomplete\"'\n+    GIT_AUTHOR_NAME=\"C\" GIT_AUTHOR_EMAIL=\"C@test.git\" git commit -a -m \"Incomplete\"'\n \n test_expect_success \\\n     'With incomplete lines.' \\\n@@ -119,7 +119,7 @@ test_expect_success \\\n \techo\n     } | sed -e \"s/^3A/99/\" -e \"/^1A/d\" -e \"/^incomplete/d\" > file &&\n     echo \"incomplete\" | tr -d \"\\\\012\" >>file &&\n-    GIT_AUTHOR_NAME=\"D\" git commit -a -m \"edit\"'\n+    GIT_AUTHOR_NAME=\"D\" GIT_AUTHOR_EMAIL=\"D@test.git\" git commit -a -m \"edit\"'\n \n test_expect_success \\\n     'some edit' \\\ndiff --git a/t/t8002-blame.sh b/t/t8002-blame.sh\nindex 597cf04..d3a51e1 100755\n--- a/t/t8002-blame.sh\n+++ b/t/t8002-blame.sh\n@@ -6,4 +6,9 @@ test_description='git blame'\n PROG='git blame -c'\n . \"$TEST_DIRECTORY\"/annotate-tests.sh\n \n+PROG='git blame -c -e'\n+test_expect_success 'Blame --show-email works' '\n+    check_count \"<A@test.git>\" 1 \"<B@test.git>\" 1 \"<B1@test.git>\" 1 \"<B2@test.git>\" 1 \"<author@example.com>\" 1 \"<C@test.git>\" 1 \"<D@test.git>\" 1\n+'\n+\n test_done\n-- \n1.7.3.1.220.g19a98\n"},{"id":"154023","messageId":"20101021205358.GA29377@sigill.intra.peff.net","threadId":"25459","inReplyTo":"20101021203210.GA12685@burratino","subject":"Re: [PATCH v2] blame: Add option to show author email instead of name","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-10-21T20:53:58Z","receivedAt":"2010-10-21T20:53:58Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Oct 21, 2010 at 03:32:10PM -0500, Jonathan Nieder wrote:\n\n> No preference, since I never use \"git annotate\" myself.  In fact,\n> long term, I'd rather see a \"git blame --format=<template>\" appearing\n> and \"git annotate\" replaced with a thin script wrapping \"git blame\".\n\nIsn't that what it is already?\n\n  $ grep blame builtin/annotate.c\n  return cmd_blame(argc + 1, nargv, prefix);\n\n-Peff\n"},{"id":"154024","messageId":"1D51CC29-0248-4C12-BD1B-4013434AEA03@sb.org","threadId":"25459","inReplyTo":"20101021205358.GA29377@sigill.intra.peff.net","subject":"Re: [PATCH v2] blame: Add option to show author email instead of name","fromName":"Kevin Ballard","fromEmail":"kevin@sb.org","sentAt":"2010-10-21T20:54:22Z","receivedAt":"2010-10-21T20:54:22Z","isPatch":true,"sender":{"key":"kevin@sb.org","avatar":"https://avatars.githubusercontent.com/u/714?v=4"},"body":"On Oct 21, 2010, at 1:53 PM, Jeff King wrote:\n\n> On Thu, Oct 21, 2010 at 03:32:10PM -0500, Jonathan Nieder wrote:\n> \n>> No preference, since I never use \"git annotate\" myself.  In fact,\n>> long term, I'd rather see a \"git blame --format=<template>\" appearing\n>> and \"git annotate\" replaced with a thin script wrapping \"git blame\".\n> \n> Isn't that what it is already?\n> \n>  $ grep blame builtin/annotate.c\n>  return cmd_blame(argc + 1, nargv, prefix);\n> \n> -Peff\n\nIIRC, git-annotate is equivalent to `git blame -c`, which is why the tests for git-blame\nare so useless (they're all tests for `git blame -c`, which makes them identical to the\ntests for git-annotate).\n\n-Kevin Ballard"},{"id":"154026","messageId":"20101021205859.GA29550@sigill.intra.peff.net","threadId":"25459","inReplyTo":"1D51CC29-0248-4C12-BD1B-4013434AEA03@sb.org","subject":"Re: [PATCH v2] blame: Add option to show author email instead of name","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-10-21T20:58:59Z","receivedAt":"2010-10-21T20:58:59Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Oct 21, 2010 at 01:54:22PM -0700, Kevin Ballard wrote:\n\n> > Isn't that what it is already?\n> > \n> >  $ grep blame builtin/annotate.c\n> >  return cmd_blame(argc + 1, nargv, prefix);\n> \n> IIRC, git-annotate is equivalent to `git blame -c`, which is why the\n> tests for git-blame are so useless (they're all tests for `git blame\n> -c`, which makes them identical to the tests for git-annotate).\n\nYeah, I believe that t8002 is totally redundant with t8001 these days. I\nwonder if we should just drop t8001 entirely.\n\nThe other blame tests use the \"native\" format. It would be nice to have\nsome --porcelain and --incremental tests, too, but I expect it is too\nboring for anyone to volunteer to work on. :)\n\n-Peff\n"}]}