mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-06 23:51:24 -08:00
Add or reset based on the presence of MERGE_HEAD
* lisp/vc/vc-git.el (vc-git-find-file-hook): Add `vc-git-resolve-when-done' to `after-save-hook' in either case. (vc-git-conflicted-files): Add a TODO. (vc-git-resolve-when-done): Depending on the presence of MERGE_HEAD, either update the resolved file in the index, or remove it from there. (Bug#20292)
This commit is contained in:
parent
3f2c8b8264
commit
dbd65c779a
1 changed files with 22 additions and 21 deletions
|
|
@ -771,6 +771,9 @@ This prompts for a branch to merge from."
|
|||
(vc-git--run-command-string directory "status" "--porcelain" "--"))
|
||||
(lines (when status (split-string status "\n" 'omit-nulls)))
|
||||
files)
|
||||
;; TODO: Look into reimplementing `vc-git-state', as well as
|
||||
;; `vc-git-dir-status-files', based on this output, thus making the
|
||||
;; extra process call in `vc-git-find-file-hook' unnecessary.
|
||||
(dolist (line lines files)
|
||||
(when (string-match "\\([ MADRCU?!][ MADRCU?!]\\) \\(.+\\)\\(?: -> \\(.+\\)\\)?"
|
||||
line)
|
||||
|
|
@ -786,32 +789,30 @@ This prompts for a branch to merge from."
|
|||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(unless (re-search-forward "^<<<<<<< " nil t)
|
||||
(vc-git-command nil 0 buffer-file-name "add")
|
||||
(if (file-exists-p (expand-file-name ".git/MERGE_HEAD"
|
||||
(vc-git-root buffer-file-name)))
|
||||
;; Doing a merge.
|
||||
(vc-git-command nil 0 buffer-file-name "add")
|
||||
;; Doing something else. Likely applying a stash (bug#20292).
|
||||
(vc-git-command nil 0 buffer-file-name "reset"))
|
||||
;; 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."
|
||||
(let (stashed)
|
||||
(when (and buffer-file-name
|
||||
;; FIXME
|
||||
;; 1) the net result is to call git twice per file.
|
||||
;; 2) v-g-c-f is documented to take a directory.
|
||||
;; http://lists.gnu.org/archive/html/emacs-devel/2014-01/msg01126.html
|
||||
;; XXX: Should we first look for the markers, and only
|
||||
;; call this function when see some?
|
||||
(vc-git-conflicted-files buffer-file-name)
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(when (re-search-forward "^>>>>>>> " nil 'noerror)
|
||||
(setq stashed (looking-at "Stashed changes"))
|
||||
t)))
|
||||
(vc-file-setprop buffer-file-name 'vc-state 'conflict)
|
||||
(smerge-start-session)
|
||||
(unless stashed
|
||||
;; Stashes are tricky (bug#20292).
|
||||
(add-hook 'after-save-hook 'vc-git-resolve-when-done nil 'local))
|
||||
(message "There are unresolved conflicts in this file"))))
|
||||
(when (and buffer-file-name
|
||||
;; FIXME
|
||||
;; 1) the net result is to call git twice per file.
|
||||
;; 2) v-g-c-f is documented to take a directory.
|
||||
;; http://lists.gnu.org/archive/html/emacs-devel/2014-01/msg01126.html
|
||||
(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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue