]> git.eshelyaron.com Git - emacs.git/commitdiff
* admin/gitmerge.el (gitmerge-resolve): Handle NEWS. (Bug#29366)
authorGlenn Morris <rgm@gnu.org>
Sat, 2 Dec 2017 03:06:40 +0000 (22:06 -0500)
committerGlenn Morris <rgm@gnu.org>
Sat, 2 Dec 2017 03:06:40 +0000 (22:06 -0500)
admin/gitmerge.el

index 3c65b0e6951f92ec4f5b2f43b8508d9db5f280bf..69f48b877af9f3255a0d1e921701fb03be5911fa 100644 (file)
@@ -307,25 +307,47 @@ Returns non-nil if conflicts remain."
             ;; (pop-to-buffer (current-buffer)) (debug 'before-resolve)
             ))
           ;; Try to resolve the conflicts.
-          (cond
-           ;; Generated files.
-           ((member file '("lisp/ldefs-boot.el"))
-            ;; We are in the file's buffer, so names are relative.
-            (call-process "git" nil t nil "reset" "--"
-                          (file-name-nondirectory file))
-            (call-process "git" nil t nil "checkout" "--"
-                          (file-name-nondirectory file))
-            (revert-buffer nil 'noconfirm))
-           (t
-            (goto-char (point-max))
-            (while (re-search-backward smerge-begin-re nil t)
-              (save-excursion
-                (ignore-errors
-                  (smerge-match-conflict)
-                  (smerge-resolve))))
-            ;; (when (derived-mode-p 'change-log-mode)
-            ;;   (pop-to-buffer (current-buffer)) (debug 'after-resolve))
-            (save-buffer)))
+          (let (temp)
+            (cond
+             ((and (equal file "etc/NEWS")
+                   (ignore-errors
+                     (setq temp
+                           (format "NEWS.%s"
+                                   (gitmerge-emacs-version gitmerge--from))))
+                   (file-exists-p temp)
+                   (or noninteractive
+                       (y-or-n-p "Try to fix NEWS conflict? ")))
+              (let ((relfile (file-name-nondirectory file))
+                    (tempfile (make-temp-file "gitmerge")))
+                (unwind-protect
+                    (progn
+                      (call-process "git" nil `(:file ,tempfile) nil "diff"
+                                    (format ":1:%s" file)
+                                    (format ":3:%s" file))
+                      (call-process "git" nil t nil "reset" "--" relfile)
+                      (call-process "git" nil t nil "checkout" "--" relfile)
+                      (revert-buffer nil 'noconfirm)
+                      (call-process "patch" tempfile nil nil temp)
+                      (call-process "git" nil t nil "add" "--" temp))
+                  (delete-file tempfile))))
+             ;; Generated files.
+             ((member file '("lisp/ldefs-boot.el"))
+              ;; We are in the file's buffer, so names are relative.
+              (call-process "git" nil t nil "reset" "--"
+                            (file-name-nondirectory file))
+              (call-process "git" nil t nil "checkout" "--"
+                            (file-name-nondirectory file))
+              (revert-buffer nil 'noconfirm))
+             (t
+              (goto-char (point-max))
+              (while (re-search-backward smerge-begin-re nil t)
+                (save-excursion
+                  (ignore-errors
+                    (smerge-match-conflict)
+                    (smerge-resolve))))
+              ;; (when (derived-mode-p 'change-log-mode)
+              ;;   (pop-to-buffer (current-buffer)) (debug 'after-resolve))
+              (save-buffer))))
           (goto-char (point-min))
           (prog1 (re-search-forward smerge-begin-re nil t)
             (unless exists (kill-buffer))))))))