unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#27953: vc-region-history doesn't follow renames
@ 2017-08-04 15:12 Clément Pit--Claudel
  2017-08-04 17:21 ` Stefan Monnier
  0 siblings, 1 reply; 12+ messages in thread
From: Clément Pit--Claudel @ 2017-08-04 15:12 UTC (permalink / raw)
  To: 27953; +Cc: monnier


[-- Attachment #1.1.1: Type: text/plain, Size: 607 bytes --]

X-Debbugs-CC: monnier@iro.umontreal.ca

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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.1.2: 0001-Follow-renames-in-vc-git-region-history.patch --]
[-- Type: text/x-patch; name="0001-Follow-renames-in-vc-git-region-history.patch", Size: 1243 bytes --]

From 7a1c945645e6ea3c995ba21b4288b7a048340e67 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Pit--Claudel?= <clement.pitclaudel@live.com>
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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* bug#27953: vc-region-history doesn't follow renames
  2017-08-04 15:12 bug#27953: vc-region-history doesn't follow renames Clément Pit--Claudel
@ 2017-08-04 17:21 ` Stefan Monnier
  2017-08-04 17:40   ` Andreas Schwab
  2017-08-05 13:06   ` Clément Pit--Claudel
  0 siblings, 2 replies; 12+ messages in thread
From: Stefan Monnier @ 2017-08-04 17:21 UTC (permalink / raw)
  To: Clément Pit--Claudel; +Cc: 27953

> 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

?

Would this issue deserve a bug-report to Git?

> Any arguments against the attached patch?

I'd suggest to compute (file-relative-name file) only once, and to add
bug#27953 to the comment, but otherwise, looks good.


        Stefan





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#27953: vc-region-history doesn't follow renames
  2017-08-04 17:21 ` Stefan Monnier
@ 2017-08-04 17:40   ` Andreas Schwab
  2017-08-05 13:06   ` Clément Pit--Claudel
  1 sibling, 0 replies; 12+ messages in thread
From: Andreas Schwab @ 2017-08-04 17:40 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Clément Pit--Claudel, 27953

On Aug 04 2017, Stefan Monnier <monnier@IRO.UMontreal.CA> 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 latter is supposed to be invalid:

       -L <start>,<end>:<file>, -L :<funcname>:<file>
           Trace the evolution of the line range given by "<start>,<end>" (or
           the function name regex <funcname>) within the <file>. You may not
                                                                  ^^^^^^^^^^^
           give any pathspec limiters.
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^

> Would this issue deserve a bug-report to Git?

It does.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#27953: vc-region-history doesn't follow renames
  2017-08-04 17:21 ` Stefan Monnier
  2017-08-04 17:40   ` Andreas Schwab
@ 2017-08-05 13:06   ` Clément Pit--Claudel
  2017-08-05 17:05     ` Kyle Meyer
  1 sibling, 1 reply; 12+ messages in thread
From: Clément Pit--Claudel @ 2017-08-05 13:06 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 27953


[-- Attachment #1.1.1: Type: text/plain, Size: 775 bytes --]

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 :/

> Would this issue deserve a bug-report to Git?

Possibly; it's a bit intimidating.

>> Any arguments against the attached patch?
> 
> I'd suggest to compute (file-relative-name file) only once, and to add
> bug#27953 to the comment, but otherwise, looks good.

Attached an updated version :)

Clément.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.1.2: 0001-Follow-renames-in-vc-git-region-history.patch --]
[-- Type: text/x-patch; name="0001-Follow-renames-in-vc-git-region-history.patch", Size: 1288 bytes --]

From 78959b7c2bb7a13c4ab965e2617e3e9eec127b35 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Pit--Claudel?= <clement.pitclaudel@live.com>
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 | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index cc3e295..7d13dfe 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -1159,8 +1159,11 @@ 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))))
+  (let ((file-relname (file-relative-name file)))
+    (vc-git-command buffer 'async nil "log" "-p" "--follow"
+              (format "-L%d,%d:%s" lfrom lto file-relname)
+              ;; Must include one path spec for --follow to work (#27953)
+              file-relname)))
 
 (require 'diff-mode)
 
-- 
2.7.4


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* bug#27953: vc-region-history doesn't follow renames
  2017-08-05 13:06   ` Clément Pit--Claudel
