Add smerge support to the git back end.

This commit is contained in:
Eric S. Raymond 2014-08-13 04:42:33 -04:00
parent 2cc441ecbf
commit b5354531ba
2 changed files with 29 additions and 4 deletions

View file

@ -1,8 +1,13 @@
2014-08-13 Eric S. Raymond <esr@thyrsus.com>
* vc/vc-git.el (vc-git-conflicted-files): Integrate Rüdiger
Sonderfeld's code for detecting conflicted files using a status
listing. Useful in itself and a step towards better smerge
* vc/vc.git.el: (vc-git-find-file-hook): New function. Adds
support for calling smerge on a conflicted file, and calling git
add when there are no longer conflict markers in a saved file.
This is a completed version of Rüdiger Sonderfeld's proposal.
* vc/vc-git.el (vc-git-conflicted-files): New function. Integrate
Rüdiger Sonderfeld's code for detecting conflicted files using a
status listing. Useful in itself and a step towards better smerge
support.
2014-08-12 Stefan Monnier <monnier@iro.umontreal.ca>

View file

@ -101,7 +101,7 @@
;; - clear-headers () NOT NEEDED
;; - delete-file (file) OK
;; - rename-file (old new) OK
;; - find-file-hook () NOT NEEDED
;; - find-file-hook () OK
;; - conflicted-files OK
;;; Code:
@ -786,6 +786,26 @@ This prompts for a branch to merge from."
"DU" "AA" "UU"))
(push file files)))))))
(defun vc-git-resolve-when-done ()
"Call \"git add\" if the conflict markers have been removed."
(save-excursion
(goto-char (point-min))
(unless (re-search-forward "^<<<<<<< " nil t)
(vc-git-command nil 0 buffer-file-name "add")
;; Remove the hook so that it is not called multiple times.
(remove-hook 'after-save-hook 'vc-git-resolve-when-done t))))
(defun vc-git-find-file-hook ()
"Activate `smerge-mode' if there is a conflict."
(when (and buffer-file-name
(vc-git-conflicted-files buffer-file-name)
(save-excursion
(goto-char (point-min))
(re-search-forward "^<<<<<<< " nil 'noerror)))
(vc-file-setprop buffer-file-name 'vc-state 'conflict)
(smerge-start-session)
(add-hook 'after-save-hook 'vc-git-resolve-when-done nil 'local)
(message "There are unresolved conflicts in this file")))
;;; HISTORY FUNCTIONS