aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Gutov2015-05-16 16:14:01 +0300
committerDmitry Gutov2015-05-16 16:14:01 +0300
commit45651154473c7d2f16230da765d034ecfde7968a (patch)
treead85b5d780fbb252a07bcfacf5be207aa929be97
parent0d3451c75dcdc52948caf5c464feada7280c64c1 (diff)
downloademacs-45651154473c7d2f16230da765d034ecfde7968a.tar.gz
emacs-45651154473c7d2f16230da765d034ecfde7968a.zip
Add new option vc-git-resolve-conflicts
* lisp/vc/vc-git.el (vc-git-resolve-conflicts): New variable. (vc-git-find-file-hook): Add to after-save-hook only when the above is non-nil. (vc-git-resolve-when-done): Update to honor the new variable. (Bug#20292)
-rw-r--r--lisp/vc/vc-git.el32
1 files changed, 25 insertions, 7 deletions
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 20f21011642..9dae1909595 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -130,6 +130,19 @@ If nil, use the value of `vc-annotate-switches'. If t, use no switches."
130 :version "25.1" 130 :version "25.1"
131 :group 'vc-git) 131 :group 'vc-git)
132 132
133(defcustom vc-git-resolve-conflicts t
134 "When non-nil, mark conflicted file as resolved upon saving.
135That is performed after all conflict markers in it have been
136removed. If the value is `unstage-maybe', and no merge is in
137progress, then after the last conflict is resolved, also clear
138the staging area."
139 :type '(choice (const :tag "Don't resolve" nil)
140 (const :tag "Resolve" t)
141 (const :tag "Resolve and maybe unstage all files"
142 unstage-maybe))
143 :version "25.1"
144 :group 'vc-git)
145
133(defcustom vc-git-program "git" 146(defcustom vc-git-program "git"
134 "Name of the Git executable (excluding any arguments)." 147 "Name of the Git executable (excluding any arguments)."
135 :version "24.1" 148 :version "24.1"
@@ -801,12 +814,16 @@ This prompts for a branch to merge from."
801 (save-excursion 814 (save-excursion
802 (goto-char (point-min)) 815 (goto-char (point-min))
803 (unless (re-search-forward "^<<<<<<< " nil t) 816 (unless (re-search-forward "^<<<<<<< " nil t)
804 (if (file-exists-p (expand-file-name ".git/MERGE_HEAD" 817 (vc-git-command nil 0 buffer-file-name "add")
805 (vc-git-root buffer-file-name))) 818 (when (and
806 ;; Doing a merge. 819 (eq vc-git-resolve-conflicts 'unstage-maybe)
807 (vc-git-command nil 0 buffer-file-name "add") 820 ;; Not doing a merge. Likely applying a stash
808 ;; Doing something else. Likely applying a stash (bug#20292). 821 ;; (bug#20292).
809 (vc-git-command nil 0 buffer-file-name "reset")) 822 (not
823 (file-exists-p (expand-file-name ".git/MERGE_HEAD"
824 (vc-git-root buffer-file-name))))
825 (not (vc-git-conflicted-files (vc-git-root buffer-file-name))))
826 (vc-git-command nil 0 nil "reset"))
810 ;; Remove the hook so that it is not called multiple times. 827 ;; Remove the hook so that it is not called multiple times.
811 (remove-hook 'after-save-hook 'vc-git-resolve-when-done t)))) 828 (remove-hook 'after-save-hook 'vc-git-resolve-when-done t))))
812 829
@@ -823,7 +840,8 @@ This prompts for a branch to merge from."
823 (re-search-forward "^<<<<<<< " nil 'noerror))) 840 (re-search-forward "^<<<<<<< " nil 'noerror)))
824 (vc-file-setprop buffer-file-name 'vc-state 'conflict) 841 (vc-file-setprop buffer-file-name 'vc-state 'conflict)
825 (smerge-start-session) 842 (smerge-start-session)
826 (add-hook 'after-save-hook 'vc-git-resolve-when-done nil 'local) 843 (when vc-git-resolve-conflicts
844 (add-hook 'after-save-hook 'vc-git-resolve-when-done nil 'local))
827 (message "There are unresolved conflicts in this file"))) 845 (message "There are unresolved conflicts in this file")))
828 846
829;;; HISTORY FUNCTIONS 847;;; HISTORY FUNCTIONS