{"thread":{"id":"40810","subject":"[PATCH v1] blame: avoid checking if a file exists on the working tree if a revision is provided","startedAt":"2015-11-17T01:07:17Z","lastAt":"2015-11-17T01:25:52Z","messageCount":3,"participants":["Edmundo Carmona Antoranz"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"273402","messageId":"1447722437-14937-1-git-send-email-eantoranz@gmail.com","threadId":"40810","inReplyTo":null,"subject":"[PATCH v1] blame: avoid checking if a file exists on the working tree if a revision is provided","fromName":"Edmundo Carmona Antoranz","fromEmail":"eantoranz@gmail.com","sentAt":"2015-11-17T01:07:17Z","receivedAt":"2015-11-17T01:07:17Z","isPatch":true,"sender":{"key":"eantoranz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1491018?v=4"},"body":"If a file has been deleted/renamed, blame refused to display\nblame content even if the path provided does match an existing\nblob on said revision.\n\n$ git status\nOn branch hide\nChanges not staged for commit:\n  (use \"git add/rm <file>...\" to update what will be committed)\n  (use \"git checkout -- <file>...\" to discard changes in working directory)\n\n        deleted:    testfile1.txt\n\nno changes added to commit (use \"git add\" and/or \"git commit -a\")\n\nBefore:\n$ git blame testfile1.txt\nfatal: cannot stat path 'testfile1.txt': No such file or directory\n$ git blame testfile1.txt HEAD\nfatal: cannot stat path 'testfile1.txt': No such file or directory\n\nAfter:\n$ git blame testfile1.txt\nfatal: Cannot lstat 'testfile1.txt': No such file or directory\n$ git blame testfile1.txt HEAD\n^da1a96f testfile2.txt (Edmundo Carmona Antoranz 2015-11-10 17:52:00 -0600 1) testfile 2\n^da1a96f testfile2.txt (Edmundo Carmona Antoranz 2015-11-10 17:52:00 -0600 2)\n^da1a96f testfile2.txt (Edmundo Carmona Antoranz 2015-11-10 17:52:00 -0600 3) Some content\n\nSigned-off-by: Edmundo Carmona Antoranz <eantoranz@gmail.com>\n---\n builtin/blame.c | 2 --\n 1 file changed, 2 deletions(-)\n\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 83612f5..db430d5 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -2683,8 +2683,6 @@ parse_done:\n \t\targv[argc - 1] = \"--\";\n \n \t\tsetup_work_tree();\n-\t\tif (!file_exists(path))\n-\t\t\tdie_errno(\"cannot stat path '%s'\", path);\n \t}\n \n \trevs.disable_stdin = 1;\n-- \n2.6.2\n"},{"id":"273403","messageId":"CAOc6etbsqZ=gTGido2b3FXZyY+1JRkeF1O9pk37+7qOogaN6oA@mail.gmail.com","threadId":"40810","inReplyTo":"1447722437-14937-1-git-send-email-eantoranz@gmail.com","subject":"Re: [PATCH v1] blame: avoid checking if a file exists on the working tree if a revision is provided","fromName":"Edmundo Carmona Antoranz","fromEmail":"eantoranz@gmail.com","sentAt":"2015-11-17T01:16:33Z","receivedAt":"2015-11-17T01:16:33Z","isPatch":true,"sender":{"key":"eantoranz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1491018?v=4"},"body":"On Mon, Nov 16, 2015 at 7:07 PM, Edmundo Carmona Antoranz\n<eantoranz@gmail.com> wrote:\n> -               if (!file_exists(path))\n> -                       die_errno(\"cannot stat path '%s'\", path);\n\nTwo things:\n1\nWhat I would love to do is check if revisions were provided. Something like:\n\nif (no_revisions() && !file_exists(path))\n    die_errno(\"cannot stat path '%s'\", path);\n\n_but_ revisions are set up a little bit later. I don't know right now\nif I could just move it up (I don't think it would be that simple\nbecause I see there's some messing up with argv and argc in that 'if'\nthat encloses the lines I'm removing). Maybe it would make sense to\nmove the check for file existence to _after_ revisions have been set\nup? Even without the check for revisions, it's behaving kind of the\nway I mean it to. But I'm sure it'd be more elegant if I checked if\nrevisions were provided.\n\n2 It makes sense to create test cases for this patch, right?\n\nLooking forward to your comments. Thanks in advance.\n"},{"id":"273404","messageId":"CAOc6etbmjufXLd7eXCtj7triO5190U4ea0RbXB40Br9-gvAwEA@mail.gmail.com","threadId":"40810","inReplyTo":"CAOc6etbsqZ=gTGido2b3FXZyY+1JRkeF1O9pk37+7qOogaN6oA@mail.gmail.com","subject":"Re: [PATCH v1] blame: avoid checking if a file exists on the working tree if a revision is provided","fromName":"Edmundo Carmona Antoranz","fromEmail":"eantoranz@gmail.com","sentAt":"2015-11-17T01:25:52Z","receivedAt":"2015-11-17T01:25:52Z","isPatch":true,"sender":{"key":"eantoranz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1491018?v=4"},"body":"Ok... I think I got how to check revisions / file existence after\nrevisions have been set up.\n\nSending next patch version\n\nOn Mon, Nov 16, 2015 at 7:16 PM, Edmundo Carmona Antoranz\n<eantoranz@gmail.com> wrote:\n> On Mon, Nov 16, 2015 at 7:07 PM, Edmundo Carmona Antoranz\n> <eantoranz@gmail.com> wrote:\n>> -               if (!file_exists(path))\n>> -                       die_errno(\"cannot stat path '%s'\", path);\n>\n> Two things:\n> 1\n> What I would love to do is check if revisions were provided. Something like:\n>\n> if (no_revisions() && !file_exists(path))\n>     die_errno(\"cannot stat path '%s'\", path);\n>\n> _but_ revisions are set up a little bit later. I don't know right now\n> if I could just move it up (I don't think it would be that simple\n> because I see there's some messing up with argv and argc in that 'if'\n> that encloses the lines I'm removing). Maybe it would make sense to\n> move the check for file existence to _after_ revisions have been set\n> up? Even without the check for revisions, it's behaving kind of the\n> way I mean it to. But I'm sure it'd be more elegant if I checked if\n> revisions were provided.\n>\n> 2 It makes sense to create test cases for this patch, right?\n>\n> Looking forward to your comments. Thanks in advance.\n"}]}