git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] blame: avoid checking if a file exists on the working tree if a revision is provided
@ 2015-11-17  1:29 Edmundo Carmona Antoranz
  2015-11-17  5:11 ` Eric Sunshine
  0 siblings, 1 reply; 9+ messages in thread
From: Edmundo Carmona Antoranz @ 2015-11-17  1:29 UTC (permalink / raw)
  To: git; +Cc: max, peff, Edmundo Carmona Antoranz

If a file has been deleted/renamed, blame refused to display
blame content even if the path provided does match an existing
blob on said revision.

$ git status
On branch hide
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        deleted:    testfile1.txt

no changes added to commit (use "git add" and/or "git commit -a")

Before:
$ git blame testfile1.txt
fatal: cannot stat path 'testfile1.txt': No such file or directory
$ git blame testfile1.txt HEAD
fatal: cannot stat path 'testfile1.txt': No such file or directory

After:
$ git blame testfile1.txt
fatal: Cannot lstat 'testfile1.txt': No such file or directory
$ git blame testfile1.txt HEAD
^da1a96f testfile2.txt (Edmundo Carmona Antoranz 2015-11-10 17:52:00 -0600 1) testfile 2
^da1a96f testfile2.txt (Edmundo Carmona Antoranz 2015-11-10 17:52:00 -0600 2)
^da1a96f testfile2.txt (Edmundo Carmona Antoranz 2015-11-10 17:52:00 -0600 3) Some content

Signed-off-by: Edmundo Carmona Antoranz <eantoranz@gmail.com>
---
 builtin/blame.c | 5 +++--
 1 file changed, 3 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;
-- 
2.6.2

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-11-20  4:38 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-17  1:29 [PATCH v2] blame: avoid checking if a file exists on the working tree if a revision is provided Edmundo Carmona Antoranz
2015-11-17  5:11 ` Eric Sunshine
2015-11-17 22:48   ` Jeff King
2015-11-17 23:00     ` Stefan Beller
2015-11-17 23:01     ` Eric Sunshine
2015-11-17 23:22       ` Jeff King
2015-11-20  4:38         ` Eric Sunshine
2015-11-17 23:37   ` Edmundo Carmona Antoranz
2015-11-17 23:47     ` 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).