unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#5352: diff-jump-to-old-file inverts hunk application as well
@ 2010-01-11  4:39 Michael Orlitzky
  2022-05-09 14:32 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Orlitzky @ 2010-01-11  4:39 UTC (permalink / raw)
  To: bug-gnu-emacs

The custom diff-jump-to-old-file causes a reversal of the traditional
diff/patch behavior present in Emacs <= 22. From diff-mode.el, it seems
sort of intentional that this is the case; nevertheless, the new
behavior does not strike me as useful. From diff-mode.el:

(defun diff-apply-hunk (&optional reverse)
   "Apply the current hunk to the source file and go to the next.
   By default, the new source file is patched, but if the variable
   `diff-jump-to-old-file' is non-nil, then the old source file is
   patched instead (some commands, such as `diff-goto-source' can change
   the value of this variable when given an appropriate prefix argument).

Why should the default be to patch the new file, which is by definition
already patched? Take for example,

   gantu ~ $ cat new.txt
   Line 1
   Line 2
   Line 3
   Line 4
   gantu ~ $ cat source.txt
   Line 1
   Line 2
   Line 4
   gantu ~ $ diff -c source.txt new.txt > test.patch
   gantu ~ $ emacs -nw test.patch

(The diff -c accomplishes the same thing as M-x diff would within
Emacs). In this case, when the patch is opened, it is expected that M-x
diff-apply-hunk will patch the source (old) file to the new. That is, it
should add "Line 3" to the third line of the source file. This is how
Emacs <= 22 worked.

With v23, the new behavior is that M-x diff-apply-hunk will attempt to
apply the hunk to new.txt which, of course, already contains that line.
Even if one performs the diff within Emacs and explicitly chooses the
source/new files, the default behavior is to attempt to re-patch the new
file.









^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#5352: diff-jump-to-old-file inverts hunk application as well
  2010-01-11  4:39 bug#5352: diff-jump-to-old-file inverts hunk application as well Michael Orlitzky
@ 2022-05-09 14:32 ` Lars Ingebrigtsen
  2022-05-09 16:18   ` Michael Orlitzky
  0 siblings, 1 reply; 3+ messages in thread
From: Lars Ingebrigtsen @ 2022-05-09 14:32 UTC (permalink / raw)
  To: Michael Orlitzky; +Cc: 5352

Michael Orlitzky <michael@orlitzky.com> writes:

> The custom diff-jump-to-old-file causes a reversal of the traditional
> diff/patch behavior present in Emacs <= 22. From diff-mode.el, it seems
> sort of intentional that this is the case; nevertheless, the new
> behavior does not strike me as useful. From diff-mode.el:
>
> (defun diff-apply-hunk (&optional reverse)
>   "Apply the current hunk to the source file and go to the next.
>   By default, the new source file is patched, but if the variable
>   `diff-jump-to-old-file' is non-nil, then the old source file is
>   patched instead (some commands, such as `diff-goto-source' can change
>   the value of this variable when given an appropriate prefix argument).
>
> Why should the default be to patch the new file, which is by definition
> already patched? Take for example,

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

I think the logic here is when you have a diff that's been partially
applied, so that the "new" file isn't literally the one you've already
applied the patch to.

In that case, you usually want to apply the hunk to the new file, and
not the old one.

In any case, the current behaviour has been in place for a decade, so I
think it's too late to change it now (because that would break things
for people that's used to the direction it works in now).

So I'm closing this bug report.

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





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#5352: diff-jump-to-old-file inverts hunk application as well
  2022-05-09 14:32 ` Lars Ingebrigtsen
@ 2022-05-09 16:18   ` Michael Orlitzky
  0 siblings, 0 replies; 3+ messages in thread
From: Michael Orlitzky @ 2022-05-09 16:18 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 5352

On Mon, 2022-05-09 at 16:32 +0200, Lars Ingebrigtsen wrote:
> 
> So I'm closing this bug report.
> 

This seems to be working like I expect it to now, so maybe the issue
was elsewhere and has been fixed in the meantime.






^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-05-09 16:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-11  4:39 bug#5352: diff-jump-to-old-file inverts hunk application as well Michael Orlitzky
2022-05-09 14:32 ` Lars Ingebrigtsen
2022-05-09 16:18   ` Michael Orlitzky

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).