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

Package: emacs;

Reported by: Wojciech Siewierski <wojciech.siewierski <at> gmail.com>

Date: Mon, 3 Apr 2017 00:06:02 UTC

Severity: normal

Found in version 25.1

Full log


View this message in rfc822 format

From: Wojciech Siewierski <wojciech.siewierski <at> gmail.com>
To: Dmitry Gutov <dgutov <at> yandex.ru>, 26345 <at> debbugs.gnu.org
Subject: bug#26345: 25.1; vc-annotate in Git is unable to fully navigate the history if the file was moved
Date: Mon, 10 Apr 2017 17:06:16 +0200
[Message part 1 (text/plain, inline)]
On 10.04.2017 04:30, Dmitry Gutov wrote:
> 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
The error is gone but usability-wise not much has changed: now the
vc-annotate buffer contains "fatal: no such path olddir/file.txt in
master" after I finish my test scenario. I guess not much more can be
done. Thanks!

[signature.asc (application/pgp-signature, attachment)]

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.