all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Dmitry Gutov <dmitry@gutov.dev>
Cc: sbaugh@catern.com, 62731@debbugs.gnu.org
Subject: bug#62731: 29.0.60; diff-apply-hunk doesn't work for creating new files
Date: Thu, 17 Oct 2024 20:56:38 +0300	[thread overview]
Message-ID: <86ttdazk89.fsf@mail.linkov.net> (raw)
In-Reply-To: <1cc9143d-96c2-47d8-afaa-70c4e766a953@gutov.dev> (Dmitry Gutov's message of "Wed, 16 Oct 2024 22:37:40 +0300")

>>>> All right, the attached seems to support both creation and deletion,
>>>> including applying hunks in reverse direction.
>>>> Things got trickier but not by a lot.
>>>
>>> Now pushed to master, seems useful enough. Let's see if some unforeseen
>>> problems are reported.
>> 
>> This change broke diff of files:
>> 
>> @@ -1957,7 +1970,7 @@ diff-find-source-location
>>                                   diff-context-mid-hunk-header-re nil t)
>>   			 (error "Can't find the hunk separator"))
>>   		       (match-string 1)))))
>> -	   (file (or (diff-find-file-name other noprompt)
>> +	   (file (or (diff-find-file-name (xor other reverse) noprompt)
>>                        (error "Can't find the file")))
>>   	   (revision (and other diff-vc-backend
>>                             (if reverse (nth 1 diff-vc-revisions)
>> 
>> So after 'dired-backup-diff', typing 'C-c C-c' visits wrong file:
>> visits the backup when point is on the file line, and vice versa:
>> visits the file when point is on backup file line.
>
> Thanks for reporting.
>
> Do you think we can fix it this way?
>
> diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
> index cfa90d380ad..374df3ee2cb 100644
> --- a/lisp/vc/diff-mode.el
> +++ b/lisp/vc/diff-mode.el
> @@ -2196,7 +2196,7 @@ diff-goto-source
>     ;; This is a convenient detail when using smerge-diff.
>     (if event (posn-set-point (event-end event)))
>     (let ((buffer (when event (current-buffer)))
> -        (reverse (not (save-excursion (beginning-of-line) (looking-at "[-<]")))))
> +        (reverse (not (save-excursion (beginning-of-line) (looking-at "[+<]")))))
>       (pcase-let ((`(,buf ,_line-offset ,pos ,src ,_dst ,_switched)
>                    (diff-find-source-location other-file reverse)))
>         (pop-to-buffer buf)

I don't understand this change.

> Otherwise, I don't quite understand the intent behind that line. But it 
> might have been masking the problem which I (hopefully) fixed in the 
> hunk you quoted/

There is already one 'xor' here.  Maybe the second 'xor' not needed:

(defun diff-find-source-location (&optional other-file reverse noprompt)
    ...
    (let* ((other (xor other-file diff-jump-to-old-file))
    ...
	   (file (or (diff-find-file-name (xor other reverse) noprompt)





  reply	other threads:[~2024-10-17 17:56 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-09  1:14 bug#62731: 29.0.60; diff-apply-hunk doesn't work for creating new files sbaugh
2024-10-02  0:41 ` Dmitry Gutov
2024-10-02  6:58   ` Eli Zaretskii
2024-10-02 18:57     ` Dmitry Gutov
2024-10-02 19:41       ` Eli Zaretskii
2024-10-02 19:48         ` Dmitry Gutov
2024-10-03  5:47           ` Eli Zaretskii
2024-10-04  1:14             ` Dmitry Gutov
2024-10-07 23:28               ` Dmitry Gutov
     [not found] ` <handler.62731.D62731.172834375714682.notifdone@debbugs.gnu.org>
2024-10-15 16:13   ` Juri Linkov
2024-10-16 19:37     ` Dmitry Gutov
2024-10-17 17:56       ` Juri Linkov [this message]
2024-10-19  1:29         ` Dmitry Gutov
2024-10-19 18:11           ` 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=86ttdazk89.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=62731@debbugs.gnu.org \
    --cc=dmitry@gutov.dev \
    --cc=sbaugh@catern.com \
    /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.