diff options
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/vc/vc-git.el | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 582de10..c75c61c 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -1111,6 +1111,19 @@ It is based on `log-edit-mode', and has Git-specific extensions." ("Sign-Off" . ,(boolean-arg-fn "--signoff"))) comment))) +(defmacro vc-git--with-apply-temp-to-staging (temp &rest body) + (declare (indent 1) (debug (symbolp body))) + `(let ((,temp (make-nearby-temp-file ,(format "git-%s" temp)))) + (unwind-protect (progn ,@body + ;; This uses `file-local-name' to strip the + ;; TRAMP prefix, not `file-relative-name', + ;; because we've had at least one problem + ;; report where relativizing the file name + ;; meant that Git failed to find it. + (vc-git-command nil 0 nil "apply" "--cached" + (file-local-name ,temp))) + (delete-file ,temp)))) + (defun vc-git-checkin (files comment &optional _rev) (let* ((file1 (or (car files) default-directory)) (root (vc-git-root file1)) @@ -1194,8 +1207,7 @@ It is based on `log-edit-mode', and has Git-specific extensions." (t (push file-name to-stash))) (setq pos (point)))))) (unless (string-empty-p vc-git-patch-string) - (let ((patch-file (make-nearby-temp-file "git-patch")) - ;; Temporarily countermand the let-binding at the + (let (;; Temporarily countermand the let-binding at the ;; beginning of this function. (coding-system-for-write (coding-system-change-eol-conversion @@ -1203,12 +1215,9 @@ It is based on `log-edit-mode', and has Git-specific extensions." ;; to have the Unix EOL format, because Git expects ;; that, even on Windows. (or pcsw vc-git-commits-coding-system) 'unix))) - (with-temp-file patch-file - (insert vc-git-patch-string)) - (unwind-protect - (vc-git-command nil 0 nil "apply" "--cached" - (file-local-name patch-file)) - (delete-file patch-file)))) + (vc-git--with-apply-temp-to-staging patch + (with-temp-file patch + (insert vc-git-patch-string))))) (when to-stash (vc-git--stash-staged-changes to-stash))) (let ((files (and only (not vc-git-patch-string) files)) (args (vc-git--log-edit-extract-headers comment)) @@ -1218,15 +1227,9 @@ It is based on `log-edit-mode', and has Git-specific extensions." (when (and msg-file (file-exists-p msg-file)) (delete-file msg-file)) (when to-stash - (let ((cached (make-nearby-temp-file "git-cached"))) - (unwind-protect - (progn - (with-temp-file cached - (vc-git-command t 0 nil "stash" "show" "-p")) - (vc-git-command nil 0 "apply" "--cached" - (file-local-name cached))) - (delete-file cached)) - (vc-git-command nil 0 nil "stash" "drop")))))) + (vc-git--with-apply-temp-to-staging cached + (with-temp-file cached + (vc-git-command t 0 nil "stash" "show" "-p"))))))) (when msg-file (let ((coding-system-for-write (or pcsw vc-git-commits-coding-system))) @@ -1282,6 +1285,8 @@ It is based on `log-edit-mode', and has Git-specific extensions." (unwind-protect (progn (vc-git-command nil 0 nil "read-tree" "HEAD") + ;; See `vc-git--with-apply-temp-to-staging' + ;; regarding use of `file-local-name'. (vc-git-command nil 0 nil "apply" "--cached" (file-local-name cached)) (setq tree (git-string "write-tree"))) |