vc-allow-rewriting-published-history: Use nil->ask->t

* lisp/vc/vc.el (vc-allow-rewriting-published-history): Use
increasingly permissive values nil->ask->t rather than
nil->t->no-ask.  Recommend `ask' or nil.
* lisp/vc/vc-git.el (vc-git--assert-allowed-rewrite): Update
accordingly.
This commit is contained in:
Sean Whitton 2024-10-24 11:26:27 +08:00
parent bc8f416ee9
commit 3bb1b85b78
2 changed files with 13 additions and 7 deletions

View file

@ -1966,7 +1966,8 @@ This requires git 1.8.4 or later, for the \"-L\" option of \"git log\"."
"log" "--max-count=1" "--pretty=format:%B" rev)))
(defun vc-git--assert-allowed-rewrite (rev)
(when (and (not (eq vc-allow-rewriting-published-history 'no-ask))
(when (and (not (and vc-allow-rewriting-published-history
(not (eq vc-allow-rewriting-published-history 'ask))))
;; Check there is an upstream.
(with-temp-buffer
(vc-git--out-ok "config" "--get"
@ -1978,7 +1979,7 @@ This requires git 1.8.4 or later, for the \"-L\" option of \"git log\"."
"--pretty=format:%H"
"@{upstream}..HEAD")))))
(unless (or (cl-member rev outgoing :test #'string-prefix-p)
(and vc-allow-rewriting-published-history
(and (eq vc-allow-rewriting-published-history 'ask)
(yes-or-no-p
(format "Commit %s appears published; allow rewriting history?"
rev))))

View file

@ -931,12 +931,17 @@ the ordinary way until you take special action. For example, for Git,
see \"Recovering from Upstream Rebase\" in the Man page git-rebase(1).
Normally, Emacs refuses to run VCS commands that it thinks will rewrite
published history. If you customize this variable to a non-nil value,
Emacs will instead prompt you to confirm that you really want to perform
the rewrite. A value of `no-ask' means to proceed with no prompting."
published history. If you customize this variable to `ask', Emacs will
instead prompt you to confirm that you really want to perform the
rewrite. Any other non-nil value means to proceed with no prompting.
We recommend customizing this variable to `ask' or leaving it nil,
because if published history is rewritten unexpectedly it can be fairly
time-consuming to recover. Only customize this variable to a non-nil
value other than `ask' if you have a strong grasp of the VCS in use."
:type '(choice (const :tag "Don't allow" nil)
(const :tag "Prompt to allow" t)
(const :tag "Allow without prompting" no-ask))
(const :tag "Prompt to allow" ask)
(const :tag "Allow without prompting" t))
:version "31.1")