Subject: bug#27953: closed (Re: bug#27953: vc-region-history doesn't follow renames)

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 05 Aug 2017 17:28:02 +0000

Your bug report

#27953: vc-region-history doesn't follow renames

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
27953: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=27953
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#27953: vc-region-history doesn't follow renames
From: Clément Pit--Claudel <[email-masked]>
To: Kyle Meyer <[email-masked]>
Cc: Andreas Schwab <[email-masked]>, Stefan Monnier <[email-masked]>, [email-masked]
Date: Sat, 5 Aug 2017 19:27:21 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

On 2017-08-05 19:05, Kyle Meyer wrote:
> Clément Pit--Claudel <[email-masked]> writes:
>> On 2017-08-04 19:21, Stefan Monnier wrote:
>>>> Indeed, `git log -p --follow -L5,25:file.c' doesn't work.  But `git
>>>> log -p --follow -L5,25:file.c file.c' does work (note the extra mention of
>>>> the file name).
>>>
>>> Hmm... what's the difference between
>>>
>>>     git log -p -L5,25:file.c
>>> and
>>>     git log -p -L5,25:file.c file.c
>>
>> The second one allows --follow; the first one doesn't.  I don't know what differences they may be beyond that :/
> 
> As Andreas mentioned, even though git doesn't throw an error, giving a
> pathspec with -L is documented as invalid.

Thanks. I'm glad I sent the patch for review.

> But you shouldn't need to add --follow here.  Renames should be followed
> by default when -L is used.  (At least, that's what I see using Git
> v2.13.3.)

This seems to be new. Adding --follow appears to make git follow renames here (2.7.4).

Thanks.
Clément.

Subject: vc-region-history doesn't follow renames
From: Clément Pit--Claudel <[email-masked]>
To: [email-masked]
Date: Fri, 4 Aug 2017 17:12:39 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

X-Debbugs-CC: [email-masked]

Hi bug-gnu-emacs,

vc-git-region-history currently stops at the first rename, instead of continuing across renames.  This is because it doesn't pass --follow to git.  The original author put the required option "--follow" in a comment, adding "FIXME: not supported?".

Indeed, `git log -p --follow -L5,25:file.c' doesn't work.  But `git log -p --follow -L5,25:file.c file.c' does work (note the extra mention of the file name).

Any arguments against the attached patch?

(CCing Stefan, since you're the last one who modified this function)

Clément.

From 7a1c945645e6ea3c995ba21b4288b7a048340e67 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Pit--Claudel?= <[email-masked]>
Date: Fri, 4 Aug 2017 17:03:20 +0200
Subject: [PATCH] Follow renames in vc-git-region-history

* lisp/vc/vc-git.el (vc-git-region-history): Pass --follow.  This
requires a path spec, so pass that too.
---
 lisp/vc/vc-git.el | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index cc3e295..6830951 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -1159,8 +1159,10 @@ vc-git-region-history
                 (- (+ curno curcnt) (+ headno headcnt)))))
       (setq lto (- lto (or to-offset last-offset)))
       (setq lfrom (- lfrom (or to-offset last-offset)))))
-  (vc-git-command buffer 'async nil "log" "-p" ;"--follow" ;FIXME: not supported?
-                  (format "-L%d,%d:%s" lfrom lto (file-relative-name file))))
+  (vc-git-command buffer 'async nil "log" "-p" "--follow"
+            (format "-L%d,%d:%s" lfrom lto (file-relative-name file))
+            ;; Must include one path spec for --follow to work
+            (file-relative-name file)))
 
 (require 'diff-mode)
 
-- 
2.7.4