diff options
| -rw-r--r-- | lisp/ChangeLog | 11 | ||||
| -rw-r--r-- | lisp/vc/vc-git.el | 22 |
2 files changed, 29 insertions, 4 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 764d6d12c8a..39ab7caf874 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,8 +1,13 @@ | |||
| 1 | 2014-08-13 Eric S. Raymond <esr@thyrsus.com> | 1 | 2014-08-13 Eric S. Raymond <esr@thyrsus.com> |
| 2 | 2 | ||
| 3 | * vc/vc-git.el (vc-git-conflicted-files): Integrate Rüdiger | 3 | * vc/vc.git.el: (vc-git-find-file-hook): New function. Adds |
| 4 | Sonderfeld's code for detecting conflicted files using a status | 4 | support for calling smerge on a conflicted file, and calling git |
| 5 | listing. Useful in itself and a step towards better smerge | 5 | add when there are no longer conflict markers in a saved file. |
| 6 | This is a completed version of Rüdiger Sonderfeld's proposal. | ||
| 7 | |||
| 8 | * vc/vc-git.el (vc-git-conflicted-files): New function. Integrate | ||
| 9 | Rüdiger Sonderfeld's code for detecting conflicted files using a | ||
| 10 | status listing. Useful in itself and a step towards better smerge | ||
| 6 | support. | 11 | support. |
| 7 | 12 | ||
| 8 | 2014-08-12 Stefan Monnier <monnier@iro.umontreal.ca> | 13 | 2014-08-12 Stefan Monnier <monnier@iro.umontreal.ca> |
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 3e9228601d8..27a2f8b3d4d 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el | |||
| @@ -101,7 +101,7 @@ | |||
| 101 | ;; - clear-headers () NOT NEEDED | 101 | ;; - clear-headers () NOT NEEDED |
| 102 | ;; - delete-file (file) OK | 102 | ;; - delete-file (file) OK |
| 103 | ;; - rename-file (old new) OK | 103 | ;; - rename-file (old new) OK |
| 104 | ;; - find-file-hook () NOT NEEDED | 104 | ;; - find-file-hook () OK |
| 105 | ;; - conflicted-files OK | 105 | ;; - conflicted-files OK |
| 106 | 106 | ||
| 107 | ;;; Code: | 107 | ;;; Code: |
| @@ -786,6 +786,26 @@ This prompts for a branch to merge from." | |||
| 786 | "DU" "AA" "UU")) | 786 | "DU" "AA" "UU")) |
| 787 | (push file files))))))) | 787 | (push file files))))))) |
| 788 | 788 | ||
| 789 | (defun vc-git-resolve-when-done () | ||
| 790 | "Call \"git add\" if the conflict markers have been removed." | ||
| 791 | (save-excursion | ||
| 792 | (goto-char (point-min)) | ||
| 793 | (unless (re-search-forward "^<<<<<<< " nil t) | ||
| 794 | (vc-git-command nil 0 buffer-file-name "add") | ||
| 795 | ;; Remove the hook so that it is not called multiple times. | ||
| 796 | (remove-hook 'after-save-hook 'vc-git-resolve-when-done t)))) | ||
| 797 | |||
| 798 | (defun vc-git-find-file-hook () | ||
| 799 | "Activate `smerge-mode' if there is a conflict." | ||
| 800 | (when (and buffer-file-name | ||
| 801 | (vc-git-conflicted-files buffer-file-name) | ||
| 802 | (save-excursion | ||
| 803 | (goto-char (point-min)) | ||
| 804 | (re-search-forward "^<<<<<<< " nil 'noerror))) | ||
| 805 | (vc-file-setprop buffer-file-name 'vc-state 'conflict) | ||
| 806 | (smerge-start-session) | ||
| 807 | (add-hook 'after-save-hook 'vc-git-resolve-when-done nil 'local) | ||
| 808 | (message "There are unresolved conflicts in this file"))) | ||
| 789 | 809 | ||
| 790 | ;;; HISTORY FUNCTIONS | 810 | ;;; HISTORY FUNCTIONS |
| 791 | 811 | ||