GNU bug report logs -
#26345
25.1; vc-annotate in Git is unable to fully navigate the history if the file was moved
Previous Next
Full log
Message #8 received at 26345 <at> debbugs.gnu.org (full text, mbox):
On 03.04.2017 00:46, Wojciech Siewierski wrote:
>
> It seems some vc-git operations override `default-directory' with the
> parent directory of the files they operate on. It's a problem if they no
> longer exist like in the following scenario.
>
> Preparation steps in shell:
>
> $ git init
> $ mkdir olddir/
> $ echo oldcontent > olddir/file.txt
> $ git add olddir/
> $ git commit -m 'Initial commit'
> $ echo newcontent > olddir/file.txt
> $ git add olddir/
> $ git commit -m 'Modify the file'
> $ git mv olddir/ newdir/
> $ git commit -m 'Move the file'
>
> Reproduction:
>
> 1. Open newdir/file.txt in Emacs.
> 2. Press `C-x v g' to open `vc-annotate'.
> 3. Press `j' to jump to the revision from before the file was moved.
> 4. Try to move to the next (newer) revision with `n'. The error appears
> here.
Thanks. For the report. I'm including a minor patch below. Does it
improve things considerably for you?
>> apply: Setting current directory: No such file or directory,
> .../testrepo/olddir/
>
> It seems in this scenario `vc-annotate' also has trouble with the
> regular navigation (`n' and `p') without the usage of `j' but the error
> message is not as clear.
The problem of `n' and `p' navigation between revisions where the file
name changed is still present, because of how `vc-git-next-revision' is
written. Suggestions for a better implementation are welcome.
The patch that fixes the first scenario:
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 1a3f1bf..4767cbf 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -1274,9 +1274,8 @@ vc-git--rev-parse
(defun vc-git-next-revision (file rev)
"Git-specific version of `vc-next-revision'."
- (let* ((default-directory (file-name-directory
- (expand-file-name file)))
- (file (file-name-nondirectory file))
+ (let* ((default-directory (vc-git-root file))
+ (file (file-relative-name file))
(current-rev
(with-temp-buffer
(and
This bug report was last modified 100 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.