From: Dmitry Gutov <dgutov@yandex.ru>
To: Wojciech Siewierski <wojciech.siewierski@gmail.com>,
26345@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 05:30:14 +0300 [thread overview]
Message-ID: <acbe4730-6eda-55c3-5f0b-625c86f05e9f@yandex.ru> (raw)
In-Reply-To: <3b0ce616-d7ae-8f63-3ed8-cab1a6feaae2@gmail.com>
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
next prev parent reply other threads:[~2017-04-10 2:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-02 21:46 bug#26345: 25.1; vc-annotate in Git is unable to fully navigate the history if the file was moved Wojciech Siewierski
2017-04-10 2:30 ` Dmitry Gutov [this message]
2017-04-10 15:06 ` Wojciech Siewierski
2017-04-10 23:25 ` Dmitry Gutov
2017-04-14 23:46 ` Wojciech Siewierski
2017-05-01 1:41 ` Dmitry Gutov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=acbe4730-6eda-55c3-5f0b-625c86f05e9f@yandex.ru \
--to=dgutov@yandex.ru \
--cc=26345@debbugs.gnu.org \
--cc=wojciech.siewierski@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).