From: Sean Whitton Date: Tue, 20 Dec 2022 22:53:19 +0000 (-0700) Subject: vc-git-checkin: Don't try to apply an empty patch X-Git-Tag: emacs-29.0.90~1041^2~4 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=baaa9f42e574aa5eceeb4b9354a42ccb8ff1969a;p=emacs.git 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 1424342225ef5b18c630364dd88e004f4ebb1c7f) --- diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index b5959d535c0..afaaa44e908 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -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)))))