Commit 42c22614 authored by Jonas Bernoulli's avatar Jonas Bernoulli

magit-confirm: Fix regression

Unfortunately doing so means changing the function signature in a way
that is not backward compatible.

This function relies on being able to tell whether ITEMS is nil
because that argument was not provided or because an empty list was
provided as its value.  In the former case the action still has to be
confirmed in the latter case it does not because there is nothing to
act on.

So the `(items nil sitems)' argument has to be last but in d6420549
I added a new argument NOCONFIRM after it.

Fixes #3341.
parent 91b4af27
......@@ -494,7 +494,7 @@ running 'man git-rebase' at the command line) for details."
(defun git-rebase-cancel-confirm (force)
(or (not (buffer-modified-p))
(magit-confirm 'abort-rebase "Abort this rebase" nil nil 'noabort)))
(magit-confirm 'abort-rebase "Abort this rebase" nil 'noabort)))
(defun git-rebase-autostash-save ()
(--when-let (magit-file-line (magit-git-dir "rebase-merge/autostash"))
......@@ -520,7 +520,7 @@ without requiring confirmation."
(magit-call-git "rm" "--cached" "--force" "--" file)))))))
(defun magit-discard-files--rename (files status)
(magit-confirm 'rename "Undo rename %s" "Undo %i renames"
(magit-confirm 'rename "Undo rename %s" "Undo %i renames" nil
(mapcar (lambda (file)
(setq file (assoc file status))
(format "%s -> %s" (cadr file) (car file)))
......@@ -568,7 +568,7 @@ defaulting to the branch at point."
(let ((branches (magit-region-values 'branch t))
(force current-prefix-arg))
(if (> (length branches) 1)
(magit-confirm t nil "Delete %i branches" branches)
(magit-confirm t nil "Delete %i branches" nil branches)
(setq branches
(list (magit-read-branch-prefer-other
(if force "Force delete branch" "Delete branch")))))
......@@ -577,7 +577,7 @@ defaulting to the branch at point."
(if (magit-confirm 'delete-unmerged-branch
"Delete unmerged branch %s"
"Delete %i unmerged branches"
unmerged 'noabort)
'noabort unmerged)
(setq force branches)
(or (setq branches (-difference branches unmerged))
(user-error "Abort")))))
......@@ -629,14 +629,14 @@ defaulting to the branch at point."
(magit-branch-merged-p branch t))
(magit-confirm 'delete-unmerged-branch
"Delete unmerged branch %s" ""
(list branch)))
nil (list branch)))
(magit-call-git "checkout" "--detach"))
(`master (unless (or (equal force '(4))
(member branch force)
(magit-branch-merged-p branch "master"))
(magit-confirm 'delete-unmerged-branch
"Delete unmerged branch %s" ""
(list branch)))
nil (list branch)))
(magit-call-git "checkout" "master"))
(`abort (user-error "Abort")))
(setq force t))
......@@ -238,11 +238,12 @@ remote or replace the refspecs with the default refspec instead."
(magit-confirm 'prune-stale-refspecs
(format "Prune stale refspec %s and branch %%s" refspec)
(format "Prune stale refspec %s and %%i branches" refspec)
nil refs))
(magit-confirm 'prune-stale-refspecs nil
(format "Prune %%i stale refspecs and %i branches"
(length (cl-mapcan (lambda (s) (copy-sequence (cdr s)))
(--map (pcase-let ((`(,refspec . ,refs) it))
(concat refspec "\n"
(mapconcat (lambda (b) (concat " " b))
......@@ -218,7 +218,7 @@ and forgo removing the stash."
"Remove a stash from the stash list.
When the region is active offer to drop all contained stashes."
(interactive (list (--if-let (magit-region-values 'stash)
(magit-confirm t nil "Drop %i stashes" it)
(magit-confirm t nil "Drop %i stashes" nil it)
(magit-read-stash "Drop stash"))))
(dolist (stash (if (listp stash)
(nreverse (prog1 stash (setq stash (car stash))))
......@@ -572,8 +572,8 @@ ACTION is a member of option `magit-slow-confirm'."
(yes-or-no-p prompt)
(y-or-n-p prompt)))
(cl-defun magit-confirm (action &optional prompt prompt-n
(items nil sitems) noabort)
(cl-defun magit-confirm (action &optional prompt prompt-n noabort
(items nil sitems))
(declare (indent defun))
(setq prompt-n (format (concat (or prompt-n prompt) "? ") (length items)))
(setq prompt (format (concat (or prompt (magit-confirm-make-prompt action))
......@@ -616,7 +616,7 @@ ACTION is a member of option `magit-slow-confirm'."
(magit-confirm action
(concat prompt " %s")
(concat prompt " %i files")
nil files)))
(defun magit-confirm-make-prompt (action)
(let ((prompt (symbol-name action)))
......@@ -460,7 +460,7 @@ to delete those, otherwise prompt for a single tag to be deleted,
defaulting to the tag at point.
\n(git tag -d TAGS)"
(interactive (list (--if-let (magit-region-values 'tag)
(magit-confirm t nil "Delete %i tags" it)
(magit-confirm t nil "Delete %i tags" nil it)
(magit-read-tag "Delete tag" t))))
(magit-run-git "tag" "-d" tags))
......@@ -479,12 +479,12 @@ defaulting to the tag at point.
(unless (magit-confirm t
"Delete %s locally"
"Delete %i tags locally"
ltags 'noabort)
'noabort ltags)
(setq ltags nil))
(unless (magit-confirm t
"Delete %s from remote"
"Delete %i tags from remote"
rtags 'noabort)
'noabort rtags)
(setq rtags nil))
(list ltags rtags remote)))
(when tags
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