GNU bug report logs - #5352
diff-jump-to-old-file inverts hunk application as well

Previous Next

Package: emacs;

Reported by: Michael Orlitzky <michael <at> orlitzky.com>

Date: Mon, 11 Jan 2010 06:34:01 UTC

Severity: normal

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Michael Orlitzky <michael <at> orlitzky.com>
To: bug-gnu-emacs <at> gnu.org
Subject: diff-jump-to-old-file inverts hunk application as well
Date: Sun, 10 Jan 2010 23:39:20 -0500
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.







This bug report was last modified 3 years and 8 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.