From: Juri Linkov <juri@linkov.net>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Dmitry Gutov <dmitry@gutov.dev>, Tomas Nordin <tomasn@posteo.net>,
72556@debbugs.gnu.org
Subject: bug#72556: 29.1.90; vc-diff does not undo hunk in end of source file
Date: Mon, 19 Aug 2024 19:49:05 +0300 [thread overview]
Message-ID: <861q2lhrxc.fsf@mail.linkov.net> (raw)
In-Reply-To: <86ttfj32wk.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 17 Aug 2024 12:38:19 +0300")
>> To reproduce:
>>
>> $ mkdir apply
>> $ cd apply
>> $ echo "first line of code" > example.file
>> $ git init
>> $ git add .
>> $ git commit -m 'init'
>> $ echo "last line of code" >> example.file
>> $ emacs -Q example.file
>>
>> C-x v =
>> n
>> C-c C-a
>>
>> The hunk is applied in the source buffer.
>
> Juri and Dmitry, any comments or suggestions?
I don't know why it fails at the end, so I tried to debug 'diff-apply-hunk',
and found that the problem is in these lines of 'diff-find-source-location':
;; FIXME: Check for case where both OLD and NEW are found.
(pos (or (diff-find-text (car old))
When the hunk is at the beginning/end of the diff buffer,
then it misses the top/bottom part of the context,
so 'diff-find-text' wrongly matches it because it fails
to see any changes in it due to insufficient context,
and returns switched=nil.
A possible solution would be to add a condition to detect the case
when the hunk is at the beginning/end of the diff buffer.
next prev parent reply other threads:[~2024-08-19 16:49 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-10 12:11 bug#72556: 29.1.90; vc-diff does not undo hunk in end of source file Tomas Nordin
2024-08-17 9:38 ` Eli Zaretskii
2024-08-19 16:49 ` Juri Linkov [this message]
2024-08-31 8:09 ` Eli Zaretskii
2024-09-14 7:35 ` Eli Zaretskii
2024-09-14 15:47 ` Dmitry Gutov
2024-09-14 15:50 ` Dmitry Gutov
2024-09-15 10:41 ` Tomas Nordin
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=861q2lhrxc.fsf@mail.linkov.net \
--to=juri@linkov.net \
--cc=72556@debbugs.gnu.org \
--cc=dmitry@gutov.dev \
--cc=eliz@gnu.org \
--cc=tomasn@posteo.net \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.