2

I am using smerge to resolve conflicts in order to apply merge. I am applying one by one for smerge-keep-mine to all conflicts, which I belive equivalent for git merge --strategy-option ours

[Q] Is it possible to apply smerge-keep-mine for all the conflicts by using a single keybinding?

config:

(defun smerge-try-smerge ()
  (save-excursion
    (goto-char (point-min))
    (when (re-search-forward "^<<<<<<< " nil t)
      (require 'smerge-mode)
      (smerge-mode 1))))
(add-hook 'find-file-hook 'smerge-try-smerge t)
(add-hook 'after-revert-hook 'smerge-try-smerge t)

(defun smerge-next-safe ()
    "returns t on success, nil otherwise"
  (condition-case err
      (not (smerge-next))
    ('error
     nil)))

(require 'vc)
(defun next-conflict ()  ;; key-binding
  (interactive)
  (let ((buffer (current-buffer)))
    (when (not (smerge-next-safe))
      (vc-find-conflicted-file)
      (if (eq buffer (current-buffer))
          (message "No conflicts found")
        (goto-char 0)
        (smerge-next-safe)))))

;; smerge-keep-current bound to smerge-command-prefix (RET) to keep the version the cursor is on.
;; smerge-keep-mine bound to smerge-command-prefix (m) to keep your changes.
;; smerge-keep-other bound to smerge-command-prefix (o) to keep other changes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.