{"thread":{"id":"23826","subject":"Possible bug with argument parsing in git blame","startedAt":"2010-05-17T10:21:18Z","lastAt":"2010-05-24T06:46:41Z","messageCount":5,"participants":["Debayan Banerjee","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"141802","messageId":"AANLkTikn1-Ua6G7eAc8UD8DJx0vpc-5-BOoxsi2mx2BC@mail.gmail.com","threadId":"23826","inReplyTo":null,"subject":"Possible bug with argument parsing in git blame","fromName":"Debayan Banerjee","fromEmail":"debayanin@gmail.com","sentAt":"2010-05-17T10:21:18Z","receivedAt":"2010-05-17T10:21:18Z","isPatch":false,"sender":{"key":"debayanin@gmail.com","avatar":"https://gravatar.com/avatar/950309d0a76e4e3eba6b22d59c42c982b6fa077a6c7d2070a12ce64d72f7cfb4?d=mp&s=160"},"body":"debayan@deep-blur:~/testrepo$ git blame 22621a32..8486802f --\ndir/subdir/newsubdir/b\n\n81531975 b                      (debayan 2010-05-13 15:32:17 +0530  1) four\n81531975 b                      (debayan 2010-05-13 15:32:17 +0530  2) five\nd700ac9c b                      (debayan 2010-05-13 15:33:27 +0530  3) blah\n2656ab56 b                      (debayan 2010-05-13 15:33:34 +0530  4) bleh\nd0c6e851 b                      (debayan 2010-05-13 15:42:21 +0530  5) foo\n7bf5510e b                      (debayan 2010-05-13 15:42:53 +0530  6) yo\nc4515289 b                      (debayan 2010-05-13 15:43:10 +0530  7) lala\na257c7e4 b                      (debayan 2010-05-13 16:03:46 +0530  8) yes\ned8e4601 b                      (debayan 2010-05-13 16:03:55 +0530  9) np\ne96d14bf dir/subdir/newsubdir/b (debayan 2010-05-13 16:05:05 +0530 10) yo\ndace00d1 dir/subdir/newsubdir/b (debayan 2010-05-13 16:05:11 +0530 11) boye\n8486802f dir/subdir/newsubdir/b (debayan 2010-05-13 16:07:51 +0530 12) what?\n\ndebayan@deep-blur:~/testrepo$ git blame 22621a32..8486802f\ndir/subdir/newsubdir/b\nfatal: cannot stat path 22621a32..8486802f: No such file or directory\n\nThe only difference between the first and the second command is the\n\"--\" separator.  Is this normal behaviour?\n\n-- \nDebayan Banerjee\nSoftware Engineer\n"},{"id":"142131","messageId":"20100523080002.GB24598@coredump.intra.peff.net","threadId":"23826","inReplyTo":"AANLkTikn1-Ua6G7eAc8UD8DJx0vpc-5-BOoxsi2mx2BC@mail.gmail.com","subject":"Re: Possible bug with argument parsing in git blame","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-05-23T08:00:02Z","receivedAt":"2010-05-23T08:00:02Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, May 17, 2010 at 03:51:18PM +0530, Debayan Banerjee wrote:\n\n> debayan@deep-blur:~/testrepo$ git blame 22621a32..8486802f --\n> dir/subdir/newsubdir/b\n> \n> 81531975 b                      (debayan 2010-05-13 15:32:17 +0530  1) four\n> 81531975 b                      (debayan 2010-05-13 15:32:17 +0530  2) five\n> d700ac9c b                      (debayan 2010-05-13 15:33:27 +0530  3) blah\n> 2656ab56 b                      (debayan 2010-05-13 15:33:34 +0530  4) bleh\n> d0c6e851 b                      (debayan 2010-05-13 15:42:21 +0530  5) foo\n> 7bf5510e b                      (debayan 2010-05-13 15:42:53 +0530  6) yo\n> c4515289 b                      (debayan 2010-05-13 15:43:10 +0530  7) lala\n> a257c7e4 b                      (debayan 2010-05-13 16:03:46 +0530  8) yes\n> ed8e4601 b                      (debayan 2010-05-13 16:03:55 +0530  9) np\n> e96d14bf dir/subdir/newsubdir/b (debayan 2010-05-13 16:05:05 +0530 10) yo\n> dace00d1 dir/subdir/newsubdir/b (debayan 2010-05-13 16:05:11 +0530 11) boye\n> 8486802f dir/subdir/newsubdir/b (debayan 2010-05-13 16:07:51 +0530 12) what?\n> \n> debayan@deep-blur:~/testrepo$ git blame 22621a32..8486802f\n> dir/subdir/newsubdir/b\n> fatal: cannot stat path 22621a32..8486802f: No such file or directory\n> \n> The only difference between the first and the second command is the\n> \"--\" separator.  Is this normal behaviour?\n\nI can't reproduce the problem here. For example, in git.git, both of the\nfollowing produce the same output:\n\n  git blame HEAD~5..HEAD~3 alloc.c\n  git blame HEAD~5..HEAD~3 -- alloc.c\n\nCan you provide the exact set of commands to replicate your repository\nstate and show the failure?\n\nAlso, I tested with the current 'master'. Are you using an older version\nof git?\n\n-Peff\n"},{"id":"142154","messageId":"20100523200853.GA23377@coredump.intra.peff.net","threadId":"23826","inReplyTo":"AANLkTinMlvmOneGgkIqxE8qWlhoOlqgALl-YHprqPI6h@mail.gmail.com","subject":"Re: Possible bug with argument parsing in git blame","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-05-23T20:08:54Z","receivedAt":"2010-05-23T20:08:54Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, May 23, 2010 at 07:22:41PM +0530, Debayan Banerjee wrote:\n\n> > I can't reproduce the problem here. For example, in git.git, both of the\n> > following produce the same output:\n> >\n> >  git blame HEAD~5..HEAD~3 alloc.c\n> >  git blame HEAD~5..HEAD~3 -- alloc.c\n> \n> It seems to happen only if the path has '/' in it. For example alloc.c\n> will be parsed fine, but dir/alloc.c wont.\n\nSorry, I still can't reproduce with:\n\n  mkdir repo && cd repo && git init\n  mkdir subdir\n\n  commit() {\n    echo content >>subdir/file\n    git add subdir/file\n    git commit -m foo\n  }\n\n  commit; commit; commit; commit; commit\n\n  git blame HEAD~3..HEAD~1 subdir/file >no-dash &&\n  git blame HEAD~3..HEAD~1 -- subdir/file >dash &&\n  diff no-dash dash &&\n  echo ok\n\nSo there must be some difference between your setup and my test case.\nCan you give more details?\n\n-Peff\n\nPS I tested on a variety of git versions back to v1.5.5, and I couldn't\ntrigger the problem, so I don't think it is a version issue.\n"},{"id":"142174","messageId":"AANLkTikEiRuitD7lrZQIaOruCBrL1Vu5K74Y4wGoiC1z@mail.gmail.com","threadId":"23826","inReplyTo":"20100523200853.GA23377@coredump.intra.peff.net","subject":"Re: Possible bug with argument parsing in git blame","fromName":"Debayan Banerjee","fromEmail":"debayanin@gmail.com","sentAt":"2010-05-24T06:17:02Z","receivedAt":"2010-05-24T06:17:02Z","isPatch":false,"sender":{"key":"debayanin@gmail.com","avatar":"https://gravatar.com/avatar/950309d0a76e4e3eba6b22d59c42c982b6fa077a6c7d2070a12ce64d72f7cfb4?d=mp&s=160"},"body":"On 24 May 2010 01:38, Jeff King <peff@peff.net> wrote:\n> On Sun, May 23, 2010 at 07:22:41PM +0530, Debayan Banerjee wrote:\n>\n>> > I can't reproduce the problem here. For example, in git.git, both of the\n>> > following produce the same output:\n>> >\n\nI used master too. The test cases you provided work fine for me too.\nIt also seems that '/' is not a problem. I tested myself with some\ncombinations and i could not reproduced the bug. But the strange\nbehaviour i reported with my particular case still exists.\nMy repo structure can be cloned from http://github.com/debayan/git-blame-test .\n-- \nDebayan Banerjee\nSoftware Engineer\n"},{"id":"142177","messageId":"20100524064641.GA10858@coredump.intra.peff.net","threadId":"23826","inReplyTo":"AANLkTikEiRuitD7lrZQIaOruCBrL1Vu5K74Y4wGoiC1z@mail.gmail.com","subject":"Re: Possible bug with argument parsing in git blame","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-05-24T06:46:41Z","receivedAt":"2010-05-24T06:46:41Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, May 24, 2010 at 11:47:02AM +0530, Debayan Banerjee wrote:\n\n> I used master too. The test cases you provided work fine for me too.\n> It also seems that '/' is not a problem. I tested myself with some\n> combinations and i could not reproduced the bug. But the strange\n> behaviour i reported with my particular case still exists.  My repo\n> structure can be cloned from http://github.com/debayan/git-blame-test\n> .\n\nOK, I see what is happening. The issue is that you are blaming a file\nfrom some revision, but that file doesn't exist in the working tree. You\ncan recreate it with:\n\n  git init\n  echo contents >>foo && git add foo && git commit -m one\n  echo contents >>foo && git add foo && git commit -m two\n  echo contents >>foo && git add foo && git commit -m three\n  git mv foo bar && git commit -m moved\n\nNow \"git blame HEAD~2..HEAD~1 -- foo\" will work, but \"git blame\nHEAD~2..HEAD~1 foo\" will not work.\n\nThis is as expected. When parsing revision/filename combinations, if\nthere is no explicit \"--\" separator, then we only allow filenames if the\nfile exists in the working tree. The idea is to prevent typos. For\nexample, in the same repo:\n\n  git bar ;# works, we have bar in the working tree\n  git log foo ;# complains, foo is not a revision and not a file, so\n               # maybe a typo\n  git log -- foo ;# works, filters on foo. The \"--\" makes it explicit\n\nThings are a little bit funny with blame because:\n\n  1. It should take exactly one filename, so it doesn't have this\n     ambiguity.\n\n  2. The error message isn't very helpful. I think this is because blame\n     actually accepts several different combinations (like \"<path>\n     <rev>\", and it ends up confused.\n\nI would be tempted to improve this, but I think (1) may no longer be the\ncase soon. As I understand it, some of Bo Yang's work in this area may\nmean that blame will soon accept multiple files, and the argument\nparsing may change.\n\n-Peff\n"}]}