1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-10 00:00:39 -08:00

vc-git-resolve-conflicts: Extend unstage-maybe to similar operations

* lisp/vc/vc-git.el (vc-git-resolve-when-done): When
vc-git-resolve-conflicts is unstage-maybe, don't clear the
staging area during a rebase, am, revert or cherry-pick.
(vc-git-resolve-conflicts): Update docstring in light of changes
to vc-git-resolve-when-done.
(vc-git--cmds-in-progress): Detect reverts and cherry-pick
operations in progress.
This commit is contained in:
Sean Whitton 2024-10-27 14:11:50 +08:00
parent d354300993
commit d7d5b2ec9a

View file

@ -168,10 +168,10 @@ uses a full scan)."
(defcustom vc-git-resolve-conflicts t (defcustom vc-git-resolve-conflicts t
"When non-nil, mark conflicted file as resolved upon saving. "When non-nil, mark conflicted file as resolved upon saving.
That is performed after all conflict markers in it have been That is performed after all conflict markers in it have been removed.
removed. If the value is `unstage-maybe', and no merge is in If the value is `unstage-maybe', and no merge, rebase or similar
progress, then after the last conflict is resolved, also clear operation is in progress, then after the last conflict is resolved, also
the staging area." clear the staging area."
:type '(choice (const :tag "Don't resolve" nil) :type '(choice (const :tag "Don't resolve" nil)
(const :tag "Resolve" t) (const :tag "Resolve" t)
(const :tag "Resolve and maybe unstage all files" (const :tag "Resolve and maybe unstage all files"
@ -766,6 +766,10 @@ or an empty string if none."
(let ((gitdir (vc-git--git-path)) (let ((gitdir (vc-git--git-path))
cmds) cmds)
;; See contrib/completion/git-prompt.sh in git.git. ;; See contrib/completion/git-prompt.sh in git.git.
(when (file-exists-p (expand-file-name "REVERT_HEAD" gitdir))
(push 'revert cmds))
(when (file-exists-p (expand-file-name "CHERRY_PICK_HEAD" gitdir))
(push 'cherry-pick cmds))
(when (or (file-directory-p (when (or (file-directory-p
(expand-file-name "rebase-merge" gitdir)) (expand-file-name "rebase-merge" gitdir))
(file-exists-p (file-exists-p
@ -1419,8 +1423,14 @@ This prompts for a branch to merge from."
(vc-git-command nil 0 buffer-file-name "add") (vc-git-command nil 0 buffer-file-name "add")
(unless (or (unless (or
(not (eq vc-git-resolve-conflicts 'unstage-maybe)) (not (eq vc-git-resolve-conflicts 'unstage-maybe))
;; Doing a merge, so bug#20292 doesn't apply. ;; Doing a merge or rebase-like operation, so bug#20292
(file-exists-p (vc-git--git-path "MERGE_HEAD")) ;; doesn't apply.
;;
;; If we were to 'git reset' in the middle of a
;; cherry-pick, for example, it would effectively abort
;; the cherry-pick, losing the user's progress.
(cl-intersection '(merge rebase am revert cherry-pick)
(vc-git--cmds-in-progress))
(vc-git-conflicted-files (vc-git-root buffer-file-name))) (vc-git-conflicted-files (vc-git-root buffer-file-name)))
(vc-git-command nil 0 nil "reset")) (vc-git-command nil 0 nil "reset"))
(vc-resynch-buffer buffer-file-name t t) (vc-resynch-buffer buffer-file-name t t)