GNU bug report logs - #1537
diff-mode for git patches trouble

Previous Next

Package: emacs;

Reported by: Dmitriy Blinov <bda <at> mns.spb.ru>

Date: Thu, 11 Dec 2008 13:15:02 UTC

Severity: wishlist

Merged with 1536

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 1537 in the body.
You can then email your comments to 1537 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#1537; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to Dmitriy Blinov <bda <at> mns.spb.ru>:
New bug report received and forwarded. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Dmitriy Blinov <bda <at> mns.spb.ru>
To: bug-gnu-emacs <at> gnu.org
Subject: diff-mode for git patches trouble
Date: Thu, 11 Dec 2008 16:08:59 +0300
There is the problem then I'm trying to edit git-generated patches in 
emacs diff-mode.

git patches look like:
---
hello.txt |    2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/hello.txt b/hello.txt
index 55bf894..25a09cc 100644
--- a/hello.txt
+++ b/hello.txt
@@ -6,7 +6,7 @@
5
6
7
-8
+8 8
9
10
11
-- 
1.5.6.5


The last but one line is two minuses by default. And diff-mode 
recognizes  first minus as  deleted  string.
Therefore  when we change some strings in patch, emacs creates malformed 
hunk offset.
It will be @@ -6,8 +6,7 @@ insead of correct @@ -6,7 +6,7 @@ after patch 
edition (if we don't delete/create strings).

Is it possible to fix this harm or I should append whitespace before 
"--" string  always?





Merged 1536 1537. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> emacsbugs.donarmstrong.com. (Thu, 11 Dec 2008 18:05:07 GMT) Full text and rfc822 format available.

Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#1537; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #12 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Dmitriy Blinov <bda <at> mns.spb.ru>
Cc: 1537 <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
Subject: Re: bug#1537: diff-mode for git patches trouble
Date: Thu, 11 Dec 2008 14:04:58 -0500
> The last but one line is two minuses by default.  And diff-mode
> recognizes first minus as deleted string.  Therefore when we change
> some strings in patch, emacs creates malformed hunk offset.  It will
> be @@ -6,8 +6,7 @@ insead of correct @@ -6,7 +6,7 @@ after patch
> edition (if we don't delete/create strings).

> Is it possible to fix this harm or I should append whitespace before "--"
> string always?

Given the way the code is currently implemented, it's difficult to fix
this problem.  One of the problem is that we currently don't do anything
special before the user modifies the buffer.  Not even in
a before-change-function.  So by the time we try to update the hunk
header, the buffer has been modified and we don't know what it looked
like before.
I.e. to fix it we'll need to mark the end-of-hunk before the buffer is
really modified.  E.g. by automatically adding an empty line at
end-of-hunk (or a marker).

Of course, in the general case the problem is insoluble (e.g. if you
edit the line with the "--"), but clearly we can do better in the
"normal" case.


        Stefan





Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#1537; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#1537; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to Dmitriy Blinov <bda <at> mns.spb.ru>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #22 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Dmitriy Blinov <bda <at> mns.spb.ru>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 1537 <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
Subject: Re: bug#1537: diff-mode for git patches trouble
Date: Fri, 12 Dec 2008 09:57:19 +0300
> Of course, in the general case the problem is insoluble (e.g. if you
> edit the line with the "--"), but clearly we can do better in the
> "normal" case.
>
>
>         Stefan
Probably it was incorrect to post this feature here.  In fact it's git 
problem but not emacs.





Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#1537; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to Dmitriy Blinov <bda <at> mns.spb.ru>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#1537; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to Stefan Monnier <monnier <at> IRO.UMontreal.CA>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #32 received at 1537 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Dmitriy Blinov <bda <at> mns.spb.ru>
Cc: 1537 <at> debbugs.gnu.org
Subject: Re: bug#1537: diff-mode for git patches trouble
Date: Fri, 12 Dec 2008 14:08:19 -0500
severity 1537 wishlist
thanks

>> Of course, in the general case the problem is insoluble (e.g. if you
>> edit the line with the "--"), but clearly we can do better in the
>> "normal" case.
> Probably it was incorrect to post this feature here.  In fact it's git
> problem but not emacs.

No, it definitely has its place here: while it's true that Git's output
is not very friendly to patch-editing as supported by diff-mode, the
output is formally correct and unambiguous.
And your example of changes is also unambiguous, so you can definitely
argue that Emacs should behave correctly in this case.


        Stefan



Severity set to `wishlist' from `normal' Request was from Stefan Monnier <monnier <at> IRO.UMontreal.CA> to control <at> emacsbugs.donarmstrong.com. (Fri, 12 Dec 2008 19:15:04 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#1537; Package emacs. (Sun, 16 Aug 2020 17:01:02 GMT) Full text and rfc822 format available.

Message #37 received at 1537 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: Dmitriy Blinov <bda <at> mns.spb.ru>
Cc: 1537 <at> debbugs.gnu.org, 1536 <at> debbugs.gnu.org
Subject: Re: bug#1537: diff-mode for git patches trouble
Date: Sun, 16 Aug 2020 10:00:02 -0700
Dmitriy Blinov <bda <at> mns.spb.ru> writes:

> There is the problem then I'm trying to edit git-generated patches in
> emacs diff-mode.
>
> git patches look like:
> ---
> hello.txt |    2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/hello.txt b/hello.txt
> index 55bf894..25a09cc 100644
> --- a/hello.txt
> +++ b/hello.txt
> @@ -6,7 +6,7 @@
> 5
> 6
> 7
> -8
> +8 8
> 9
> 10
> 11

(That was 11 years ago.)

I can't reproduce this on current master.  The numbers seem to update
correctly, as ar as I'm understanding from:

    https://stackoverflow.com/questions/6508651/what-do-the-numbers-on-a-git-diff-header-mean

It would be useful if someone could double check this finding in case
there is something I'm missing.  It could be quickly verified using:

    git format-patch -1 ; ./src/emacs -Q *patch

And then edit any line in a patch to see if the numbers update correctly.

Best regards,
Stefan Kangas




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#1537; Package emacs. (Wed, 14 Oct 2020 06:09:01 GMT) Full text and rfc822 format available.

Message #40 received at 1537 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Stefan Kangas <stefan <at> marxist.se>
Cc: 1537 <at> debbugs.gnu.org, 1536 <at> debbugs.gnu.org, Dmitriy Blinov <bda <at> mns.spb.ru>
Subject: Re: bug#1536: bug#1537: diff-mode for git patches trouble
Date: Wed, 14 Oct 2020 08:08:17 +0200
Stefan Kangas <stefan <at> marxist.se> writes:

> I can't reproduce this on current master.  The numbers seem to update
> correctly, as ar as I'm understanding from:
>
>     https://stackoverflow.com/questions/6508651/what-do-the-numbers-on-a-git-diff-header-mean
>
> It would be useful if someone could double check this finding in case
> there is something I'm missing.  It could be quickly verified using:
>
>     git format-patch -1 ; ./src/emacs -Q *patch
>
> And then edit any line in a patch to see if the numbers update correctly.

Yup; seems to update correctly for me, too, so I'm closing this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug closed, send any further explanations to 1536 <at> debbugs.gnu.org and Dmitriy Blinov <bda <at> mns.spb.ru> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Wed, 14 Oct 2020 06:09:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 11 Nov 2020 12:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 164 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.