1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-24 07:20:37 +00:00

* admin/gitmerge.el (gitmerge-resolve): Check NEWS patch exit status.

This commit is contained in:
Glenn Morris 2018-10-24 13:20:01 -04:00
parent 00027ff9d0
commit 129ffc2761

View File

@ -275,6 +275,9 @@ should not be skipped."
(setq found (cdr skip)))) (setq found (cdr skip))))
found)) found))
(defvar change-log-start-entry-re) ; in add-log, which defines change-log-mode
(declare-function add-log-iso8601-time-string "add-log" ())
(defun gitmerge-resolve (file) (defun gitmerge-resolve (file)
"Try to resolve conflicts in FILE with smerge. "Try to resolve conflicts in FILE with smerge.
Returns non-nil if conflicts remain." Returns non-nil if conflicts remain."
@ -323,6 +326,9 @@ Returns non-nil if conflicts remain."
;; Try to resolve the conflicts. ;; Try to resolve the conflicts.
(let (temp) (let (temp)
(cond (cond
;; FIXME when merging release branch to master, we still
;; need to detect and handle the case where NEWS was modified
;; without a conflict. We should abort if NEWS gets changed.
((and (equal file "etc/NEWS") ((and (equal file "etc/NEWS")
(ignore-errors (ignore-errors
(setq temp (setq temp
@ -332,18 +338,21 @@ Returns non-nil if conflicts remain."
(or noninteractive (or noninteractive
(y-or-n-p "Try to fix NEWS conflict? "))) (y-or-n-p "Try to fix NEWS conflict? ")))
(let ((relfile (file-name-nondirectory file)) (let ((relfile (file-name-nondirectory file))
(tempfile (make-temp-file "gitmerge"))) (patchfile (concat temp "-gitmerge.patch")))
(unwind-protect (call-process "git" nil `(:file ,patchfile) nil "diff"
(format ":1:%s" file)
(format ":3:%s" file))
(if (eq 0 (call-process "patch" patchfile nil nil temp))
(progn (progn
(call-process "git" nil `(:file ,tempfile) nil "diff" ;; We intentionally use a non-temporary name for this
(format ":1:%s" file) ;; file, and only delete it if applied successfully.
(format ":3:%s" file)) (delete-file patchfile)
(call-process "git" nil t nil "add" "--" temp)
(call-process "git" nil t nil "reset" "--" relfile) (call-process "git" nil t nil "reset" "--" relfile)
(call-process "git" nil t nil "checkout" "--" relfile) (call-process "git" nil t nil "checkout" "--" relfile)
(revert-buffer nil 'noconfirm) (revert-buffer nil 'noconfirm))
(call-process "patch" tempfile nil nil temp) ;; The conflict markers remain so we return non-nil.
(call-process "git" nil t nil "add" "--" temp)) (message "Failed to fix NEWS conflict"))))
(delete-file tempfile))))
;; Generated files. ;; Generated files.
((member file '("lisp/ldefs-boot.el")) ((member file '("lisp/ldefs-boot.el"))
;; We are in the file's buffer, so names are relative. ;; We are in the file's buffer, so names are relative.