Function: magit-ediff-resolve-all
magit-ediff-resolve-all is an autoloaded, interactive and
byte-compiled function defined in magit-ediff.el.
Signature
(magit-ediff-resolve-all ARG1)
Documentation
Resolve all conflicts in the FILE at point using Ediff.
If there is no file at point or if it doesn't have any unmerged changes, then prompt for a file.
See info node (magit) Ediffing for more information about this and alternative commands.
Key Bindings
Source Code
;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/magit-ediff.el
;;;###autoload(autoload 'magit-ediff-resolve-all "magit-ediff" nil t)
(transient-define-suffix magit-ediff-resolve-all (file)
"Resolve all conflicts in the FILE at point using Ediff.
If there is no file at point or if it doesn't have any unmerged
changes, then prompt for a file.
See info node `(magit) Ediffing' for more information about this
and alternative commands."
:inapt-if-not #'magit-anything-unmerged-p
(interactive (list (magit-read-unmerged-file)))
(magit-with-toplevel
(let* ((dir (magit-gitdir))
(revA (or (magit-name-branch "HEAD")
(magit-commit-oid "HEAD")))
(revB (cl-find-if (##file-exists-p (expand-file-name % dir))
'("MERGE_HEAD" "CHERRY_PICK_HEAD" "REVERT_HEAD")))
(revB (or (magit-name-branch revB)
(magit-commit-oid revB)))
(revC (magit-commit-oid (magit-git-string "merge-base" revA revB)))
(fileA (magit--rev-file-name file revA revB))
(fileB (magit--rev-file-name file revB revA))
(fileC (or (magit--rev-file-name file revC revA)
(magit--rev-file-name file revC revB))))
;; Ediff assumes that the FILE where it is going to store the merge
;; result does not exist yet, so move the existing file out of the
;; way. If a buffer visits FILE, then we have to kill that upfront.
(when-let ((buffer (find-buffer-visiting file)))
(when (and (buffer-modified-p buffer)
(not (y-or-n-p (format "Save buffer %s %s? "
(buffer-name buffer)
"(cannot continue otherwise)"))))
(user-error "Abort"))
(kill-buffer buffer))
(let ((orig (concat file ".ORIG")))
(when (file-exists-p orig)
(rename-file orig (make-temp-name (concat orig "_"))))
(rename-file file orig))
(let ((setup (lambda ()
;; Use the same conflict marker style as Git uses.
(setq-local ediff-combination-pattern
'("<<<<<<< HEAD" A
,(format "||||||| %s" revC) Ancestor
"=======" B
,(format ">>>>>>> %s" revB)))))
(quit (lambda ()
;; For merge jobs Ediff switches buffer names around.
;; At this point `ediff-buffer-C' no longer refers to
;; the ancestor buffer but to the merge result buffer.
;; See (if ediff-merge-job ...) in `ediff-setup'.
(when (buffer-live-p ediff-buffer-C)
(with-current-buffer ediff-buffer-C
(save-buffer)
(save-excursion
(goto-char (point-min))
(unless (re-search-forward "^<<<<<<< " nil t)
(magit-stage-files (list file)))))))))
(magit-ediff-buffers
(magit-ediff--find-file revA fileA)
(magit-ediff--find-file revB fileB)
(and fileC (magit-ediff--find-file revC fileC))
setup quit file)))))