[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#20292: 24.5; Saving Git-controlled file with merge conflicts after "
From: |
Dmitry Gutov |
Subject: |
bug#20292: 24.5; Saving Git-controlled file with merge conflicts after "stash pop" stages the file |
Date: |
Sat, 16 May 2015 02:50:57 +0300 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.0 |
On 05/14/2015 11:55 PM, Stefan Monnier wrote:
I think the only sane way to handle this is to always use "git add" and
to add a config var so users who don't like it can disable it.
If we're fine with a config var, we might as well try to support the
alternative behavior. This should do it:
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 20f2101..2fbb71b 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -130,6 +130,17 @@ If nil, use the value of `vc-annotate-switches'.
If t, use no switches."
:version "25.1"
:group 'vc-git)
+(defcustom vc-git-resolve-conflicts t
+ "When non-nil, mark conflicted file as resolved upon saving.
+That happens after all conflict markers in it have been removed.
+If the value is `unstage', then after the last conflict is
+resolved, the staging area is cleared if no merge is in progress."
+ :type '(choice (const :tag "Don't resolve" nil)
+ (const :tag "Resolve" t)
+ (const :tag "Unstage all after resolving" unstage))
+ :version "25.1"
+ :group 'vc-git)
+
(defcustom vc-git-program "git"
"Name of the Git executable (excluding any arguments)."
:version "24.1"
@@ -801,12 +812,16 @@ This prompts for a branch to merge from."
(save-excursion
(goto-char (point-min))
(unless (re-search-forward "^<<<<<<< " nil t)
- (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"))
+ (vc-git-command nil 0 buffer-file-name "add")
+ (when (and
+ (eq vc-git-resolve-conflicts 'unstage)
+ ;; Doing something other than a merge. Likely applying a
+ ;; stash (bug#20292).
+ (not
+ (file-exists-p (expand-file-name ".git/MERGE_HEAD"
+ (vc-git-root
buffer-file-name))))
+ (not (vc-git-conflicted-files (vc-git-root
buffer-file-name))))
+ (vc-git-command nil 0 nil "reset"))
;; Remove the hook so that it is not called multiple times.
(remove-hook 'after-save-hook 'vc-git-resolve-when-done t))))
@@ -823,7 +838,8 @@ This prompts for a branch to merge from."
(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)
+ (when vc-git-resolve-conflicts
+ (add-hook 'after-save-hook 'vc-git-resolve-when-done nil 'local))
(message "There are unresolved conflicts in this file")))
;;; HISTORY FUNCTIONS
- bug#20292: 24.5; Saving Git-controlled file with merge conflicts after "stash pop" stages the file, (continued)
- bug#20292: 24.5; Saving Git-controlled file with merge conflicts after "stash pop" stages the file, Dmitry Gutov, 2015/05/14
- bug#20292: 24.5; Saving Git-controlled file with merge conflicts after "stash pop" stages the file, Stefan Monnier, 2015/05/14
- bug#20292: 24.5; Saving Git-controlled file with merge conflicts after "stash pop" stages the file, Eli Zaretskii, 2015/05/15
- bug#20292: 24.5; Saving Git-controlled file with merge conflicts after "stash pop" stages the file, Stefan Monnier, 2015/05/15
- bug#20292: 24.5; Saving Git-controlled file with merge conflicts after "stash pop" stages the file, Eli Zaretskii, 2015/05/15
- bug#20292: 24.5; Saving Git-controlled file with merge conflicts after "stash pop" stages the file, Stefan Monnier, 2015/05/15
- bug#20292: 24.5; Saving Git-controlled file with merge conflicts after "stash pop" stages the file, Eli Zaretskii, 2015/05/15
- bug#20292: 24.5; Saving Git-controlled file with merge conflicts after "stash pop" stages the file, Stefan Monnier, 2015/05/15
- bug#20292: 24.5; Saving Git-controlled file with merge conflicts after "stash pop" stages the file, Dmitry Gutov, 2015/05/15
- bug#20292: 24.5; Saving Git-controlled file with merge conflicts after "stash pop" stages the file, Stefan Monnier, 2015/05/16
- bug#20292: 24.5; Saving Git-controlled file with merge conflicts after "stash pop" stages the file,
Dmitry Gutov <=
- bug#20292: 24.5; Saving Git-controlled file with merge conflicts after "stash pop" stages the file, Eli Zaretskii, 2015/05/16
- bug#20292: 24.5; Saving Git-controlled file with merge conflicts after "stash pop" stages the file, Dmitry Gutov, 2015/05/16
- bug#20292: 24.5; Saving Git-controlled file with merge conflicts after "stash pop" stages the file, Eli Zaretskii, 2015/05/16
- bug#20292: 24.5; Saving Git-controlled file with merge conflicts after "stash pop" stages the file, Dmitry Gutov, 2015/05/16
- bug#20292: 24.5; Saving Git-controlled file with merge conflicts after "stash pop" stages the file, Stefan Monnier, 2015/05/16
- bug#20292: 24.5; Saving Git-controlled file with merge conflicts after "stash pop" stages the file, Dmitry Gutov, 2015/05/16
- bug#20292: 24.5; Saving Git-controlled file with merge conflicts after "stash pop" stages the file, Eli Zaretskii, 2015/05/15
- bug#20292: 24.5; Saving Git-controlled file with merge conflicts after "stash pop" stages the file, Eli Zaretskii, 2015/05/15