aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Whitton2025-09-25 17:44:30 +0100
committerSean Whitton2025-09-25 17:44:30 +0100
commitb2e35d1d2c52d9d00809550702f9f4628651cfe2 (patch)
treed29942a2ec2f678aaeb106cdd354318391e9fb57
parent3536f1aa3371ab254e6cf96c2a21512049998644 (diff)
downloademacs-b2e35d1d2c52d9d00809550702f9f4628651cfe2.tar.gz
emacs-b2e35d1d2c52d9d00809550702f9f4628651cfe2.zip
vc-git--checkin: Avoid passing --ours to git-apply
* lisp/vc/vc-git.el (vc-git--with-apply-temp): New BUFFER param. (vc-git--checkin): Avoid passing --ours to git-apply.
-rw-r--r--lisp/vc/vc-git.el28
1 files changed, 23 insertions, 5 deletions
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 09f3d293bbe..9d655e34112 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -1122,7 +1122,8 @@ It is based on `log-edit-mode', and has Git-specific extensions."
1122 ("Sign-Off" . ,(boolean-arg-fn "--signoff"))) 1122 ("Sign-Off" . ,(boolean-arg-fn "--signoff")))
1123 comment))) 1123 comment)))
1124 1124
1125(cl-defmacro vc-git--with-apply-temp ((temp &rest args) &body body) 1125(cl-defmacro vc-git--with-apply-temp
1126 ((temp &optional buffer &rest args) &body body)
1126 (declare (indent 1)) 1127 (declare (indent 1))
1127 `(let ((,temp (make-nearby-temp-file ,(format "git-%s" temp)))) 1128 `(let ((,temp (make-nearby-temp-file ,(format "git-%s" temp))))
1128 (unwind-protect (progn ,@body 1129 (unwind-protect (progn ,@body
@@ -1131,7 +1132,7 @@ It is based on `log-edit-mode', and has Git-specific extensions."
1131 ;; because we've had at least one problem 1132 ;; because we've had at least one problem
1132 ;; report where relativizing the file name 1133 ;; report where relativizing the file name
1133 ;; meant that Git failed to find it. 1134 ;; meant that Git failed to find it.
1134 (vc-git-command nil 0 nil "apply" 1135 (vc-git-command ,buffer 0 nil "apply"
1135 ,@(or args '("--cached")) 1136 ,@(or args '("--cached"))
1136 (file-local-name ,temp))) 1137 (file-local-name ,temp)))
1137 (delete-file ,temp)))) 1138 (delete-file ,temp))))
@@ -1264,9 +1265,26 @@ It is an error to supply both or neither."
1264 ;; afterwards. 1265 ;; afterwards.
1265 (when patch-string 1266 (when patch-string
1266 (vc-git-command nil 0 nil "add" "--all") 1267 (vc-git-command nil 0 nil "add" "--all")
1267 (vc-git--with-apply-temp (patch "--3way" "--ours") 1268 (with-temp-buffer
1268 (with-temp-file patch 1269 (vc-git--with-apply-temp (patch t "--3way")
1269 (insert patch-string))) 1270 (with-temp-file patch
1271 (insert patch-string)))
1272 ;; We could delete the following if we could also pass
1273 ;; --ours to git-apply, but that is only available in
1274 ;; recent versions of Git. --3way is much older.
1275 (cl-loop
1276 initially (goto-char (point-min))
1277 ;; git-apply doesn't apply Git's usual quotation and
1278 ;; escape rules for printing file names so we can do
1279 ;; this simple regexp processing.
1280 ;; (Passing -z does not affect the relevant output.)
1281 while (re-search-forward "^U " nil t)
1282 collect (buffer-substring-no-properties (point)
1283 (pos-eol))
1284 into paths
1285 finally (when paths
1286 (vc-git-command nil 0 paths
1287 "checkout" "--ours"))))
1270 (vc-git-command nil 0 nil "reset")) 1288 (vc-git-command nil 0 nil "reset"))
1271 (when to-stash 1289 (when to-stash
1272 (vc-git--with-apply-temp (cached) 1290 (vc-git--with-apply-temp (cached)