Commit a2e1139c authored by Jonas Bernoulli's avatar Jonas Bernoulli

Fix remembering whether user confirmed editing published commits

We now use a variable to remember whether the user already confirmed
that s/he wants to edit published commits when initiating the rebase
so that s/he won't be asked again when there are staged changes when
continuing the rebase.  Previously we tried to use a file in the
control directory used by Git, but that directory does not exist at
the time we need to remember and if we create it ourselves, then Git
trips over it.

Fixes #3447.
parent abc305c9
......@@ -571,6 +571,7 @@ START has to be selected from a list of recent commits."
message)))
(defvar magit--rebase-published-symbol nil)
(defvar magit--rebase-public-edit-confirmed nil)
(defun magit-rebase-interactive-assert (since &optional delay-edit-confirm)
(let* ((commit (if (string-suffix-p "^" since)
......@@ -581,6 +582,8 @@ START has to be selected from a list of recent commits."
;; The "--root" argument is being used.
since))
(branches (magit-list-publishing-branches commit)))
(setq magit--rebase-public-edit-confirmed
(delete (magit-toplevel) magit--rebase-public-edit-confirmed))
(when (and branches
(or (not delay-edit-confirm)
;; The user might have stopped at a published commit
......@@ -592,9 +595,8 @@ START has to be selected from a list of recent commits."
(m2 ".\nDo you really want to modify them"))
(magit-confirm (or magit--rebase-published-symbol 'rebase-published)
(concat m1 "%s" m2)
(concat m1 "%i public branches" m2)
nil branches))
(magit--rebase-public-edit-confirmed 'set)))
(concat m1 "%i public branches" m2)))
(push (magit-toplevel) magit--rebase-public-edit-confirmed)))
(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)
......@@ -602,13 +604,6 @@ START has to be selected from a list of recent commits."
(?a "[a]bort" (user-error "Quit")))
since))
(defun magit--rebase-public-edit-confirmed (&optional set)
(let ((file (magit-git-dir (convert-standard-filename
"rebase-merge/magit-edit-confirmed"))))
(if set
(with-temp-file (write-file file) t)
(file-exists-p file))))
;;;###autoload
(defun magit-rebase-interactive (commit args)
"Start an interactive rebase sequence."
......@@ -666,7 +661,8 @@ edit. With a prefix argument the old message is reused as-is."
(user-error "Cannot continue rebase with unstaged changes")
(when (and (magit-anything-staged-p)
(file-exists-p (magit-git-dir "rebase-merge"))
(not (magit--rebase-public-edit-confirmed)))
(not (member (magit-toplevel)
magit--rebase-public-edit-confirmed)))
(magit-commit-amend-assert))
(if noedit
(let ((process-environment process-environment))
......
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