{"thread":{"id":"3566","subject":"[PATCH] git-blame: Use the same tests for git-blame as for git-annotate","startedAt":"2006-03-05T11:13:34Z","lastAt":"2006-03-06T15:44:39Z","messageCount":19,"participants":["Fredrik Kuivinen","Ryan Anderson","Junio C Hamano","Martin Langhoff","A Large Angry SCM","Shawn Pearce","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"17183","messageId":"20060305111334.GB23448@c165.ib.student.liu.se","threadId":"3566","inReplyTo":null,"subject":"[PATCH] git-blame: Use the same tests for git-blame as for git-annotate","fromName":"Fredrik Kuivinen","fromEmail":"freku045@student.liu.se","sentAt":"2006-03-05T11:13:34Z","receivedAt":"2006-03-05T11:13:34Z","isPatch":true,"sender":{"key":"frekui@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13770967?v=4"},"body":"\nSigned-off-by: Fredrik Kuivinen <freku045@student.liu.se>\n\n\n---\n\n t/annotate-tests.sh |   86 +++++++++++++++++++++++++++++++++++++++++++++++++++\n t/t8001-annotate.sh |   85 +-------------------------------------------------\n t/t8002-blame.sh    |    9 +++++\n 3 files changed, 97 insertions(+), 83 deletions(-)\n create mode 100644 t/annotate-tests.sh\n create mode 100755 t/t8002-blame.sh\n\n06b0e500a5202899dcfd037cf78ee4a982da46b4\ndiff --git a/t/annotate-tests.sh b/t/annotate-tests.sh\nnew file mode 100644\nindex 0000000..54a4dfb\n--- /dev/null\n+++ b/t/annotate-tests.sh\n@@ -0,0 +1,86 @@\n+# This file isn't used as a test script directly, instead it is\n+# sourced from t8001-annotate.sh and t8001-blame.sh.\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 commit -a -m \"Initial.\"'\n+\n+test_expect_success \\\n+    'check all lines blamed on A' \\\n+    '[ $(git annotate file | awk \"{print \\$3}\" | grep -c \"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 commit -a -m \"Second.\"'\n+\n+test_expect_success \\\n+    'Two lines blamed on A' \\\n+    '[ $($PROG file | awk \"{print \\$3}\" | grep -c \"A\") == 2 ]'\n+\n+test_expect_success \\\n+    'Two lines blamed on B' \\\n+    '[ $($PROG file | awk \"{print \\$3}\" | grep -c \"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 commit -a -m \"Branch1-1\"'\n+\n+test_expect_success \\\n+    'Two lines blamed on A' \\\n+    '[ $($PROG file | awk \"{print \\$3}\" | grep -c \"^A$\") == 2 ]'\n+\n+test_expect_success \\\n+    'Two lines blamed on B' \\\n+    '[ $($PROG file | awk \"{print \\$3}\" | grep -c \"^B$\") == 2 ]'\n+\n+test_expect_success \\\n+    'Two lines blamed on B1' \\\n+    '[ $($PROG file | awk \"{print \\$3}\" | grep -c \"^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 commit -a -m \"Branch2-1\"'\n+\n+test_expect_success \\\n+    'Two lines blamed on A' \\\n+    '[ $($PROG file | awk \"{print \\$3}\" | grep -c \"^A$\") == 2 ]'\n+\n+test_expect_success \\\n+    'One line blamed on B' \\\n+    '[ $($PROG file | awk \"{print \\$3}\" | grep -c \"^B$\") == 1 ]'\n+\n+test_expect_success \\\n+    'One line blamed on B2' \\\n+    '[ $($PROG file | awk \"{print \\$3}\" | grep -c \"^B2$\") == 1 ]'\n+\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' \\\n+    '[ $($PROG file | awk \"{print \\$3}\" | grep -c \"^A$\") == 2 ]'\n+\n+test_expect_success \\\n+    'One line blamed on B' \\\n+    '[ $($PROG file | awk \"{print \\$3}\" | grep -c \"^B$\") == 1 ]'\n+\n+test_expect_success \\\n+    'Two lines blamed on B1' \\\n+    '[ $($PROG file | awk \"{print \\$3}\" | grep -c \"^B1$\") == 2 ]'\n+\n+test_expect_success \\\n+    'One line blamed on B2' \\\n+    '[ $($PROG file | awk \"{print \\$3}\" | grep -c \"^B2$\") == 1 ]'\ndiff --git a/t/t8001-annotate.sh b/t/t8001-annotate.sh\nindex 172908a..9e5a04b 100755\n--- a/t/t8001-annotate.sh\n+++ b/t/t8001-annotate.sh\n@@ -3,88 +3,7 @@\n test_description='git-annotate'\n . ./test-lib.sh\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 commit -a -m \"Initial.\"'\n-\n-test_expect_success \\\n-    'check all lines blamed on A' \\\n-    '[ $(git annotate file | awk \"{print \\$3}\" | grep -c \"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 commit -a -m \"Second.\"'\n-\n-test_expect_success \\\n-    'Two lines blamed on A' \\\n-    '[ $(git annotate file | awk \"{print \\$3}\" | grep -c \"A\") == 2 ]'\n-\n-test_expect_success \\\n-    'Two lines blamed on B' \\\n-    '[ $(git annotate file | awk \"{print \\$3}\" | grep -c \"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 commit -a -m \"Branch1-1\"'\n-\n-test_expect_success \\\n-    'Two lines blamed on A' \\\n-    '[ $(git annotate file | awk \"{print \\$3}\" | grep -c \"^A$\") == 2 ]'\n-\n-test_expect_success \\\n-    'Two lines blamed on B' \\\n-    '[ $(git annotate file | awk \"{print \\$3}\" | grep -c \"^B$\") == 2 ]'\n-\n-test_expect_success \\\n-    'Two lines blamed on B1' \\\n-    '[ $(git annotate file | awk \"{print \\$3}\" | grep -c \"^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 commit -a -m \"Branch2-1\"'\n-\n-test_expect_success \\\n-    'Two lines blamed on A' \\\n-    '[ $(git annotate file | awk \"{print \\$3}\" | grep -c \"^A$\") == 2 ]'\n-\n-test_expect_success \\\n-    'One line blamed on B' \\\n-    '[ $(git annotate file | awk \"{print \\$3}\" | grep -c \"^B$\") == 1 ]'\n-\n-test_expect_success \\\n-    'One line blamed on B2' \\\n-    '[ $(git annotate file | awk \"{print \\$3}\" | grep -c \"^B2$\") == 1 ]'\n-\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' \\\n-    '[ $(git annotate file | awk \"{print \\$3}\" | grep -c \"^A$\") == 2 ]'\n-\n-test_expect_success \\\n-    'One line blamed on B' \\\n-    '[ $(git annotate file | awk \"{print \\$3}\" | grep -c \"^B$\") == 1 ]'\n-\n-test_expect_success \\\n-    'Two lines blamed on B1' \\\n-    '[ $(git annotate file | awk \"{print \\$3}\" | grep -c \"^B1$\") == 2 ]'\n-\n-test_expect_success \\\n-    'One line blamed on B2' \\\n-    '[ $(git annotate file | awk \"{print \\$3}\" | grep -c \"^B2$\") == 1 ]'\n+PROG='git annotate'\n+source ../annotate-tests.sh\n \n test_done\ndiff --git a/t/t8002-blame.sh b/t/t8002-blame.sh\nnew file mode 100755\nindex 0000000..1036c54\n--- /dev/null\n+++ b/t/t8002-blame.sh\n@@ -0,0 +1,9 @@\n+#!/bin/sh\n+\n+test_description='git-blame'\n+. ./test-lib.sh\n+\n+PROG='git blame -c'\n+source ../annotate-tests.sh\n+\n+test_done\n-- \n1.2.4.g4644-dirty\n"},{"id":"17211","messageId":"440B751F.5000801@michonline.com","threadId":"3566","inReplyTo":"20060305111334.GB23448@c165.ib.student.liu.se","subject":"Re: [PATCH] git-blame: Use the same tests for git-blame as for git-annotate","fromName":"Ryan Anderson","fromEmail":"ryan@michonline.com","sentAt":"2006-03-05T23:32:47Z","receivedAt":"2006-03-05T23:32:47Z","isPatch":true,"sender":{"key":"ryan@michonline.com","avatar":null},"body":"\nAlong these lines, if anyone can pin down the complicated cases that\nannotate and blame get differently, adding them as a test would be\n*exceedingly* appreciated, even if it makes annotate (or blame) fail for\na bit, it gives us something to work against.\n\nI've been trying to find some time this weekend to dig into why annotate\ngets things wrong, but I've been distracted, unfortunately.\n\n\n-- \n\nRyan Anderson\n  sometimes Pug Majere\n\n"},{"id":"17213","messageId":"7vzmk4ctlj.fsf@assigned-by-dhcp.cox.net","threadId":"3566","inReplyTo":"440B751F.5000801@michonline.com","subject":"Re: [PATCH] git-blame: Use the same tests for git-blame as for git-annotate","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-03-06T00:19:52Z","receivedAt":"2006-03-06T00:19:52Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ryan Anderson <ryan@michonline.com> writes:\n\n> Along these lines, if anyone can pin down the complicated cases that\n> annotate and blame get differently, adding them as a test would be\n> *exceedingly* appreciated, even if it makes annotate (or blame) fail for\n> a bit, it gives us something to work against.\n\nIn the t/trash repository, \"git-annotate file master\" and\n\"git-annotate file master^\" behaves funkily.\n\nOTOH \"git-blame file master\" assigns everything to that commit\nwhile only the last two lines are attributable to it.  Needs a\nbit more work on both sides ;-).\n"},{"id":"17214","messageId":"46a038f90603051629ke34a0a6u89dad995bbd777b0@mail.gmail.com","threadId":"3566","inReplyTo":"440B751F.5000801@michonline.com","subject":"Re: [PATCH] git-blame: Use the same tests for git-blame as for git-annotate","fromName":"Martin Langhoff","fromEmail":"martin.langhoff@gmail.com","sentAt":"2006-03-06T00:29:32Z","receivedAt":"2006-03-06T00:29:32Z","isPatch":true,"sender":{"key":"martin.langhoff@gmail.com","avatar":"https://gravatar.com/avatar/1e3f311b6c4c15836501901ca58f8c0b0667246488084ba524d8bc9867e22fd9?d=mp&s=160"},"body":"On 3/6/06, Ryan Anderson <ryan@michonline.com> wrote:\n> Along these lines, if anyone can pin down the complicated cases that\n> annotate and blame get differently, adding them as a test would be\n> *exceedingly* appreciated, even if it makes annotate (or blame) fail for\n> a bit, it gives us something to work against.\n\nIt would be great if they both worked properly with paths that existed\nin the past. Right now, I can't git-annotate or git-blame a file I\nknow was there in a past revision. I think I had taught Johannes'\nannotate to deal with this, or at least intended to. As things stand,\ngit-annotate/git-blame need a checkout, which is really silly.\n\nTools like gitweb and cvsserver should be able to do:\n\n  GIT_DIR=/somebarerepo/git.git git-(annotate|blame) -h headname Makefile\n\nand not worry about creating a temporary index *and* checking out\nMakefile so that things work. That's what cvsserver does now, anyway.\nUgly :-(\n\ncheers,\n\n\n\nm\n"},{"id":"17225","messageId":"20060306024353.GA23001@mythryan2.michonline.com","threadId":"3566","inReplyTo":"46a038f90603051629ke34a0a6u89dad995bbd777b0@mail.gmail.com","subject":"[PATCH] annotate: Support annotation of files on other revisions.","fromName":"Ryan Anderson","fromEmail":"ryan@michonline.com","sentAt":"2006-03-06T02:43:53Z","receivedAt":"2006-03-06T02:43:53Z","isPatch":true,"sender":{"key":"ryan@michonline.com","avatar":null},"body":"\nThis is a bug fix, and cleans up one or two other things spotted during the\ncourse of tracking down the main bug here.\n\nAlso, the test-suite is updated to reflect this case.\n\nSigned-off-by: Ryan Anderson <ryan@michonline.com>\n\n---\n\n git-annotate.perl   |    7 +++++--\n t/t8001-annotate.sh |    6 ++++++\n 2 files changed, 11 insertions(+), 2 deletions(-)\n\nOn Mon, Mar 06, 2006 at 01:29:32PM +1300, Martin Langhoff wrote:\n> On 3/6/06, Ryan Anderson <ryan@michonline.com> wrote:\n> > Along these lines, if anyone can pin down the complicated cases that\n> > annotate and blame get differently, adding them as a test would be\n> > *exceedingly* appreciated, even if it makes annotate (or blame) fail for\n> > a bit, it gives us something to work against.\n> \n> It would be great if they both worked properly with paths that existed\n> in the past. Right now, I can't git-annotate or git-blame a file I\n> know was there in a past revision. I think I had taught Johannes'\n> annotate to deal with this, or at least intended to. As things stand,\n> git-annotate/git-blame need a checkout, which is really silly.\n\nannotate was *trying* to handle that cleanly, but failed due to a silly\nbug.  This is the same bug that Junio pointed out:\n\tcd t\n\t./t8001-annotate.sh\n\tcd trash\n\t../../git-annotate file master\n\nThis is fixed by the patch at the end of this email.\n\n> Tools like gitweb and cvsserver should be able to do:\n> \n>   GIT_DIR=/somebarerepo/git.git git-(annotate|blame) -h headname Makefile\n> \n> and not worry about creating a temporary index *and* checking out\n> Makefile so that things work. That's what cvsserver does now, anyway.\n> Ugly :-(\n\nFor annotate, the syntax I was using was:\n\tgit annotate Makefile headname\n\nI'm not married to it, so please, send a patch to change it if you want\n(Please fix up the test case I'm sending in this patch, as well.)\n\ncdd80fd28d300dd2400bf75ff64ae2bf1a8b92aa\ndiff --git a/git-annotate.perl b/git-annotate.perl\nindex d93ee19..5953ac6 100755\n--- a/git-annotate.perl\n+++ b/git-annotate.perl\n@@ -10,6 +10,7 @@ use warnings;\n use strict;\n use Getopt::Long;\n use POSIX qw(strftime gmtime);\n+use Data::Dumper;\n \n sub usage() {\n \tprint STDERR 'Usage: ${\\basename $0} [-s] [-S revs-file] file [ revision ]\n@@ -99,7 +100,7 @@ while (my $bound = pop @stack) {\n \t}\n }\n push @revqueue, $head;\n-init_claim( defined $starting_rev ? $starting_rev : 'dirty');\n+init_claim( defined $starting_rev ? $head : 'dirty');\n unless (defined $starting_rev) {\n \tmy $diff = open_pipe(\"git\",\"diff\",\"-R\", \"HEAD\", \"--\",$filename)\n \t\tor die \"Failed to call git diff to check for dirty state: $!\";\n@@ -345,6 +346,7 @@ sub git_cat_file {\n \treturn () unless defined $rev && defined $filename;\n \n \tmy $blob = git_ls_tree($rev, $filename);\n+\tdie \"Failed to find a blob for $filename in rev $rev\\n\" if !defined $blob;\n \n \tmy $catfile = open_pipe(\"git\",\"cat-file\", \"blob\", $blob)\n \t\tor die \"Failed to git-cat-file blob $blob (rev $rev, file $filename): \" . $!;\n@@ -367,12 +369,13 @@ sub git_ls_tree {\n \n \tmy ($mode, $type, $blob, $tfilename);\n \twhile(<$lstree>) {\n+\t\tchomp;\n \t\t($mode, $type, $blob, $tfilename) = split(/\\s+/, $_, 4);\n \t\tlast if ($tfilename eq $filename);\n \t}\n \tclose($lstree);\n \n-\treturn $blob if $filename eq $filename;\n+\treturn $blob if ($tfilename eq $filename);\n \tdie \"git-ls-tree failed to find blob for $filename\";\n \n }\ndiff --git a/t/t8001-annotate.sh b/t/t8001-annotate.sh\nindex 172908a..761d0bc 100755\n--- a/t/t8001-annotate.sh\n+++ b/t/t8001-annotate.sh\n@@ -87,4 +87,10 @@ test_expect_success \\\n     'One line blamed on B2' \\\n     '[ $(git annotate file | awk \"{print \\$3}\" | grep -c \"^B2$\") == 1 ]'\n \n+test_expect_success \\\n+    'Annotating an old revision works' \\\n+    '[ $(git annotate file master | awk \"{print \\$3}\" | grep -c \"^A$\") == 2 ] && \\\n+     [ $(git annotate file master | awk \"{print \\$3}\" | grep -c \"^B$\") == 2 ]'\n+\n+\n test_done\n-- \n1.2.4.g9201-dirty\n\n\n\n-- \n\nRyan Anderson\n  sometimes Pug Majere\n"},{"id":"17226","messageId":"440BA4DA.9060101@michonline.com","threadId":"3566","inReplyTo":"20060305111334.GB23448@c165.ib.student.liu.se","subject":"Re: [PATCH] git-blame: Use the same tests for git-blame as for git-annotate","fromName":"Ryan Anderson","fromEmail":"ryan@michonline.com","sentAt":"2006-03-06T02:56:26Z","receivedAt":"2006-03-06T02:56:26Z","isPatch":true,"sender":{"key":"ryan@michonline.com","avatar":null},"body":"Fredrik Kuivinen wrote:\n\n>Signed-off-by: Fredrik Kuivinen <freku045@student.liu.se>\n>\n>\n>---\n>\n> t/annotate-tests.sh |   86 +++++++++++++++++++++++++++++++++++++++++++++++++++\n> t/t8001-annotate.sh |   85 +-------------------------------------------------\n> t/t8002-blame.sh    |    9 +++++\n> 3 files changed, 97 insertions(+), 83 deletions(-)\n> create mode 100644 t/annotate-tests.sh\n> create mode 100755 t/t8002-blame.sh\n>\n>06b0e500a5202899dcfd037cf78ee4a982da46b4\n>diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh\n>new file mode 100644\n>index 0000000..54a4dfb\n>--- /dev/null\n>+++ b/t/annotate-tests.sh\n>@@ -0,0 +1,86 @@\n>+# This file isn't used as a test script directly, instead it is\n>+# sourced from t8001-annotate.sh and t8001-blame.sh.\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 commit -a -m \"Initial.\"'\n>+\n>+test_expect_success \\\n>+    'check all lines blamed on A' \\\n>+    '[ $(git annotate file | awk \"{print \\$3}\" | grep -c \"A\") == 2 ]'\n>  \n>\nThis should be $PROG as well, I suspect.\n\nAlso, we need to agree on a syntax for working on non-HEAD revisions.\n\n\"git annotate $file $commitish\" is what I had been using, but it's\nreally not something I feel strongly about.\n\n\n-- \n\nRyan Anderson\n  sometimes Pug Majere\n\n"},{"id":"17229","messageId":"46a038f90603052018n76d316eclf84b6921c9595f16@mail.gmail.com","threadId":"3566","inReplyTo":"20060306024353.GA23001@mythryan2.michonline.com","subject":"Re: [PATCH] annotate: Support annotation of files on other revisions.","fromName":"Martin Langhoff","fromEmail":"martin.langhoff@gmail.com","sentAt":"2006-03-06T04:18:35Z","receivedAt":"2006-03-06T04:18:35Z","isPatch":true,"sender":{"key":"martin.langhoff@gmail.com","avatar":"https://gravatar.com/avatar/1e3f311b6c4c15836501901ca58f8c0b0667246488084ba524d8bc9867e22fd9?d=mp&s=160"},"body":"On 3/6/06, Ryan Anderson <ryan@michonline.com> wrote:\n> annotate was *trying* to handle that cleanly, but failed due to a silly\n\nGreat stuff, thanks! I'll let it hit master and then I'll drop the\nmessy part of req_annotate() in cvsserver.\n\n> For annotate, the syntax I was using was:\n>         git annotate Makefile headname\n>\n> I'm not married to it, so please, send a patch to change it if you want\n> (Please fix up the test case I'm sending in this patch, as well.)\n\nThat's _perfect_. I was just making the syntax up.\n\ncheers,\n\n\nmartin\n"},{"id":"17232","messageId":"440BC92E.4060306@gmail.com","threadId":"3566","inReplyTo":"20060306024353.GA23001@mythryan2.michonline.com","subject":"Re: [PATCH] annotate: Support annotation of files on other revisions.","fromName":"A Large Angry SCM","fromEmail":"gitzilla@gmail.com","sentAt":"2006-03-06T05:31:26Z","receivedAt":"2006-03-06T05:31:26Z","isPatch":true,"sender":{"key":"gitzilla@gmail.com","avatar":"https://gravatar.com/avatar/354625c442439908ff3dd99757dee330e29e9df7847472384faf7a00add247fb?d=mp&s=160"},"body":"Ryan Anderson wrote:\n...\n> \n> For annotate, the syntax I was using was:\n> \tgit annotate Makefile headname\n> \n> I'm not married to it, so please, send a patch to change it if you want\n> (Please fix up the test case I'm sending in this patch, as well.)\n> \n\nWouldn't\n\tgit annotate <headname> <filename(s?)>\nbe more consistent with other git commands?\n"},{"id":"17234","messageId":"440BCB67.4070406@michonline.com","threadId":"3566","inReplyTo":"440BC92E.4060306@gmail.com","subject":"Re: [PATCH] annotate: Support annotation of files on other revisions.","fromName":"Ryan Anderson","fromEmail":"ryan@michonline.com","sentAt":"2006-03-06T05:40:55Z","receivedAt":"2006-03-06T05:40:55Z","isPatch":true,"sender":{"key":"ryan@michonline.com","avatar":null},"body":"A Large Angry SCM wrote:\n\n> Ryan Anderson wrote:\n> ...\n>\n>>\n>> For annotate, the syntax I was using was:\n>>     git annotate Makefile headname\n>>\n>> I'm not married to it, so please, send a patch to change it if you want\n>> (Please fix up the test case I'm sending in this patch, as well.)\n>>\n>\n> Wouldn't\n>     git annotate <headname> <filename(s?)>\n> be more consistent with other git commands?\n>\nYes, but <headname> (really, a commitish) needs to be optional.\n\nI should probably switch to:\n    git annotate [-c|--commit <committish>] <filename>\nbut that's partly why I'm asking for feedback.\n\n\n-- \n\nRyan Anderson\n  sometimes Pug Majere\n\n"},{"id":"17235","messageId":"20060306055036.GB26820@spearce.org","threadId":"3566","inReplyTo":"440BCB67.4070406@michonline.com","subject":"Re: [PATCH] annotate: Support annotation of files on other revisions.","fromName":"Shawn Pearce","fromEmail":"spearce@spearce.org","sentAt":"2006-03-06T05:50:36Z","receivedAt":"2006-03-06T05:50:36Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Ryan Anderson <ryan@michonline.com> wrote:\n> A Large Angry SCM wrote:\n> \n> > Ryan Anderson wrote:\n> > ...\n> >\n> >>\n> >> For annotate, the syntax I was using was:\n> >>     git annotate Makefile headname\n> >>\n> >> I'm not married to it, so please, send a patch to change it if you want\n> >> (Please fix up the test case I'm sending in this patch, as well.)\n> >>\n> >\n> > Wouldn't\n> >     git annotate <headname> <filename(s?)>\n> > be more consistent with other git commands?\n> >\n> Yes, but <headname> (really, a commitish) needs to be optional.\n> \n> I should probably switch to:\n>     git annotate [-c|--commit <committish>] <filename>\n> but that's partly why I'm asking for feedback.\n\nYes but doesn't git-diff accept:\n\n\tgit-diff Makefile\n\tgit-diff HEAD Makefile\n\n?  (Which is rather ugly as what if you have a tracked file actually\ncalled HEAD and you want the first form when the commit-ish is\nomitted.)  So accepting an optional commit-ish before the filename\nwould be in line with what git-diff accepts today.\n\nBut maybe breaking convention from git-diff now is a good thing,\nwith a future change to cleanup git-diff.\n\n-- \nShawn.\n"},{"id":"17236","messageId":"7vu0acaypd.fsf@assigned-by-dhcp.cox.net","threadId":"3566","inReplyTo":"440BA4DA.9060101@michonline.com","subject":"[PATCH] annotate/blame tests updates.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-03-06T06:12:30Z","receivedAt":"2006-03-06T06:12:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ryan Anderson <ryan@michonline.com> writes:\n\n>>+test_expect_success \\\n>>+    'check all lines blamed on A' \\\n>>+    '[ $(git annotate file | awk \"{print \\$3}\" | grep -c \"A\") == 2 ]'\n>>  \n>>\n> This should be $PROG as well, I suspect.\n\nTrue.  Also I am suspecting this awk being a but unsafe.  The\ndefault author is \"A U Thor <author@example.com>\", and without\nFS specified awk would split at whitespaces.\n\nI haven't pushed out the test-case sharing by Fredrik yet, but I\nhave already taken it.  This patch is on top of it.\n\n-- >8 --\nThis rewrites the result check code a bit.  The earlier one\nusing awk was splitting columns at any whitespace, which\nconfused lines attributed incorrectly to the merge made by the\ndefault author \"A U Thor <author@example.com>\" with lines\nattributed to author \"A\".\n\nThe latest test by Ryan to add the \"starting from older commit\"\ntest is also included, with another older commit test.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n\n---\n\n t/annotate-tests.sh |   81 ++++++++++++++++++++++++++++-----------------------\n 1 files changed, 44 insertions(+), 37 deletions(-)\n\n92a903acfd0904e6dd6d18112428429938783d19\ndiff --git a/t/annotate-tests.sh b/t/annotate-tests.sh\nindex 54a4dfb..d25a7a1 100644\n--- a/t/annotate-tests.sh\n+++ b/t/annotate-tests.sh\n@@ -1,6 +1,37 @@\n # This file isn't used as a test script directly, instead it is\n # sourced from t8001-annotate.sh and t8001-blame.sh.\n \n+check_count () {\n+\thead=\n+\tcase \"$1\" in -h) head=\"$2\"; shift; shift ;; esac\n+\t$PROG file $head | perl -e '\n+\t\tmy %expect = (@ARGV);\n+\t\tmy %count = ();\n+\t\twhile (<STDIN>) {\n+\t\t\tif (/^[0-9a-f]+\\t\\(([^\\t]+)\\t/) {\n+\t\t\t\tmy $author = $1;\n+\t\t\t\tfor ($author) { s/^\\s*//; s/\\s*$//; }\n+\t\t\t\tif (exists $expect{$author}) {\n+\t\t\t\t\t$count{$author}++;\n+\t\t\t\t}\n+\t\t\t}\n+\t\t}\n+\t\tmy $bad = 0;\n+\t\twhile (my ($author, $count) = each %count) {\n+\t\t\tmy $ok;\n+\t\t\tif ($expect{$author} != $count) {\n+\t\t\t\t$bad = 1;\n+\t\t\t\t$ok = \"bad\";\n+\t\t\t}\n+\t\t\telse {\n+\t\t\t\t$ok = \"good\";\n+\t\t\t}\n+\t\t\tprint STDERR \"Author $author (expected $expect{$author}, attributed $count) $ok\\n\";\n+\t\t}\n+\t\texit($bad);\n+\t' \"$@\"\n+}\n+\n test_expect_success \\\n     'prepare reference tree' \\\n     'echo \"1A quick brown fox jumps over the\" >file &&\n@@ -10,7 +41,7 @@ test_expect_success \\\n \n test_expect_success \\\n     'check all lines blamed on A' \\\n-    '[ $(git annotate file | awk \"{print \\$3}\" | grep -c \"A\") == 2 ]'\n+    'check_count A 2'\n \n test_expect_success \\\n     'Setup new lines blamed on B' \\\n@@ -19,12 +50,8 @@ test_expect_success \\\n      GIT_AUTHOR_NAME=\"B\" git commit -a -m \"Second.\"'\n \n test_expect_success \\\n-    'Two lines blamed on A' \\\n-    '[ $($PROG file | awk \"{print \\$3}\" | grep -c \"A\") == 2 ]'\n-\n-test_expect_success \\\n-    'Two lines blamed on B' \\\n-    '[ $($PROG file | awk \"{print \\$3}\" | grep -c \"B\") == 2 ]'\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@@ -34,16 +61,8 @@ test_expect_success \\\n      GIT_AUTHOR_NAME=\"B1\" git commit -a -m \"Branch1-1\"'\n \n test_expect_success \\\n-    'Two lines blamed on A' \\\n-    '[ $($PROG file | awk \"{print \\$3}\" | grep -c \"^A$\") == 2 ]'\n-\n-test_expect_success \\\n-    'Two lines blamed on B' \\\n-    '[ $($PROG file | awk \"{print \\$3}\" | grep -c \"^B$\") == 2 ]'\n-\n-test_expect_success \\\n-    'Two lines blamed on B1' \\\n-    '[ $($PROG file | awk \"{print \\$3}\" | grep -c \"^B1$\") == 2 ]'\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@@ -53,34 +72,22 @@ test_expect_success \\\n      GIT_AUTHOR_NAME=\"B2\" git commit -a -m \"Branch2-1\"'\n \n test_expect_success \\\n-    'Two lines blamed on A' \\\n-    '[ $($PROG file | awk \"{print \\$3}\" | grep -c \"^A$\") == 2 ]'\n-\n-test_expect_success \\\n-    'One line blamed on B' \\\n-    '[ $($PROG file | awk \"{print \\$3}\" | grep -c \"^B$\") == 1 ]'\n-\n-test_expect_success \\\n-    'One line blamed on B2' \\\n-    '[ $($PROG file | awk \"{print \\$3}\" | grep -c \"^B2$\") == 1 ]'\n-\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' \\\n-    '[ $($PROG file | awk \"{print \\$3}\" | grep -c \"^A$\") == 2 ]'\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-    'One line blamed on B' \\\n-    '[ $($PROG file | awk \"{print \\$3}\" | grep -c \"^B$\") == 1 ]'\n+    'Annotating an old revision works' \\\n+    'check_count -h master A 2 B 2'\n \n test_expect_success \\\n-    'Two lines blamed on B1' \\\n-    '[ $($PROG file | awk \"{print \\$3}\" | grep -c \"^B1$\") == 2 ]'\n+    'Annotating an old revision works' \\\n+    'check_count -h master^ A 2'\n \n-test_expect_success \\\n-    'One line blamed on B2' \\\n-    '[ $($PROG file | awk \"{print \\$3}\" | grep -c \"^B2$\") == 1 ]'\n-- \n1.2.4.g4668\n"},{"id":"17237","messageId":"7vpsl0ayij.fsf@assigned-by-dhcp.cox.net","threadId":"3566","inReplyTo":"20060306055036.GB26820@spearce.org","subject":"Re: [PATCH] annotate: Support annotation of files on other revisions.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-03-06T06:16:36Z","receivedAt":"2006-03-06T06:16:36Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Shawn Pearce <spearce@spearce.org> writes:\n\n> \tgit-diff Makefile\n> \tgit-diff HEAD Makefile\n>\n> ?  (Which is rather ugly as what if you have a tracked file actually\n> called HEAD and you want the first form when the commit-ish is\n> omitted.)  So accepting an optional commit-ish before the filename\n> would be in line with what git-diff accepts today.\n\nThe use of \"start of filelist\" marker \"--\" is optional when\nunambiguous, and that is why \"git-diff Makefile\" works.  To view\nthe change you still haven't update-index'ed to the path called\n\"HEAD\", you would naturally say \"git-diff -- HEAD\"\n"},{"id":"17238","messageId":"440BD4F4.3060906@gmail.com","threadId":"3566","inReplyTo":"20060306055036.GB26820@spearce.org","subject":"Re: [PATCH] annotate: Support annotation of files on other revisions.","fromName":"A Large Angry SCM","fromEmail":"gitzilla@gmail.com","sentAt":"2006-03-06T06:21:40Z","receivedAt":"2006-03-06T06:21:40Z","isPatch":true,"sender":{"key":"gitzilla@gmail.com","avatar":"https://gravatar.com/avatar/354625c442439908ff3dd99757dee330e29e9df7847472384faf7a00add247fb?d=mp&s=160"},"body":"Shawn Pearce wrote:\n> Ryan Anderson <ryan@michonline.com> wrote:\n>>A Large Angry SCM wrote:\n>>\n>>>Ryan Anderson wrote:\n>>>...\n>>>\n>>>>For annotate, the syntax I was using was:\n>>>>    git annotate Makefile headname\n>>>>\n>>>>I'm not married to it, so please, send a patch to change it if you want\n>>>>(Please fix up the test case I'm sending in this patch, as well.)\n>>>>\n>>>Wouldn't\n>>>    git annotate <headname> <filename(s?)>\n>>>be more consistent with other git commands?\n>>>\n>>Yes, but <headname> (really, a commitish) needs to be optional.\n>>\n>>I should probably switch to:\n>>    git annotate [-c|--commit <committish>] <filename>\n>>but that's partly why I'm asking for feedback.\n\nThat works.\n\nOr maybe:\n\tgit-annotate [<committish> --] <filename(s?)>\nor:\n\tgit-annotate [<committish>] -- <filename(s?)>\n\n> \n> Yes but doesn't git-diff accept:\n> \n> \tgit-diff Makefile\n> \tgit-diff HEAD Makefile\n> \n> ?  (Which is rather ugly as what if you have a tracked file actually\n> called HEAD and you want the first form when the commit-ish is\n> omitted.)  So accepting an optional commit-ish before the filename\n> would be in line with what git-diff accepts today.\n> \n> But maybe breaking convention from git-diff now is a good thing,\n> with a future change to cleanup git-diff.\n> \n\nLooking at the documentation, it looks like all of the commands that \ntake paths do so as the last arguments. With any commit/tree arguments \nbeing, either, required or flagged.\n\nIs there any reason that git-{annotate,blame} can't take more than one \nfilename, ever?\n"},{"id":"17239","messageId":"7vk6b8axz4.fsf@assigned-by-dhcp.cox.net","threadId":"3566","inReplyTo":"440BD4F4.3060906@gmail.com","subject":"Re: [PATCH] annotate: Support annotation of files on other revisions.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-03-06T06:28:15Z","receivedAt":"2006-03-06T06:28:15Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"> Is there any reason that git-{annotate,blame} can't take more than one\n> filename, ever?\n\nI do not see it would be much useful -- the output does not\nhave a sign to show file boundary.\n"},{"id":"17241","messageId":"20060306063254.GE26820@spearce.org","threadId":"3566","inReplyTo":"7vpsl0ayij.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] annotate: Support annotation of files on other revisions.","fromName":"Shawn Pearce","fromEmail":"spearce@spearce.org","sentAt":"2006-03-06T06:32:54Z","receivedAt":"2006-03-06T06:32:54Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Junio C Hamano <junkio@cox.net> wrote:\n> Shawn Pearce <spearce@spearce.org> writes:\n> \n> > \tgit-diff Makefile\n> > \tgit-diff HEAD Makefile\n> >\n> > ?  (Which is rather ugly as what if you have a tracked file actually\n> > called HEAD and you want the first form when the commit-ish is\n> > omitted.)  So accepting an optional commit-ish before the filename\n> > would be in line with what git-diff accepts today.\n> \n> The use of \"start of filelist\" marker \"--\" is optional when\n> unambiguous, and that is why \"git-diff Makefile\" works.  To view\n> the change you still haven't update-index'ed to the path called\n> \"HEAD\", you would naturally say \"git-diff -- HEAD\"\n\nNaturally.  :-)\n\nAfter getting along fine with `git-diff foo` for months I would\nnatually not be surprised when `git-diff foo` didn't work because\nI performed a `git-checkout -b foo pu` one day.\n\n-- \nShawn.\n"},{"id":"17244","messageId":"20060306074911.GA4501@c165.ib.student.liu.se","threadId":"3566","inReplyTo":"46a038f90603052018n76d316eclf84b6921c9595f16@mail.gmail.com","subject":"Re: [PATCH] annotate: Support annotation of files on other revisions.","fromName":"Fredrik Kuivinen","fromEmail":"freku045@student.liu.se","sentAt":"2006-03-06T07:49:11Z","receivedAt":"2006-03-06T07:49:11Z","isPatch":true,"sender":{"key":"frekui@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13770967?v=4"},"body":"On Mon, Mar 06, 2006 at 05:18:35PM +1300, Martin Langhoff wrote:\n> On 3/6/06, Ryan Anderson <ryan@michonline.com> wrote:\n> > annotate was *trying* to handle that cleanly, but failed due to a silly\n> \n> Great stuff, thanks! I'll let it hit master and then I'll drop the\n> messy part of req_annotate() in cvsserver.\n> \n> > For annotate, the syntax I was using was:\n> >         git annotate Makefile headname\n> >\n> > I'm not married to it, so please, send a patch to change it if you want\n> > (Please fix up the test case I'm sending in this patch, as well.)\n> \n> That's _perfect_. I was just making the syntax up.\n> \n\nThat syntax should work with git-blame too. If it doesn't, it's a bug.\n\n- Fredrik\n"},{"id":"17248","messageId":"Pine.LNX.4.63.0603061016320.1422@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"3566","inReplyTo":"20060306024353.GA23001@mythryan2.michonline.com","subject":"Re: [PATCH] annotate: Support annotation of files on other revisions.","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-03-06T09:18:55Z","receivedAt":"2006-03-06T09:18:55Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sun, 5 Mar 2006, Ryan Anderson wrote:\n\n> +use Data::Dumper;\n\nYou really need this?\n\nCiao,\nDscho\n\nP.S.: Not to be left behind, I also weigh in into the other discussion: \nI'd like \"git-{annotate,blame} [HEAD [--]] [filenames...]\".\n"},{"id":"17250","messageId":"Pine.LNX.4.63.0603061021240.1422@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"3566","inReplyTo":"7vk6b8axz4.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] annotate: Support annotation of files on other revisions.","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-03-06T09:24:10Z","receivedAt":"2006-03-06T09:24:10Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sun, 5 Mar 2006, Junio C Hamano wrote:\n\n> > Is there any reason that git-{annotate,blame} can't take more than one\n> > filename, ever?\n> \n> I do not see it would be much useful -- the output does not\n> have a sign to show file boundary.\n\nCVS does it. Why shouldn't git, too?\n\nCiao,\nDscho\n\nP.S.: The output for more than one file is separated by something like\n\n\tAnnotations for <filename.txt>\n\t***************\n"},{"id":"17258","messageId":"440C58E7.5080402@michonline.com","threadId":"3566","inReplyTo":"Pine.LNX.4.63.0603061016320.1422@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] annotate: Support annotation of files on other revisions.","fromName":"Ryan Anderson","fromEmail":"ryan@michonline.com","sentAt":"2006-03-06T15:44:39Z","receivedAt":"2006-03-06T15:44:39Z","isPatch":true,"sender":{"key":"ryan@michonline.com","avatar":null},"body":"Johannes Schindelin wrote:\n\n>Hi,\n>\n>On Sun, 5 Mar 2006, Ryan Anderson wrote:\n>\n>  \n>\n>>+use Data::Dumper;\n>>    \n>>\n>\n>You really need this?\n>  \n>\n\nI keep adding it back in when debugging things, and then promptly forget\nto remove it when I cull the debugging back out.\n\nIt's a core module, so it shouldn't be a significant issue for any porting\n\n-- \n\nRyan Anderson\n  sometimes Pug Majere\n\n"}]}