]> git.eshelyaron.com Git - emacs.git/commitdiff
vc-git-checkin: Don't try to apply an empty patch
authorSean Whitton <spwhitton@spwhitton.name>
Tue, 20 Dec 2022 22:53:19 +0000 (15:53 -0700)
committerSean Whitton <spwhitton@spwhitton.name>
Thu, 22 Dec 2022 20:37:12 +0000 (13:37 -0700)
* 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)

lisp/vc/vc-git.el

index b5959d535c03e5f44378ef450bdd5298dca7d862..afaaa44e9081d11a51e26b5e54d95d18c0260192 100644 (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)))))