@ 2017-08-05 17:05     ` Kyle Meyer
  2017-08-05 17:23       ` Eli Zaretskii
                         ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Kyle Meyer @ 2017-08-05 17:05 UTC (permalink / raw)
  To: Clément Pit--Claudel; +Cc: Andreas Schwab, Stefan Monnier, 27953

Clément Pit--Claudel <clement.pitclaudel@live.com> 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.

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.)

-- 
Kyle





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#27953: vc-region-history doesn't follow renames
  2017-08-05 17:05     ` Kyle Meyer
@ 2017-08-05 17:23       ` Eli Zaretskii
  2017-08-05 18:03         ` Andreas Schwab
  2017-08-05 17:27       ` Clément Pit--Claudel
  2017-08-05 18:08       ` Andreas Schwab
  2 siblings, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2017-08-05 17:23 UTC (permalink / raw)
  To: Kyle Meyer; +Cc: clement.pitclaudel, schwab, monnier, 27953

> From: Kyle Meyer <kyle@kyleam.com>
> Date: Sat, 05 Aug 2017 13:05:52 -0400
> Cc: Andreas Schwab <schwab@linux-m68k.org>,
> 	Stefan Monnier <monnier@IRO.UMontreal.CA>, 27953@debbugs.gnu.org
> 
> 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.)

I have 2.10 here, so maybe this was fixed later, but I don't see
renames followed when -L is used.  E.g., try this:

  git log -L77,83:admin/charsets/Makefile.in

You will see Git claiming the only version which changed that is the
one in which Makefile.in was created from Makefile.  Am I doing
something wrong, or expecting too much?





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#27953: vc-region-history doesn't follow renames
  2017-08-05 17:05     ` Kyle Meyer
  2017-08-05 17:23       ` Eli Zaretskii
@ 2017-08-05 17:27       ` Clément Pit--Claudel
  2017-08-05 20:55         ` Kyle Meyer
  2017-08-05 18:08       ` Andreas Schwab
  2 siblings, 1 reply; 12+ messages in thread
From: Clément Pit--Claudel @ 2017-08-05 17:27 UTC (permalink / raw)
  To: Kyle Meyer; +Cc: Andreas Schwab, Stefan Monnier, 27953-done


