1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-26 07:33:47 +00: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.
This commit is contained in:
Sean Whitton 2022-12-20 15:53:19 -07:00
parent 962bdfcdfe
commit 1424342225

View File

@ -1056,12 +1056,13 @@ It is based on `log-edit-mode', and has Git-specific extensions."
(vc-git-command nil 0 file-name "reset" "-q" "--"))
(t (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)))))