1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-30 04:10:54 -08:00

vc-git-checkin: Don't try to apply an empty patch

* lisp/vc/vc-git.el (vc-git-checkin): Don't try to apply an empty
patch to the index, because in that case 'git apply' fails.

(cherry picked from commit 1424342225)
This commit is contained in:
Sean Whitton 2022-12-20 15:53:19 -07:00
parent 0754173c92
commit baaa9f42e5

View file

@ -1041,12 +1041,13 @@ It is based on `log-edit-mode', and has Git-specific extensions."
(string-replace file-diff "" vc-git-patch-string))
(user-error "Index not empty"))
(setq pos (point))))))
(let ((patch-file (make-nearby-temp-file "git-patch")))
(with-temp-file patch-file
(insert vc-git-patch-string))
(unwind-protect
(vc-git-command nil 0 patch-file "apply" "--cached")
(delete-file patch-file))))
(unless (string-empty-p vc-git-patch-string)
(let ((patch-file (make-nearby-temp-file "git-patch")))
(with-temp-file patch-file
(insert vc-git-patch-string))
(unwind-protect
(vc-git-command nil 0 patch-file "apply" "--cached")
(delete-file patch-file)))))
(cl-flet ((boolean-arg-fn
(argument)
(lambda (value) (when (equal value "yes") (list argument)))))