]> git.eshelyaron.com Git - emacs.git/commit
Support file creation and deletion in diff-apply-hunk
authorDmitry Gutov <dmitry@gutov.dev>
Mon, 7 Oct 2024 23:25:14 +0000 (02:25 +0300)
committerEshel Yaron <me@eshelyaron.com>
Mon, 14 Oct 2024 17:34:47 +0000 (19:34 +0200)
commit2aa53d9299f0f3ca72b182d21b3d42bc2edc7980
treef71958b3312c5a98e9db1c1f42a1855020613d89
parent48050fdb4bb190be141fd006ec34c04dfc0c288d
Support file creation and deletion in diff-apply-hunk

* lisp/vc/diff-mode.el (diff-find-file-name): Allow entering
non-existing file name when the corresponding hunk is of type
"create file" (bug#62731).  Default to file name with deleted
prefix if diff-buffer-type is Git or Hg.  Make sure not to add
such input to diff-remembered-files-alist, it would be hard to
change otherwise in case of typo.
(diff-setup-buffer-type):
Match against the diff header common to 'hg diff' output.
(diff-find-source-location): Look at the other source when the
buffer is applied in reverse.
(diff-apply-hunk): Delect file deletion and pass a different
argument to 'diff-find-source-location' in such case.  Bind
diff-vc-backend to nil to avoid older revision buffer being
returned.  In the end, offer to delete the file if the hunk was of
corresponding type and matched the existing contents.

* etc/NEWS: Mention the new capability.

(cherry picked from commit 2d139141a6c249691a50ade9c8d08dc35fcdf456)
etc/NEWS
lisp/vc/diff-mode.el