[-- Attachment #1.1: Type: text/plain, Size: 1033 bytes --]

On 2017-08-05 19:05, Kyle Meyer wrote:
> Clément Pit--Claudel <clement.pitclaudel@live.com> 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.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#27953: vc-region-history doesn't follow renames
  2017-08-05 17:23       ` Eli Zaretskii
@ 2017-08-05 18:03         ` Andreas Schwab
  2017-08-05 18:26           ` Eli Zaretskii
  0 siblings, 1 reply; 12+ messages in thread
From: Andreas Schwab @ 2017-08-05 18:03 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: clement.pitclaudel, Kyle Meyer, monnier, 27953

On Aug 05 2017, Eli Zaretskii <eliz@gnu.org> wrote:

> I have 2.10 here, so maybe this was fixed later, but I don't see
> renames followed when -L is used.  E.g., try this:
>
>   git log -L77,83:admin/charsets/Makefile.in
>
> You will see Git claiming the only version which changed that is the
> one in which Makefile.in was created from Makefile.  Am I doing
> something wrong, or expecting too much?

The problem is that admin/charsets/Makefile.in is only similar to
admin/charsets/Makefile by 32%, much below the default threshold.  Try
lisp/obsolete/html2text.el instead, for example.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#27953: vc-region-history doesn't follow renames
  2017-08-05 17:05     ` Kyle Meyer
  2017-08-05 17:23       ` Eli Zaretskii
  2017-08-05 17:27       ` Clément Pit--Claudel
@ 2017-08-05 18:08       ` Andreas Schwab
  2 siblings, 0 replies; 12+ messages in thread
From: Andreas Schwab @ 2017-08-05 18:08 UTC (permalink / raw)
  To: Kyle Meyer; +Cc: Clément Pit--Claudel, Stefan Monnier, 27953

On Aug 05 2017, Kyle Meyer <kyle@kyleam.com> wrote:

> 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.)

Note that the default for diff.renames has changed in 2.9.  Earlier
versions may need to add -M.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#27953: vc-region-history doesn't follow renames
  2017-08-05 18:03         ` Andreas Schwab
@ 2017-08-05 18:26           ` Eli Zaretskii
  2017-08-05 20:06             ` Kyle Meyer
  0 siblings, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2017-08-05 18:26 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: clement.pitclaudel, kyle, monnier, 27953

> From: Andreas Schwab <schwab@linux-m68k.org>
> Cc: Kyle Meyer <kyle@kyleam.com>,  clement.pitclaudel@live.com,  monnier@IRO.UMontreal.CA,  27953@debbugs.gnu.org
> Date: Sat, 05 Aug 2017 20:03:15 +0200
> 
> >   git log -L77,83:admin/charsets/Makefile.in
> >
> > You will see Git claiming the only version which changed that is the
> > one in which Makefile.in was created from Makefile.  Am I doing
> > something wrong, or expecting too much?
> 
> The problem is that admin/charsets/Makefile.in is only similar to
> admin/charsets/Makefile by 32%, much below the default threshold.

They look very similar to me...

What about doc/emacs/Makefile.in?  That should be almost 100% similar
to its origin in man/Makefile.in, when it was moved from there, but
"git -L" still cannot cross the boundary.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#27953: vc-region-history doesn't follow renames
  2017-08-05 18:26           ` Eli Zaretskii
@ 2017-08-05 20:06             ` Kyle Meyer
  0 siblings, 0 replies; 12+ messages in thread
From: Kyle Meyer @ 2017-08-05 20:06 UTC (permalink / raw)
  To: Eli Zaretskii, Andreas Schwab; +Cc: clement.pitclaudel, monnier, 27953

Eli Zaretskii <eliz@gnu.org> writes:

> What about doc/emacs/Makefile.in?  That should be almost 100% similar
> to its origin in man/Makefile.in, when it was moved from there, but
> "git -L" still cannot cross the boundary.

I believe the issue here is that the file was deleted in one commit
(19e364e29) and then added in another (8cf51b2c2).

-- 
Kyle





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#27953: vc-region-history doesn't follow renames
  2017-08-05 17:27       ` Clément Pit--Claudel
@ 2017-08-05 20:55         ` Kyle Meyer
  0 siblings, 0 replies; 12+ messages in thread
From: Kyle Meyer @ 2017-08-05 20:55 UTC (permalink / raw)
  To: Clément Pit--Claudel; +Cc: Andreas Schwab, Stefan Monnier, 27953-done

Clément Pit--Claudel <clement.pitclaudel@live.com> writes:

> On 2017-08-05 19:05, Kyle Meyer wrote:

[...]

>> 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).

OK, just to check with a concrete example: When you run

  git log -L37,57:test/lisp/ls-lisp-tests.el 9df49cddae

565cfd9f6 isn't listed as the earliest commit?

When I run that with Git 2.8.5 (and 2.13.3), I see 565cfd9f6 as the
earliest commit, indicating that Git does detect the rename
(test/lisp/ls-lisp.el => test/lisp/ls-lisp-tests.el).  I wasn't able to
try with your version, 2.7.4, because I couldn't get it to build.

-- 
Kyle





^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2017-08-05 20:55 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-04 15:12 bug#27953: vc-region-history doesn't follow renames Clément Pit--Claudel
2017-08-04 17:21 ` Stefan Monnier
2017-08-04 17:40   ` Andreas Schwab
2017-08-05 13:06   ` Clément Pit--Claudel
2017-08-05 17:05     ` Kyle Meyer
2017-08-05 17:23       ` Eli Zaretskii
2017-08-05 18:03         ` Andreas Schwab
2017-08-05 18:26           ` Eli Zaretskii
2017-08-05 20:06             ` Kyle Meyer
2017-08-05 17:27       ` Clément Pit--Claudel
2017-08-05 20:55         ` Kyle Meyer
2017-08-05 18:08       ` Andreas Schwab

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).