emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 8c91d31: Fix gitmerge handling of automatic conflic


From: Glenn Morris
Subject: [Emacs-diffs] master 8c91d31: Fix gitmerge handling of automatic conflict reslution
Date: Tue, 12 Dec 2017 21:58:47 -0500 (EST)

branch: master
commit 8c91d31beab0234e8a187864df46af543022c656
Author: Glenn Morris <address@hidden>
Commit: Glenn Morris <address@hidden>

    Fix gitmerge handling of automatic conflict reslution
    
    * admin/gitmerge.el (gitmerge-resolve): Reenable NEWS handling.
    (gitmerge-resolve-unmerged): Commit after successful resolution.
    (gitmerge-commit): New function, extracted from gitmerge-maybe-resume.
    (gitmerge-maybe-resume): Use gitmerge-commit.
---
 admin/gitmerge.el | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/admin/gitmerge.el b/admin/gitmerge.el
index eddc72e..13d92ac 100644
--- a/admin/gitmerge.el
+++ b/admin/gitmerge.el
@@ -316,11 +316,7 @@ Returns non-nil if conflicts remain."
                                    (gitmerge-emacs-version gitmerge--from))))
                    (file-exists-p temp)
                    (or noninteractive
-                       (and
-                        (y-or-n-p "Try to fix NEWS conflict? ")
-                        ;; FIXME
-                        (y-or-n-p "This is buggy, really try? ")
-                        )))
+                       (y-or-n-p "Try to fix NEWS conflict? ")))
               (let ((relfile (file-name-nondirectory file))
                     (tempfile (make-temp-file "gitmerge")))
                 (unwind-protect
@@ -431,7 +427,9 @@ Throw an user-error if we cannot resolve automatically."
              (setq conflicted t)
            ;; Mark as resolved
            (call-process "git" nil t nil "add" file)))
-       (when conflicted
+       (if (not conflicted)
+           (and files (not (gitmerge-commit))
+                (error "Error committing resolution - fix it manually"))
          (with-current-buffer (get-buffer-create gitmerge-warning-buffer)
            (erase-buffer)
            (insert "For the following files, conflicts could\n"
@@ -457,6 +455,12 @@ Throw an user-error if we cannot resolve automatically."
                    "diff" "--name-only")
       (zerop (buffer-size))))
 
+(defun gitmerge-commit ()
+  "Commit, and return non-nil if it succeeds."
+  (with-current-buffer (get-buffer-create gitmerge-output-buffer)
+    (erase-buffer)
+    (eq 0 (call-process "git" nil t nil "commit" "--no-edit"))))
+
 (defun gitmerge-maybe-resume ()
   "Check if we have to resume a merge.
 If so, add no longer conflicted files and commit."
@@ -478,11 +482,8 @@ If so, add no longer conflicted files and commit."
        (gitmerge-resolve-unmerged)
        ;; Commit the merge.
        (when mergehead
-         (with-current-buffer (get-buffer-create gitmerge-output-buffer)
-           (erase-buffer)
-           (unless (zerop (call-process "git" nil t nil
-                                        "commit" "--no-edit"))
-             (error "Git error during merge - fix it manually"))))
+         (or (gitmerge-commit)
+             (error "Git error during merge - fix it manually")))
        ;; Successfully resumed.
        t))))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]