{"thread":{"id":"40819","subject":"[PATCH v1] annotate: skip checking working tree if a revision is provided","startedAt":"2015-11-18T01:20:09Z","lastAt":"2015-11-21T01:40:28Z","messageCount":3,"participants":["Edmundo Carmona Antoranz"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"273461","messageId":"1447809609-17556-1-git-send-email-eantoranz@gmail.com","threadId":"40819","inReplyTo":null,"subject":"[PATCH v1] annotate: skip checking working tree if a revision is provided","fromName":"Edmundo Carmona Antoranz","fromEmail":"eantoranz@gmail.com","sentAt":"2015-11-18T01:20:09Z","receivedAt":"2015-11-18T01:20:09Z","isPatch":true,"sender":{"key":"eantoranz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1491018?v=4"},"body":"If a file has been deleted/renamed, annotate refuses to work\nbecause the file does not exist on the working tree anymore\n(even if the path provided does match a blob on said revision).\n\nSigned-off-by: Edmundo Carmona Antoranz <eantoranz@gmail.com>\n---\n builtin/blame.c     |  5 +++--\n t/annotate-tests.sh | 20 ++++++++++++++++++++\n 2 files changed, 23 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 83612f5..856971a 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -2683,12 +2683,13 @@ 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 \tsetup_revisions(argc, argv, &revs, NULL);\n+\tif (!revs.pending.nr && !file_exists(path))\n+\t\tdie_errno(\"cannot stat path '%s'\", path);\n+\n \tmemset(&sb, 0, sizeof(sb));\n \n \tsb.revs = &revs;\ndiff --git a/t/annotate-tests.sh b/t/annotate-tests.sh\nindex b1673b3..c99ec41 100644\n--- a/t/annotate-tests.sh\n+++ b/t/annotate-tests.sh\n@@ -567,3 +567,23 @@ test_expect_success 'blame -L X,-N (non-numeric N)' '\n test_expect_success 'blame -L ,^/RE/' '\n \ttest_must_fail $PROG -L1,^/99/ file\n '\n+\n+test_expect_success 'annotate deleted file' '\n+\techo hello world > hello_world.txt &&\n+\tgit add hello_world.txt &&\n+\tgit commit -m \"step 1\" &&\n+\tgit rm hello_world.txt &&\n+\tgit commit -m \"step 2\" &&\n+\tgit annotate hello_world.txt HEAD~1 &&\n+\ttest_must_fail git annotate hello_world.txt\n+'\n+\n+test_expect_success 'annotate moved file' '\n+\techo hello world > hello_world.txt &&\n+\tgit add hello_world.txt &&\n+\tgit commit -m \"step 1\" &&\n+\tgit mv hello_world.txt not_there_anymore.txt &&\n+\tgit commit -m \"step 2\" &&\n+\tgit annotate hello_world.txt HEAD~1 &&\n+\ttest_must_fail git annotate hello_world.txt\n+'\n-- \n2.6.2\n"},{"id":"273565","messageId":"CAOc6etbF-yF0bhmmjQG=P=FW0QnokPTXnqLiyPM7uJ7eqom9rw@mail.gmail.com","threadId":"40819","inReplyTo":"1447809609-17556-1-git-send-email-eantoranz@gmail.com","subject":"Re: [PATCH v1] annotate: skip checking working tree if a revision is provided","fromName":"Edmundo Carmona Antoranz","fromEmail":"eantoranz@gmail.com","sentAt":"2015-11-21T01:25:55Z","receivedAt":"2015-11-21T01:25:55Z","isPatch":true,"sender":{"key":"eantoranz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1491018?v=4"},"body":"On Tue, Nov 17, 2015 at 7:20 PM, Edmundo Carmona Antoranz\n<eantoranz@gmail.com> wrote:\n> +       if (!revs.pending.nr && !file_exists(path))\n> +               die_errno(\"cannot stat path '%s'\", path);\n> +\n\nI was wondering if I should only check the path that is coming from\n\"blame\" (which is where I'm taking the check from) by checking\ndashdash_pos:\n\nif (!dashdash_pos && !revs.pending.nr && !file_exists(path))\n    die_errno(\"cannot stat path '%s'\", path);\n\nSo that we don't apply the check if we are coming from normal\ndashdash_pos != 0 (and which didn't apply the filesystem check).\n\nThanks in advance.\n"},{"id":"273566","messageId":"CAOc6etYzxbY9SR7aegTdqo9RB8bcRoL9ihZZDP3rDZVUwDT6BA@mail.gmail.com","threadId":"40819","inReplyTo":"CAOc6etbF-yF0bhmmjQG=P=FW0QnokPTXnqLiyPM7uJ7eqom9rw@mail.gmail.com","subject":"Re: [PATCH v1] annotate: skip checking working tree if a revision is provided","fromName":"Edmundo Carmona Antoranz","fromEmail":"eantoranz@gmail.com","sentAt":"2015-11-21T01:40:28Z","receivedAt":"2015-11-21T01:40:28Z","isPatch":true,"sender":{"key":"eantoranz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1491018?v=4"},"body":"And I did't say it right. The execution path where dashdash_pos is 0\nis coming from \"annotate\". Sorry for my confusion on the previous\nmail.\n\nOn Fri, Nov 20, 2015 at 7:25 PM, Edmundo Carmona Antoranz\n<eantoranz@gmail.com> wrote:\n> On Tue, Nov 17, 2015 at 7:20 PM, Edmundo Carmona Antoranz\n> <eantoranz@gmail.com> wrote:\n>> +       if (!revs.pending.nr && !file_exists(path))\n>> +               die_errno(\"cannot stat path '%s'\", path);\n>> +\n>\n> I was wondering if I should only check the path that is coming from\n> \"blame\" (which is where I'm taking the check from) by checking\n> dashdash_pos:\n>\n> if (!dashdash_pos && !revs.pending.nr && !file_exists(path))\n>     die_errno(\"cannot stat path '%s'\", path);\n>\n> So that we don't apply the check if we are coming from normal\n> dashdash_pos != 0 (and which didn't apply the filesystem check).\n>\n> Thanks in advance.\n"}]}