* [PATCH v1] annotate: skip checking working tree if a revision is provided
@ 2015-11-18 1:20 Edmundo Carmona Antoranz
2015-11-21 1:25 ` Edmundo Carmona Antoranz
0 siblings, 1 reply; 3+ messages in thread
From: Edmundo Carmona Antoranz @ 2015-11-18 1:20 UTC (permalink / raw)
To: git; +Cc: sunshine, peff, Edmundo Carmona Antoranz
If a file has been deleted/renamed, annotate refuses to work
because the file does not exist on the working tree anymore
(even if the path provided does match a blob on said revision).
Signed-off-by: Edmundo Carmona Antoranz <eantoranz@gmail.com>
---
builtin/blame.c | 5 +++--
t/annotate-tests.sh | 20 ++++++++++++++++++++
2 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/builtin/blame.c b/builtin/blame.c
index 83612f5..856971a 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -2683,12 +2683,13 @@ parse_done:
argv[argc - 1] = "--";
setup_work_tree();
- if (!file_exists(path))
- die_errno("cannot stat path '%s'", path);
}
revs.disable_stdin = 1;
setup_revisions(argc, argv, &revs, NULL);
+ if (!revs.pending.nr && !file_exists(path))
+ die_errno("cannot stat path '%s'", path);
+
memset(&sb, 0, sizeof(sb));
sb.revs = &revs;
diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh
index b1673b3..c99ec41 100644
--- a/t/annotate-tests.sh
+++ b/t/annotate-tests.sh
@@ -567,3 +567,23 @@ test_expect_success 'blame -L X,-N (non-numeric N)' '
test_expect_success 'blame -L ,^/RE/' '
test_must_fail $PROG -L1,^/99/ file
'
+
+test_expect_success 'annotate deleted file' '
+ echo hello world > hello_world.txt &&
+ git add hello_world.txt &&
+ git commit -m "step 1" &&
+ git rm hello_world.txt &&
+ git commit -m "step 2" &&
+ git annotate hello_world.txt HEAD~1 &&
+ test_must_fail git annotate hello_world.txt
+'
+
+test_expect_success 'annotate moved file' '
+ echo hello world > hello_world.txt &&
+ git add hello_world.txt &&
+ git commit -m "step 1" &&
+ git mv hello_world.txt not_there_anymore.txt &&
+ git commit -m "step 2" &&
+ git annotate hello_world.txt HEAD~1 &&
+ test_must_fail git annotate hello_world.txt
+'
--
2.6.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v1] annotate: skip checking working tree if a revision is provided
2015-11-18 1:20 [PATCH v1] annotate: skip checking working tree if a revision is provided Edmundo Carmona Antoranz
@ 2015-11-21 1:25 ` Edmundo Carmona Antoranz
2015-11-21 1:40 ` Edmundo Carmona Antoranz
0 siblings, 1 reply; 3+ messages in thread
From: Edmundo Carmona Antoranz @ 2015-11-21 1:25 UTC (permalink / raw)
To: Git List; +Cc: Eric Sunshine, Jeff King, Edmundo Carmona Antoranz
On Tue, Nov 17, 2015 at 7:20 PM, Edmundo Carmona Antoranz
<eantoranz@gmail.com> wrote:
> + if (!revs.pending.nr && !file_exists(path))
> + die_errno("cannot stat path '%s'", path);
> +
I was wondering if I should only check the path that is coming from
"blame" (which is where I'm taking the check from) by checking
dashdash_pos:
if (!dashdash_pos && !revs.pending.nr && !file_exists(path))
die_errno("cannot stat path '%s'", path);
So that we don't apply the check if we are coming from normal
dashdash_pos != 0 (and which didn't apply the filesystem check).
Thanks in advance.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v1] annotate: skip checking working tree if a revision is provided
2015-11-21 1:25 ` Edmundo Carmona Antoranz
@ 2015-11-21 1:40 ` Edmundo Carmona Antoranz
0 siblings, 0 replies; 3+ messages in thread
From: Edmundo Carmona Antoranz @ 2015-11-21 1:40 UTC (permalink / raw)
To: Git List; +Cc: Eric Sunshine, Jeff King, Edmundo Carmona Antoranz
And I did't say it right. The execution path where dashdash_pos is 0
is coming from "annotate". Sorry for my confusion on the previous
mail.
On Fri, Nov 20, 2015 at 7:25 PM, Edmundo Carmona Antoranz
<eantoranz@gmail.com> wrote:
> On Tue, Nov 17, 2015 at 7:20 PM, Edmundo Carmona Antoranz
> <eantoranz@gmail.com> wrote:
>> + if (!revs.pending.nr && !file_exists(path))
>> + die_errno("cannot stat path '%s'", path);
>> +
>
> I was wondering if I should only check the path that is coming from
> "blame" (which is where I'm taking the check from) by checking
> dashdash_pos:
>
> if (!dashdash_pos && !revs.pending.nr && !file_exists(path))
> die_errno("cannot stat path '%s'", path);
>
> So that we don't apply the check if we are coming from normal
> dashdash_pos != 0 (and which didn't apply the filesystem check).
>
> Thanks in advance.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-11-21 1:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-18 1:20 [PATCH v1] annotate: skip checking working tree if a revision is provided Edmundo Carmona Antoranz
2015-11-21 1:25 ` Edmundo Carmona Antoranz
2015-11-21 1:40 ` Edmundo Carmona Antoranz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).