{"thread":{"id":"34459","subject":"[PATCH 0/6] fix blame -L regression; add tests","startedAt":"2013-07-17T21:25:26Z","lastAt":"2013-07-22T17:25:04Z","messageCount":12,"participants":["Eric Sunshine","Thomas Rast","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":6},"messages":[{"id":"223610","messageId":"1374096332-7891-1-git-send-email-sunshine@sunshineco.com","threadId":"34459","inReplyTo":null,"subject":"[PATCH 0/6] fix blame -L regression; add tests","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2013-07-17T21:25:26Z","receivedAt":"2013-07-17T21:25:26Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"This series fixes a regression in \"blame -L X,-N\", adds blame -L tests,\nand makes minor documentation adjustments. The tests, in particular,\nwere motivated by the desire to revisit and continue working on [1]\nwhich extends git-blame to accept multiple -L's. That topic will need to\nextend blame -L tests, of which there were essentially none.\n\nPatches [2/6] (modernize style) and [3/6] (add blame -L tests) are\nintentionally independent of the \"git log -L\" topic (from earlier this\nyear) to which the other patches are related.  This independence should\nallow these two patches to graduate at their own pace without being tied\nto \"git log -L\".\n\n[1]: http://thread.gmane.org/gmane.comp.version-control.git/229755/\n\nEric Sunshine (6):\n  line-range: fix \"blame -L X,-N\" regression\n  t8001/t8002 (blame): modernize style\n  t8001/t8002 (blame): add blame -L tests\n  t8001/t8002 (blame): add blame -L :funcname tests\n  blame-options.txt: place each -L option variation on its own line\n  blame-options.txt: explain that -L <start> and <end> are optional\n\n Documentation/blame-options.txt |  10 +-\n line-range.c                    |   7 +\n t/annotate-tests.sh             | 363 ++++++++++++++++++++++++++++------------\n t/t8001-annotate.sh             |   6 +-\n t/t8002-blame.sh                |  12 +-\n 5 files changed, 283 insertions(+), 115 deletions(-)\n\n-- \n1.8.3.3.1016.g4f0baba\n"},{"id":"223611","messageId":"1374096332-7891-2-git-send-email-sunshine@sunshineco.com","threadId":"34459","inReplyTo":"1374096332-7891-1-git-send-email-sunshine@sunshineco.com","subject":"[PATCH 1/6] line-range: fix \"blame -L X,-N\" regression","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2013-07-17T21:25:27Z","receivedAt":"2013-07-17T21:25:27Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"\"blame -L X,-N\" is documented as blaming \"N lines ending at X\".  In\npractice, the behavior is achieved by swapping the two range endpoints\nif the second is less than the first.  25ed3412 (Refactor parse_loc;\n2013-03-28) broke this interpretation by removing the swapping code from\nblame.c and failing to add it to line-range.c along with other code\nrelocated from blame.c. Thus, such a range is effectively treated as\nempty.  Fix this regression.\n\nSigned-off-by: Eric Sunshine <sunshine@sunshineco.com>\n---\n line-range.c | 7 +++++++\n 1 file changed, 7 insertions(+)\n\ndiff --git a/line-range.c b/line-range.c\nindex 8faf943..3942475 100644\n--- a/line-range.c\n+++ b/line-range.c\n@@ -211,6 +211,8 @@ int parse_range_arg(const char *arg, nth_line_fn_t nth_line_cb,\n \t\t    void *cb_data, long lines, long *begin, long *end,\n \t\t    const char *path)\n {\n+\t*begin = *end = 0;\n+\n \tif (*arg == ':') {\n \t\targ = parse_range_funcname(arg, nth_line_cb, cb_data, lines, begin, end, path);\n \t\tif (!arg || *arg)\n@@ -226,6 +228,11 @@ int parse_range_arg(const char *arg, nth_line_fn_t nth_line_cb,\n \tif (*arg)\n \t\treturn -1;\n \n+\tif (*begin && *end && *end < *begin) {\n+\t\tlong tmp;\n+\t\ttmp = *end; *end = *begin; *begin = tmp;\n+\t}\n+\n \treturn 0;\n }\n \n-- \n1.8.3.3.1016.g4f0baba\n"},{"id":"223612","messageId":"1374096332-7891-3-git-send-email-sunshine@sunshineco.com","threadId":"34459","inReplyTo":"1374096332-7891-1-git-send-email-sunshine@sunshineco.com","subject":"[PATCH 2/6] t8001/t8002 (blame): modernize style","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2013-07-17T21:25:28Z","receivedAt":"2013-07-17T21:25:28Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"In particular,\n\n- indent with tabs\n- cuddle test description and opening body quote with test_expect_foo\n- normalize test descriptions and case\n- remove whitepsace following redirection operator\n- use standardized filenames (such as \"actual\", \"expected\")\n\nSigned-off-by: Eric Sunshine <sunshine@sunshineco.com>\n---\n t/annotate-tests.sh | 221 +++++++++++++++++++++++++++-------------------------\n t/t8001-annotate.sh |   6 +-\n t/t8002-blame.sh    |  12 ++-\n 3 files changed, 127 insertions(+), 112 deletions(-)\n\ndiff --git a/t/annotate-tests.sh b/t/annotate-tests.sh\nindex c56a77d..3aa6964 100644\n--- a/t/annotate-tests.sh\n+++ b/t/annotate-tests.sh\n@@ -2,11 +2,11 @@\n # sourced from t8001-annotate.sh and t8002-blame.sh.\n \n check_count () {\n-\thead=\n-\tcase \"$1\" in -h) head=\"$2\"; shift; shift ;; esac\n-\techo \"$PROG file $head\" >&4\n-\t$PROG file $head >.result || return 1\n-\tcat .result | perl -e '\n+\thead= &&\n+\tcase \"$1\" in -h) head=\"$2\"; shift; shift ;; esac &&\n+\techo \"$PROG file $head\" >&4 &&\n+\t$PROG file $head >actual &&\n+\tperl -e '\n \t\tmy %expect = (@ARGV);\n \t\tmy %count = map { $_ => 0 } keys %expect;\n \t\twhile (<STDIN>) {\n@@ -31,107 +31,114 @@ check_count () {\n \t\t\tprint STDERR \"Author $author (expected $value, attributed $count) $ok\\n\";\n \t\t}\n \t\texit($bad);\n-\t' \"$@\"\n+\t' \"$@\" <actual\n }\n \n-test_expect_success \\\n-    'prepare reference tree' \\\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_AUTHOR_EMAIL=\"A@test.git\" git commit -a -m \"Initial.\"'\n-\n-test_expect_success \\\n-    'check all lines blamed on A' \\\n-    'check_count A 2'\n-\n-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_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-    'check_count A 2 B 2'\n-\n-test_expect_success \\\n-    'merge-setup part 1' \\\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_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-    'check_count A 2 B 2 B1 2'\n-\n-test_expect_success \\\n-    'merge-setup part 2' \\\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_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-    'check_count A 2 B 1 B2 1'\n-\n-test_expect_success \\\n-    'merge-setup part 3' \\\n-    'git pull . branch1'\n-\n-test_expect_success \\\n-    'Two lines blamed on A, one on B, two on B1, one on B2' \\\n-    'check_count A 2 B 1 B1 2 B2 1'\n-\n-test_expect_success \\\n-    'Annotating an old revision works' \\\n-    'check_count -h master A 2 B 2'\n-\n-test_expect_success \\\n-    'Annotating an old revision works' \\\n-    'check_count -h master^ A 2'\n-\n-test_expect_success \\\n-    'merge-setup part 4' \\\n-    'echo \"evil merge.\" >>file &&\n-     git commit -a --amend'\n-\n-test_expect_success \\\n-    'Two lines blamed on A, one on B, two on B1, one on B2, one on A U Thor' \\\n-    'check_count A 2 B 1 B1 2 B2 1 \"A U Thor\" 1'\n-\n-test_expect_success \\\n-    'an incomplete line added' \\\n-    'echo \"incomplete\" | tr -d \"\\\\012\" >>file &&\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-    'check_count A 2 B 1 B1 2 B2 1 \"A U Thor\" 1 C 1'\n-\n-test_expect_success \\\n-    'some edit' \\\n-    'mv file file.orig &&\n-    {\n-\tcat file.orig &&\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_AUTHOR_EMAIL=\"D@test.git\" git commit -a -m \"edit\"'\n-\n-test_expect_success \\\n-    'some edit' \\\n-    'check_count A 1 B 1 B1 1 B2 1 \"A U Thor\" 1 C 1 D 1'\n-\n-test_expect_success \\\n-    'an obfuscated email added' \\\n-    'echo \"No robots allowed\" > file.new &&\n-     cat file >> file.new &&\n-     mv file.new file &&\n-     GIT_AUTHOR_NAME=\"E\" GIT_AUTHOR_EMAIL=\"E at test dot git\" git commit -a -m \"norobots\"'\n-\n-test_expect_success \\\n-    'obfuscated email parsed' \\\n-    'check_count A 1 B 1 B1 1 B2 1 \"A U Thor\" 1 C 1 D 1 E 1'\n+test_expect_success 'setup A lines' '\n+\techo \"1A quick brown fox jumps over the\" >file &&\n+\techo \"lazy dog\" >>file &&\n+\tgit add file &&\n+\tGIT_AUTHOR_NAME=\"A\" GIT_AUTHOR_EMAIL=\"A@test.git\" \\\n+\tgit commit -a -m \"Initial.\"\n+'\n+\n+test_expect_success 'blame 1 author' '\n+\tcheck_count A 2\n+'\n+\n+test_expect_success 'setup B lines' '\n+\techo \"2A quick brown fox jumps over the\" >>file &&\n+\techo \"lazy dog\" >>file &&\n+\tGIT_AUTHOR_NAME=\"B\" GIT_AUTHOR_EMAIL=\"B@test.git\" \\\n+\tgit commit -a -m \"Second.\"\n+'\n+\n+test_expect_success 'blame 2 authors' '\n+\tcheck_count A 2 B 2\n+'\n+\n+test_expect_success 'setup B1 lines (branch1)' '\n+\tgit checkout -b branch1 master &&\n+\techo \"3A slow green fox jumps into the\" >>file &&\n+\techo \"well.\" >>file &&\n+\tGIT_AUTHOR_NAME=\"B1\" GIT_AUTHOR_EMAIL=\"B1@test.git\" \\\n+\tgit commit -a -m \"Branch1-1\"\n+'\n+\n+test_expect_success 'blame 2 authors + 1 branch1 author' '\n+\tcheck_count A 2 B 2 B1 2\n+'\n+\n+test_expect_success 'setup B2 lines (branch2)' '\n+\tgit checkout -b branch2 master &&\n+\tsed -e \"s/2A quick brown/4A quick brown lazy dog/\" <file >file.new &&\n+\tmv file.new file &&\n+\tGIT_AUTHOR_NAME=\"B2\" GIT_AUTHOR_EMAIL=\"B2@test.git\" \\\n+\tgit commit -a -m \"Branch2-1\"\n+'\n+\n+test_expect_success 'blame 2 authors + 1 branch2 author' '\n+\tcheck_count A 2 B 1 B2 1\n+'\n+\n+test_expect_success 'merge branch1 & branch2' '\n+\tgit pull . branch1\n+'\n+\n+test_expect_success 'blame 2 authors + 2 merged-in authors' '\n+\tcheck_count A 2 B 1 B1 2 B2 1\n+'\n+\n+test_expect_success 'blame ancestor' '\n+\tcheck_count -h master A 2 B 2\n+'\n+\n+test_expect_success 'blame great-ancestor' '\n+\tcheck_count -h master^ A 2\n+'\n+\n+test_expect_success 'setup evil merge' '\n+\techo \"evil merge.\" >>file &&\n+\tgit commit -a --amend\n+'\n+\n+test_expect_success 'blame evil merge' '\n+\tcheck_count A 2 B 1 B1 2 B2 1 \"A U Thor\" 1\n+'\n+\n+test_expect_success 'setup incomplete line' '\n+\techo \"incomplete\" | tr -d \"\\\\012\" >>file &&\n+\tGIT_AUTHOR_NAME=\"C\" GIT_AUTHOR_EMAIL=\"C@test.git\" \\\n+\tgit commit -a -m \"Incomplete\"\n+'\n+\n+test_expect_success 'blame incomplete line' '\n+\tcheck_count A 2 B 1 B1 2 B2 1 \"A U Thor\" 1 C 1\n+'\n+\n+test_expect_success 'setup edits' '\n+\tmv file file.orig &&\n+\t{\n+\t\tcat file.orig &&\n+\t\techo\n+\t} | sed -e \"s/^3A/99/\" -e \"/^1A/d\" -e \"/^incomplete/d\" >file &&\n+\techo \"incomplete\" | tr -d \"\\\\012\" >>file &&\n+\tGIT_AUTHOR_NAME=\"D\" GIT_AUTHOR_EMAIL=\"D@test.git\" \\\n+\tgit commit -a -m \"edit\"\n+'\n+\n+test_expect_success 'blame edits' '\n+\tcheck_count A 1 B 1 B1 1 B2 1 \"A U Thor\" 1 C 1 D 1\n+'\n+\n+test_expect_success 'setup obfuscated email' '\n+\techo \"No robots allowed\" >file.new &&\n+\tcat file >>file.new &&\n+\tmv file.new file &&\n+\tGIT_AUTHOR_NAME=\"E\" GIT_AUTHOR_EMAIL=\"E at test dot git\" \\\n+\tgit commit -a -m \"norobots\"\n+'\n+\n+test_expect_success 'blame obfuscated email' '\n+\tcheck_count A 1 B 1 B1 1 B2 1 \"A U Thor\" 1 C 1 D 1 E 1\n+'\ndiff --git a/t/t8001-annotate.sh b/t/t8001-annotate.sh\nindex 41962f0..72176e4 100755\n--- a/t/t8001-annotate.sh\n+++ b/t/t8001-annotate.sh\n@@ -6,9 +6,9 @@ test_description='git annotate'\n PROG='git annotate'\n . \"$TEST_DIRECTORY\"/annotate-tests.sh\n \n-test_expect_success 'Annotating an old revision works' '\n-\tgit annotate file master >result &&\n-\tawk \"{ print \\$3; }\" <result >authors &&\n+test_expect_success 'annotate old revision' '\n+\tgit annotate file master >actual &&\n+\tawk \"{ print \\$3; }\" <actual >authors &&\n \ttest 2 = $(grep A <authors | wc -l) &&\n \ttest 2 = $(grep B <authors | wc -l)\n '\ndiff --git a/t/t8002-blame.sh b/t/t8002-blame.sh\nindex e2896cf..5cdf3f1 100755\n--- a/t/t8002-blame.sh\n+++ b/t/t8002-blame.sh\n@@ -7,8 +7,16 @@ 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 \"<E at test dot git>\" 1\n+test_expect_success 'blame --show-email' '\n+\tcheck_count \\\n+\t\t\"<A@test.git>\" 1 \\\n+\t\t\"<B@test.git>\" 1 \\\n+\t\t\"<B1@test.git>\" 1 \\\n+\t\t\"<B2@test.git>\" 1 \\\n+\t\t\"<author@example.com>\" 1 \\\n+\t\t\"<C@test.git>\" 1 \\\n+\t\t\"<D@test.git>\" 1 \\\n+\t\t\"<E at test dot git>\" 1\n '\n \n test_done\n-- \n1.8.3.3.1016.g4f0baba\n"},{"id":"223613","messageId":"1374096332-7891-4-git-send-email-sunshine@sunshineco.com","threadId":"34459","inReplyTo":"1374096332-7891-1-git-send-email-sunshine@sunshineco.com","subject":"[PATCH 3/6] t8001/t8002 (blame): add blame -L tests","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2013-07-17T21:25:29Z","receivedAt":"2013-07-17T21:25:29Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"With the exception of a couple \"corner case\" checks in t8003 (and some\nindirect tests in t4211 of -L parsing code shared by log -L), there is\nno systematic checking of blame -L.  Add tests to check blame -L\ndirectly.\n\nSigned-off-by: Eric Sunshine <sunshine@sunshineco.com>\n---\n t/annotate-tests.sh | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++--\n 1 file changed, 101 insertions(+), 3 deletions(-)\n\ndiff --git a/t/annotate-tests.sh b/t/annotate-tests.sh\nindex 3aa6964..b6a7478 100644\n--- a/t/annotate-tests.sh\n+++ b/t/annotate-tests.sh\n@@ -3,9 +3,17 @@\n \n check_count () {\n \thead= &&\n-\tcase \"$1\" in -h) head=\"$2\"; shift; shift ;; esac &&\n-\techo \"$PROG file $head\" >&4 &&\n-\t$PROG file $head >actual &&\n+\toptions= &&\n+\twhile :\n+\tdo\n+\t\tcase \"$1\" in\n+\t\t-h) head=\"$2\"; shift; shift ;;\n+\t\t-*) options=\"$options $1\"; shift ;;\n+\t\t*) break ;;\n+\t\tesac\n+\tdone &&\n+\techo \"$PROG $options file $head\" >&4 &&\n+\t$PROG $options file $head >actual &&\n \tperl -e '\n \t\tmy %expect = (@ARGV);\n \t\tmy %count = map { $_ => 0 } keys %expect;\n@@ -142,3 +150,93 @@ test_expect_success 'setup obfuscated email' '\n test_expect_success 'blame obfuscated email' '\n \tcheck_count A 1 B 1 B1 1 B2 1 \"A U Thor\" 1 C 1 D 1 E 1\n '\n+\n+test_expect_success 'blame -L 1 (all)' '\n+\tcheck_count -L1 A 1 B 1 B1 1 B2 1 \"A U Thor\" 1 C 1 D 1 E 1\n+'\n+\n+test_expect_success 'blame -L , (all)' '\n+\tcheck_count -L, A 1 B 1 B1 1 B2 1 \"A U Thor\" 1 C 1 D 1 E 1\n+'\n+\n+test_expect_success 'blame -L X (X to end)' '\n+\tcheck_count -L5 B1 1 C 1 D 1 \"A U Thor\" 1\n+'\n+\n+test_expect_success 'blame -L X, (X to end)' '\n+\tcheck_count -L5, B1 1 C 1 D 1 \"A U Thor\" 1\n+'\n+\n+test_expect_success 'blame -L ,Y (up to Y)' '\n+\tcheck_count -L,3 A 1 B2 1 E 1\n+'\n+\n+test_expect_success 'blame -L X,X' '\n+\tcheck_count -L3,3 B2 1\n+'\n+\n+test_expect_success 'blame -L X,Y' '\n+\tcheck_count -L3,6 B 1 B1 1 B2 1 D 1\n+'\n+\n+test_expect_success 'blame -L Y,X (undocumented)' '\n+\tcheck_count -L6,3 B 1 B1 1 B2 1 D 1\n+'\n+\n+test_expect_success 'blame -L X,+1' '\n+\tcheck_count -L3,+1 B2 1\n+'\n+\n+test_expect_success 'blame -L X,+N' '\n+\tcheck_count -L3,+4 B 1 B1 1 B2 1 D 1\n+'\n+\n+test_expect_success 'blame -L X,-1' '\n+\tcheck_count -L3,-1 B2 1\n+'\n+\n+test_expect_success 'blame -L X,-N' '\n+\tcheck_count -L6,-4 B 1 B1 1 B2 1 D 1\n+'\n+\n+test_expect_success 'blame -L /RE/ (RE to end)' '\n+\tcheck_count -L/evil/ C 1 \"A U Thor\" 1\n+'\n+\n+test_expect_success 'blame -L /RE/,/RE2/' '\n+\tcheck_count -L/robot/,/green/ A 1 B 1 B2 1 D 1 E 1\n+'\n+\n+test_expect_success 'blame -L X,/RE/' '\n+\tcheck_count -L5,/evil/ B1 1 D 1 \"A U Thor\" 1\n+'\n+\n+test_expect_success 'blame -L /RE/,Y' '\n+\tcheck_count -L/99/,7 B1 1 D 1 \"A U Thor\" 1\n+'\n+\n+test_expect_success 'blame -L /RE/,+N' '\n+\tcheck_count -L/99/,+3 B1 1 D 1 \"A U Thor\" 1\n+'\n+\n+test_expect_success 'blame -L /RE/,-N' '\n+\tcheck_count -L/99/,-3 B 1 B2 1 D 1\n+'\n+\n+test_expect_success 'blame -L X (X > nlines)' '\n+\ttest_must_fail $PROG -L12345 file\n+'\n+\n+test_expect_success 'blame -L ,Y (Y > nlines)' '\n+\ttest_must_fail $PROG -L,12345 file\n+'\n+\n+test_expect_success 'blame -L bogus' '\n+\ttest_must_fail $PROG -L file &&\n+\ttest_must_fail $PROG -L1,+ file &&\n+\ttest_must_fail $PROG -L1,- file &&\n+\ttest_must_fail $PROG -LX file &&\n+\ttest_must_fail $PROG -L1,X file &&\n+\ttest_must_fail $PROG -L1,+N file &&\n+\ttest_must_fail $PROG -L1,-N file\n+'\n-- \n1.8.3.3.1016.g4f0baba\n"},{"id":"223614","messageId":"1374096332-7891-5-git-send-email-sunshine@sunshineco.com","threadId":"34459","inReplyTo":"1374096332-7891-1-git-send-email-sunshine@sunshineco.com","subject":"[PATCH 4/6] t8001/t8002 (blame): add blame -L :funcname tests","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2013-07-17T21:25:30Z","receivedAt":"2013-07-17T21:25:30Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"git-blame inherited \"-L :funcname\" support when \"-L :funcname:file\" was\nimplemented for git-log. Add tests.\n\nSigned-off-by: Eric Sunshine <sunshine@sunshineco.com>\n---\n t/annotate-tests.sh | 48 ++++++++++++++++++++++++++++++++++++++++++++++--\n 1 file changed, 46 insertions(+), 2 deletions(-)\n\ndiff --git a/t/annotate-tests.sh b/t/annotate-tests.sh\nindex b6a7478..0bfee00 100644\n--- a/t/annotate-tests.sh\n+++ b/t/annotate-tests.sh\n@@ -3,17 +3,19 @@\n \n check_count () {\n \thead= &&\n+\tfile='file' &&\n \toptions= &&\n \twhile :\n \tdo\n \t\tcase \"$1\" in\n \t\t-h) head=\"$2\"; shift; shift ;;\n+\t\t-f) file=\"$2\"; shift; shift ;;\n \t\t-*) options=\"$options $1\"; shift ;;\n \t\t*) break ;;\n \t\tesac\n \tdone &&\n-\techo \"$PROG $options file $head\" >&4 &&\n-\t$PROG $options file $head >actual &&\n+\techo \"$PROG $options $file $head\" >&4 &&\n+\t$PROG $options $file $head >actual &&\n \tperl -e '\n \t\tmy %expect = (@ARGV);\n \t\tmy %count = map { $_ => 0 } keys %expect;\n@@ -231,6 +233,48 @@ test_expect_success 'blame -L ,Y (Y > nlines)' '\n \ttest_must_fail $PROG -L,12345 file\n '\n \n+test_expect_success 'setup -L :regex' '\n+\ttr Q \"\\\\t\" >hello.c <<-\\EOF &&\n+\tint main(int argc, const char *argv[])\n+\t{\n+\tQputs(\"hello\");\n+\t}\n+\tEOF\n+\tgit add hello.c &&\n+\tGIT_AUTHOR_NAME=\"F\" GIT_AUTHOR_EMAIL=\"F@test.git\" \\\n+\tgit commit -m \"hello\" &&\n+\n+\tmv hello.c hello.orig &&\n+\tsed -e \"/}/i\\\\\n+\tQputs(\\\"goodbye\\\");\" <hello.orig | tr Q \"\\\\t\" >hello.c &&\n+\tGIT_AUTHOR_NAME=\"G\" GIT_AUTHOR_EMAIL=\"G@test.git\" \\\n+\tgit commit -a -m \"goodbye\" &&\n+\n+\tmv hello.c hello.orig &&\n+\techo \"#include <stdio.h>\" >hello.c &&\n+\tcat hello.orig >>hello.c &&\n+\ttr Q \"\\\\t\" >>hello.c <<-\\EOF\n+\tvoid mail()\n+\t{\n+\tQputs(\"mail\");\n+\t}\n+\tEOF\n+\tGIT_AUTHOR_NAME=\"H\" GIT_AUTHOR_EMAIL=\"H@test.git\" \\\n+\tgit commit -a -m \"mail\"\n+'\n+\n+test_expect_success 'blame -L :literal' '\n+\tcheck_count -f hello.c -L:main F 4 G 1\n+'\n+\n+test_expect_success 'blame -L :regex' '\n+\tcheck_count -f hello.c \"-L:m[a-z][a-z]l\" H 4\n+'\n+\n+test_expect_success 'blame -L :nomatch' '\n+\ttest_must_fail $PROG -L:nomatch hello.c\n+'\n+\n test_expect_success 'blame -L bogus' '\n \ttest_must_fail $PROG -L file &&\n \ttest_must_fail $PROG -L1,+ file &&\n-- \n1.8.3.3.1016.g4f0baba\n"},{"id":"223615","messageId":"1374096332-7891-6-git-send-email-sunshine@sunshineco.com","threadId":"34459","inReplyTo":"1374096332-7891-1-git-send-email-sunshine@sunshineco.com","subject":"[PATCH 5/6] blame-options.txt: place each -L option variation on its own line","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2013-07-17T21:25:31Z","receivedAt":"2013-07-17T21:25:31Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"Standard practice in Git documentation is for each variation of an\noption (such as: -p / --porcelain) to be placed on its own line in the\nOPTIONS table. The -L option does not follow suit. It cuddles\n\"-L <start>,<end>\" and \"-L :<regex>\", separated by a comma. This is\ninconsistent and potentially confusing since the comma separating them\nis typeset the same as the comma in \"<start>,<end>\". Fix this by placing\neach variation on its own line.\n\nSigned-off-by: Eric Sunshine <sunshine@sunshineco.com>\n---\n Documentation/blame-options.txt | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/Documentation/blame-options.txt b/Documentation/blame-options.txt\nindex e9f984b..624b353 100644\n--- a/Documentation/blame-options.txt\n+++ b/Documentation/blame-options.txt\n@@ -9,7 +9,8 @@\n --show-stats::\n \tInclude additional statistics at the end of blame output.\n \n--L <start>,<end>, -L :<regex>::\n+-L <start>,<end>::\n+-L :<regex>::\n \tAnnotate only the given line range.  <start> and <end> can take\n \tone of these forms:\n \n-- \n1.8.3.3.1016.g4f0baba\n"},{"id":"223616","messageId":"1374096332-7891-7-git-send-email-sunshine@sunshineco.com","threadId":"34459","inReplyTo":"1374096332-7891-1-git-send-email-sunshine@sunshineco.com","subject":"[PATCH 6/6] blame-options.txt: explain that -L <start> and <end> are optional","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2013-07-17T21:25:32Z","receivedAt":"2013-07-17T21:25:32Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"The ability to omit either end of the -L range is a handy but\nundocumented shortcut, and is thus not easily discovered. Fix this\nshortcoming.\n\nSigned-off-by: Eric Sunshine <sunshine@sunshineco.com>\n---\n Documentation/blame-options.txt | 7 +++++--\n 1 file changed, 5 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/blame-options.txt b/Documentation/blame-options.txt\nindex 624b353..4e55b15 100644\n--- a/Documentation/blame-options.txt\n+++ b/Documentation/blame-options.txt\n@@ -11,8 +11,11 @@\n \n -L <start>,<end>::\n -L :<regex>::\n-\tAnnotate only the given line range.  <start> and <end> can take\n-\tone of these forms:\n+\tAnnotate only the given line range.  <start> and <end> are optional.\n+\t``-L <start>'' or ``-L <start>,'' spans from <start> to end of file.\n+\t``-L ,<end>'' spans from start of file to <end>.\n++\n+<start> and <end> can take one of these forms:\n \n include::line-range-format.txt[]\n \n-- \n1.8.3.3.1016.g4f0baba\n"},{"id":"223640","messageId":"87hafs84jc.fsf@linux-k42r.v.cablecom.net","threadId":"34459","inReplyTo":"1374096332-7891-6-git-send-email-sunshine@sunshineco.com","subject":"Re: [PATCH 5/6] blame-options.txt: place each -L option variation on its own line","fromName":"Thomas Rast","fromEmail":"tr@thomasrast.ch","sentAt":"2013-07-18T11:56:55Z","receivedAt":"2013-07-18T11:56:55Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Eric Sunshine <sunshine@sunshineco.com> writes:\n\n> Standard practice in Git documentation is for each variation of an\n> option (such as: -p / --porcelain) to be placed on its own line in the\n> OPTIONS table. The -L option does not follow suit. It cuddles\n> \"-L <start>,<end>\" and \"-L :<regex>\", separated by a comma. This is\n> inconsistent and potentially confusing since the comma separating them\n> is typeset the same as the comma in \"<start>,<end>\". Fix this by placing\n> each variation on its own line.\n\nOk, but why not fix them all in one go?\n\nEdited to remove the false positives:\n\n$ git grep -n '^.*,.*::$' Documentation/*.txt\nDocumentation/blame-options.txt:12:-L <start>,<end>, -L :<regex>::\nDocumentation/config.txt:1252:gitcvs.dbuser, gitcvs.dbpass::\nDocumentation/config.txt:1513:http.lowSpeedLimit, http.lowSpeedTime::\nDocumentation/git-add.txt:90:-e, \\--edit::\nDocumentation/git-check-attr.txt:22:-a, --all::\nDocumentation/git-check-ignore.txt:26:-q, --quiet::\nDocumentation/git-check-ignore.txt:30:-v, --verbose::\nDocumentation/git-check-ignore.txt:42:-n, --non-matching::\nDocumentation/git-log.txt:65:-L <start>,<end>:<file>, -L :<regex>:<file>::\nDocumentation/git-log.txt:156:git log -L '/int main/',/^}/:main.c::\nDocumentation/git-p4.txt:171:--verbose, -v::\nDocumentation/git-p4.txt:282:--dry-run, -n::\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"223639","messageId":"87zjtk6pmo.fsf@linux-k42r.v.cablecom.net","threadId":"34459","inReplyTo":"1374096332-7891-1-git-send-email-sunshine@sunshineco.com","subject":"Re: [PATCH 0/6] fix blame -L regression; add tests","fromName":"Thomas Rast","fromEmail":"tr@thomasrast.ch","sentAt":"2013-07-18T12:04:15Z","receivedAt":"2013-07-18T12:04:15Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Eric Sunshine <sunshine@sunshineco.com> writes:\n\n> This series fixes a regression in \"blame -L X,-N\", adds blame -L tests,\n> and makes minor documentation adjustments. The tests, in particular,\n> were motivated by the desire to revisit and continue working on [1]\n> which extends git-blame to accept multiple -L's. That topic will need to\n> extend blame -L tests, of which there were essentially none.\n>\n> Patches [2/6] (modernize style) and [3/6] (add blame -L tests) are\n> intentionally independent of the \"git log -L\" topic (from earlier this\n> year) to which the other patches are related.  This independence should\n> allow these two patches to graduate at their own pace without being tied\n> to \"git log -L\".\n>\n> [1]: http://thread.gmane.org/gmane.comp.version-control.git/229755/\n>\n> Eric Sunshine (6):\n>   line-range: fix \"blame -L X,-N\" regression\n>   t8001/t8002 (blame): modernize style\n>   t8001/t8002 (blame): add blame -L tests\n>   t8001/t8002 (blame): add blame -L :funcname tests\n>   blame-options.txt: place each -L option variation on its own line\n>   blame-options.txt: explain that -L <start> and <end> are optional\n\nThanks, and except for the comment I just sent out,\nAcked-by: Thomas Rast <trast@inf.ethz.ch>\n\nIn case it wasn't obvious to anyone else: the tests do actually verify\nthat the right lines were picked, by counting how often each author is\nblamed.\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"223672","messageId":"7vvc473gfe.fsf@alter.siamese.dyndns.org","threadId":"34459","inReplyTo":"87hafs84jc.fsf@linux-k42r.v.cablecom.net","subject":"Re: [PATCH 5/6] blame-options.txt: place each -L option variation on its own line","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-07-18T17:51:17Z","receivedAt":"2013-07-18T17:51:17Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thomas Rast <tr@thomasrast.ch> writes:\n\n> Eric Sunshine <sunshine@sunshineco.com> writes:\n>\n>> Standard practice in Git documentation is for each variation of an\n>> option (such as: -p / --porcelain) to be placed on its own line in the\n>> OPTIONS table. The -L option does not follow suit. It cuddles\n>> \"-L <start>,<end>\" and \"-L :<regex>\", separated by a comma. This is\n>> inconsistent and potentially confusing since the comma separating them\n>> is typeset the same as the comma in \"<start>,<end>\". Fix this by placing\n>> each variation on its own line.\n>\n> Ok, but why not fix them all in one go?\n>\n> Edited to remove the false positives:\n>\n> $ git grep -n '^.*,.*::$' Documentation/*.txt\n> Documentation/blame-options.txt:12:-L <start>,<end>, -L :<regex>::\n> Documentation/config.txt:1252:gitcvs.dbuser, gitcvs.dbpass::\n> Documentation/config.txt:1513:http.lowSpeedLimit, http.lowSpeedTime::\n> Documentation/git-add.txt:90:-e, \\--edit::\n> Documentation/git-check-attr.txt:22:-a, --all::\n> Documentation/git-check-ignore.txt:26:-q, --quiet::\n> Documentation/git-check-ignore.txt:30:-v, --verbose::\n> Documentation/git-check-ignore.txt:42:-n, --non-matching::\n> Documentation/git-log.txt:65:-L <start>,<end>:<file>, -L :<regex>:<file>::\n> Documentation/git-log.txt:156:git log -L '/int main/',/^}/:main.c::\n> Documentation/git-p4.txt:171:--verbose, -v::\n> Documentation/git-p4.txt:282:--dry-run, -n::\n\nThanks, but I think it is cleaner to fix the others in a separate\n\"treewide clean-up\" patch.\n\nAlso I wonder if this one Documentation/git-log.txt:156\n\n    git log -L '/int main/',/^}/:main.c\n\nshould be more like one of these:\n\n    git log -L '/int main/,/^}/':main.c\n    git log -L '/int main/,/^}/:main.c'\n\nI find it somewhat hard to spot the closing sq in the middle of a\nstring.\n"},{"id":"223917","messageId":"87txjr4tzx.fsf@linux-k42r.v.cablecom.net","threadId":"34459","inReplyTo":"7vvc473gfe.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 5/6] blame-options.txt: place each -L option variation on its own line","fromName":"Thomas Rast","fromEmail":"trast@inf.ethz.ch","sentAt":"2013-07-22T10:38:49Z","receivedAt":"2013-07-22T10:38:49Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Also I wonder if this one Documentation/git-log.txt:156\n>\n>     git log -L '/int main/',/^}/:main.c\n>\n> should be more like one of these:\n>\n>     git log -L '/int main/,/^}/':main.c\n>     git log -L '/int main/,/^}/:main.c'\n>\n> I find it somewhat hard to spot the closing sq in the middle of a\n> string.\n\nThere's a distinct advantage to keeping the sq before the colon, at\nleast in my config (and I think I haven't changed the defaults as far as\nthis goes): bash will try to complete a filename if you type\n\n  git log -L '...':mai<TAB>\n\nbut not if you instead do\n\n  git log -L '...:'mai<TAB>\n\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"223928","messageId":"7vmwpecxsf.fsf@alter.siamese.dyndns.org","threadId":"34459","inReplyTo":"87txjr4tzx.fsf@linux-k42r.v.cablecom.net","subject":"Re: [PATCH 5/6] blame-options.txt: place each -L option variation on its own line","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-07-22T17:25:04Z","receivedAt":"2013-07-22T17:25:04Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thomas Rast <trast@inf.ethz.ch> writes:\n\n> Junio C Hamano <gitster@pobox.com> writes:\n>\n>> Also I wonder if this one Documentation/git-log.txt:156\n>>\n>>     git log -L '/int main/',/^}/:main.c\n>>\n>> should be more like one of these:\n>>\n>>     git log -L '/int main/,/^}/':main.c\n>>     git log -L '/int main/,/^}/:main.c'\n>>\n>> I find it somewhat hard to spot the closing sq in the middle of a\n>> string.\n>\n> There's a distinct advantage to keeping the sq before the colon, at\n> least in my config (and I think I haven't changed the defaults as far as\n> this goes): bash will try to complete a filename if you type\n>\n>   git log -L '...':mai<TAB>\n>\n> but not if you instead do\n>\n>   git log -L '...:'mai<TAB>\n\nInteresting.\n"}]}