]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix gitmerge handling of automatic conflict reslution
authorGlenn Morris <rgm@gnu.org>
Wed, 13 Dec 2017 02:58:38 +0000 (21:58 -0500)
committerGlenn Morris <rgm@gnu.org>
Wed, 13 Dec 2017 02:58:38 +0000 (21:58 -0500)
* 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

index eddc72e679c35874e931e2f49aca81c4a873d9ab..13d92ac92bcef894a810bd661737c41c89b11210 100644 (file)
@@ -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))))