[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master dbd65c7: Add or reset based on the presence of MERG
From: |
Dmitry Gutov |
Subject: |
[Emacs-diffs] master dbd65c7: Add or reset based on the presence of MERGE_HEAD |
Date: |
Wed, 22 Apr 2015 02:00:03 +0000 |
branch: master
commit dbd65c779aa648bcc5c6fdc31f0be44cce4ea8ce
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>
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)
---
lisp/vc/vc-git.el | 43 ++++++++++++++++++++++---------------------
1 files changed, 22 insertions(+), 21 deletions(-)
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index bec36fd..c8b696a 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master dbd65c7: Add or reset based on the presence of MERGE_HEAD,
Dmitry Gutov <=