From: Juri Linkov <juri@linkov.net>
To: Dmitry Gutov <dmitry@gutov.dev>
Cc: 66113@debbugs.gnu.org
Subject: bug#66113: Apply the entire diff buffer
Date: Fri, 22 Sep 2023 18:48:49 +0300 [thread overview]
Message-ID: <86msxep69i.fsf@mail.linkov.net> (raw)
In-Reply-To: <9cb6c329-8a81-414a-00e0-b3d8aa73d037@gutov.dev> (Dmitry Gutov's message of "Fri, 22 Sep 2023 16:49:29 +0300")
>>>> + (t
>>>> + (dolist (buf buffers)
>>>> + (with-current-buffer buf
>>>> + (display-buffer buf)))
>>>> + (message "%d hunks failed; no buffers saved" failures)))))
>>>
>>> What happens next in this case? How do you undo in the buffers that had the
>>> patch hunks already applied?
>> Manually, like in case of ediff-patch-buffer.
>
> I've never used this, so I don't understand.
ediff-patch-buffer is an example when trying to roll back a mess
creates more mess with .orig/.rej files.
>>> Any change you wanted to work on the idea of the "atomic rollback" as well?
>> This would be an unreliable feature: in case of diff-apply creates
>> a mess,
>> such automatic undo can create more mess, because there are many different
>> strategies to undo the mess such as using undo-auto-amalgamate, or
>> applying the reverse diff partially, doing more damage in case when
>> buffers were already modified before diff-apply.
>
> How about we save the tips of buffer-undo-list, then in case the buffer
> needs reverting, basically 'undo' each of the buffers until the saved "tip"
> is reached? I don't have a quick code anippet, but that seems doable.
Maybe, but I definitely won't use such an option.
>> But fortunately the need to undo will be extremely rare, because
>> when patch hunks are already applied, it reports the failure,
>> but doesn't modify the source buffer. Therefore there is
>> nothing to undo!
>
> The problem situations is, of course, when one of the hunks (somewhere in
> the middle or near the end) fails to apply cleanly or at all.
Indeed, this is a problematic case when one of the hunks fails
whereas all other hunks are applied cleanly. This sometimes happens
when receiving an external patch, but the source already changed.
> Another approach would be to first go through the patch and check that all
> hunks apply without problems, and then, on the second pass, actually apply
> them.
This is a better option, thanks for the idea, will try to do this with
'diff-test-hunk' in a loop.
next prev parent reply other threads:[~2023-09-22 15:48 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-20 6:46 bug#66113: Apply the entire diff buffer Juri Linkov
2023-09-22 1:38 ` Dmitry Gutov
2023-09-22 6:45 ` Juri Linkov
2023-09-22 13:49 ` Dmitry Gutov
2023-09-22 15:48 ` Juri Linkov [this message]
2023-09-23 17:52 ` Juri Linkov
2023-09-24 1:34 ` Dmitry Gutov
2023-09-24 7:34 ` Juri Linkov
2023-09-24 10:58 ` Dmitry Gutov
2023-09-25 17:49 ` Juri Linkov
2023-09-25 23:07 ` Dmitry Gutov
2023-09-27 17:36 ` Juri Linkov
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=86msxep69i.fsf@mail.linkov.net \
--to=juri@linkov.net \
--cc=66113@debbugs.gnu.org \
--cc=dmitry@gutov.dev \
/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.