]> 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>
Tue, 20 Dec 2022 23:09:12 +0000 (16:09 -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.

lisp/vc/vc-git.el

index 8f995021dcc1bbefbfd720b0124caf0568559ef4..0a4e9caa61408cb2efa6c7e93e5f1675a7822dcf 100644 (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)))))