bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#26345: 25.1; vc-annotate in Git is unable to fully navigate the hist


From: Wojciech Siewierski
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
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0

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!

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]