Subject: bug#62731: 29.0.60; diff-apply-hunk doesn't work for creating new files

From: Juri Linkov <[email-masked]>
Date: Sat, 19 Oct 2024 21:11:05 +0300

>>> 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)
>
> Yes ok, let's try moving that to the caller. Pushed as commit
> 1374f20491b. A few other callers use non-nil 'reverse', but I suppose
> diff-test-hunk is not very useful for file creation/deletion.

Thanks for fixing, I confirm that now 'C-c C-c' doesn't go to the
backup file, only 'C-u C-c C-c' does.

> Note that the new (same as previous) behavior is to always visit the source
> buffer, newer the backup file's buffer. I hope that is the goal.

I forgot that diff-goto-source is not context-dependent for file diffs,
unlike for vc-diff.  So for file diffs it depends only on the prefix arg.
I don't know why is such inconsistency and whether it should be improved.