Commit 570f58b1 authored by Jonas Bernoulli's avatar Jonas Bernoulli

Refuse to create instant fixup commit for an unreachable commit

When performing an instant fixup it is clearly a mistake to select an
unreachable commit.  The second step, the rebase, would always fail.

However creating a fixup commit for an unreachable commit without
trying to instantly rebase is a valid use-case, it allows "labeling"
the fixup as belonging to some commit.  Just doing a rebase would not
be enough to get the fixup to the right place, but we cannot know
whether the user is aware of that - so continue to allow the creation
of such fixup commits.
parent 1bb73057
......@@ -45,3 +45,7 @@ Fixes since v2.11.0
* Fixup commands did not warn about merges in the rebase range until
after creating the fixup commit. #3176
* Instant fixup allowed selecting a commit that is not reachable from
HEAD, which, for the instant variants (but only those), clearly is
a user mistake that should be caught immediately. #3176
......@@ -260,6 +260,13 @@ 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
(when (and rebase (not (magit-rev-ancestor-p commit "HEAD")))
(magit-read-char-case
(format "%s isn't an ancestor of HEAD. " commit) nil
(?c "[c]reate without rebasing" (setq rebase nil))
(?s "[s]elect other" (setq commit nil))
(?a "[a]bort" (user-error "Quit")))))
(when commit
(setq commit (magit-rebase-interactive-assert commit)))
(if (and commit
......
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