Commit 1bb73057 authored by Jonas Bernoulli's avatar Jonas Bernoulli

Warn earlier about merges when creating fixup commits

Give the user the opportunity to abort or select another
commit before the fixup commit has already been created.

Closes #3176.
parent 44ca1dff
......@@ -42,3 +42,6 @@ Fixes since v2.11.0
* `git-rebase-mode-show-keybindings' failed to process non-English
usage instructions in interactive rebase buffers. #3175
* Fixup commands did not warn about merges in the rebase range until
after creating the fixup commit. #3176
......@@ -260,6 +260,8 @@ depending on the value of option `magit-commit-squash-confirm'."
(defun magit-commit-squash-internal
(option commit &optional args rebase edit confirmed)
(-when-let (args (magit-commit-assert args t))
(when commit
(setq commit (magit-rebase-interactive-assert commit)))
(if (and commit
(or confirmed
(not (or rebase
......@@ -276,7 +278,8 @@ depending on the value of option `magit-commit-squash-confirm'."
(-remove-first
(apply-partially #'string-match-p "\\`--gpg-sign=")
args)))
(magit-run-git-with-editor "commit" args)))
(magit-run-git-with-editor "commit" args))
t) ; The commit was created; used by below lambda.
(magit-log-select
(lambda (commit)
(when (and (magit-commit-squash-internal option commit args
......@@ -284,7 +287,7 @@ depending on the value of option `magit-commit-squash-confirm'."
rebase)
(magit-rebase-interactive-1 commit
(list "--autosquash" "--autostash")
"" "true")))
"" "true" t)))
(format "Type %%p on a commit to %s into it,"
(substring option 2))
nil nil (list "--graph"))
......
......@@ -382,7 +382,7 @@ START has to be selected from a list of recent commits."
(concat "Type %p on a commit to rebase it "
"and commits above it onto " newbase ","))))
(defun magit-rebase-interactive-1 (commit args message &optional editor)
(defun magit-rebase-interactive-1 (commit args message &optional editor noassert)
(declare (indent 2))
(when commit
(if (eq commit :merge-base)
......@@ -394,12 +394,8 @@ START has to be selected from a list of recent commits."
(if (magit-commit-parents commit)
(setq commit (concat commit "^"))
(setq args (cons "--root" args)))))
(when (and commit
(magit-git-lines "rev-list" "--merges" (concat commit "..HEAD")))
(magit-read-char-case "Proceed despite merge in rebase range? " nil
(?c "[c]ontinue")
(?s "[s]elect other" (setq commit nil))
(?a "[a]bort" (user-error "Quit"))))
(when (and commit (not noassert))
(setq commit (magit-rebase-interactive-assert commit)))
(if commit
(let ((process-environment process-environment))
(when editor
......@@ -408,9 +404,18 @@ START has to be selected from a list of recent commits."
(unless (member "--root" args) commit)))
(magit-log-select
`(lambda (commit)
(magit-rebase-interactive-1 commit (list ,@args) ,message ,editor))
(magit-rebase-interactive-1 commit (list ,@args)
,message ,editor ,noassert))
message)))
(defun magit-rebase-interactive-assert (since)
(if (magit-git-lines "rev-list" "--merges" (concat since "..HEAD"))
(magit-read-char-case "Proceed despite merge in rebase range? " nil
(?c "[c]ontinue" since)
(?s "[s]elect other" nil)
(?a "[a]bort" (user-error "Quit")))
since))
;;;###autoload
(defun magit-rebase-interactive (commit args)
"Start an interactive rebase sequence."
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment