aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/magit.org6
-rw-r--r--docs/magit.texi7
-rw-r--r--lisp/git-commit.el2
-rw-r--r--lisp/magit-base.el7
-rw-r--r--lisp/magit-files.el20
-rw-r--r--lisp/magit-git.el31
-rw-r--r--lisp/magit-gitignore.el2
-rw-r--r--lisp/magit-log.el17
-rw-r--r--lisp/magit-merge.el2
-rw-r--r--lisp/magit-patch.el5
-rw-r--r--lisp/magit-push.el4
-rw-r--r--lisp/magit-repos.el2
-rw-r--r--lisp/magit-transient.el9
13 files changed, 61 insertions, 53 deletions
diff --git a/docs/magit.org b/docs/magit.org
index cdc364c..4c1089c 100644
--- a/docs/magit.org
+++ b/docs/magit.org
@@ -1794,7 +1794,11 @@ will also have to install the ~ido-completing-read+~ package and use
- If REQUIRE-MATCH is ~nil~ and the user exits without a choice, then
~nil~ is returned instead of an empty string.
- - If REQUIRE-MATCH is non-nil and the users exits without a choice,
+ - If REQUIRE-MATCH is ~any~, then do not require a match but
+ do require non-empty input (or non-nil DEFAULT, since that
+ is substituted for empty input).
+
+ - If REQUIRE-MATCH is non-~nil~ and the users exits without a choice,
an user-error is raised.
- FALLBACK specifies a secondary default that is only used if the
diff --git a/docs/magit.texi b/docs/magit.texi
index f8fdb85..4e96c3a 100644
--- a/docs/magit.texi
+++ b/docs/magit.texi
@@ -2102,7 +2102,12 @@ If REQUIRE-MATCH is @code{nil} and the user exits without a choice, then
@code{nil} is returned instead of an empty string.
@item
-If REQUIRE-MATCH is non-nil and the users exits without a choice,
+If REQUIRE-MATCH is @code{any}, then do not require a match but
+do require non-empty input (or non-nil DEFAULT, since that
+is substituted for empty input).
+
+@item
+If REQUIRE-MATCH is non-@code{nil} and the users exits without a choice,
an user-error is raised.
@item
diff --git a/lisp/git-commit.el b/lisp/git-commit.el
index 6c5975f..140e058 100644
--- a/lisp/git-commit.el
+++ b/lisp/git-commit.el
@@ -947,7 +947,7 @@ completion candidates. The input must have the form \"NAME <EMAIL>\"."
(sort (delete-dups
(magit-git-lines "log" "-n9999" "--format=%aN <%ae>"))
#'string<)
- nil nil nil 'git-commit-read-ident-history)))
+ nil 'any nil 'git-commit-read-ident-history)))
(save-match-data
(if (string-match "\\`\\([^<]+\\) *<\\([^>]+\\)>\\'" str)
(list (save-match-data (string-trim (match-str 1 str)))
diff --git a/lisp/magit-base.el b/lisp/magit-base.el
index b49f2a7..b8d50a9 100644
--- a/lisp/magit-base.el
+++ b/lisp/magit-base.el
@@ -576,6 +576,10 @@ acts similarly to `completing-read', except for the following:
- If REQUIRE-MATCH is nil and the user exits without a choice,
then nil is returned instead of an empty string.
+- If REQUIRE-MATCH is `any', then do not require a match but
+ do require non-empty input (or non-nil DEFAULT, since that
+ is substituted for empty input).
+
- If REQUIRE-MATCH is non-nil and the user exits without a
choice, `user-error' is raised.
@@ -614,7 +618,8 @@ acts similarly to `completing-read', except for the following:
(reply (funcall magit-completing-read-function
(magit--format-prompt prompt def)
collection predicate
- require-match initial-input hist def)))
+ (if (eq require-match 'any) nil require-match)
+ initial-input hist def)))
(setq this-command command)
;; Note: Avoid `string=' to support `helm-comp-read-use-marked'.
(if (equal reply "")
diff --git a/lisp/magit-files.el b/lisp/magit-files.el
index a7abb08..b1836dc 100644
--- a/lisp/magit-files.el
+++ b/lisp/magit-files.el
@@ -68,17 +68,15 @@ the line and column corresponding to that location."
(defun magit-find-file-read-args (prompt)
(let ((pseudo-revs '("{worktree}" "{index}")))
- (if-let ((rev (magit-completing-read "Find file from revision"
- (append pseudo-revs
- (magit-list-refnames nil t))
- nil nil nil 'magit-revision-history
- (or (magit-branch-or-commit-at-point)
- (magit-get-current-branch)))))
- (list rev (magit-read-file-from-rev (if (member rev pseudo-revs)
- "HEAD"
- rev)
- prompt))
- (user-error "Nothing selected"))))
+ (let ((rev (magit-completing-read "Find file from revision"
+ (append pseudo-revs
+ (magit-list-refnames nil t))
+ nil 'any nil 'magit-revision-history
+ (or (magit-branch-or-commit-at-point)
+ (magit-get-current-branch)))))
+ (list rev
+ (magit-read-file-from-rev (if (member rev pseudo-revs) "HEAD" rev)
+ prompt)))))
(defun magit-find-file--internal (rev file fn)
(let ((buf (magit-find-file-noselect rev file))
diff --git a/lisp/magit-git.el b/lisp/magit-git.el
index 22a31db..44b135b 100644
--- a/lisp/magit-git.el
+++ b/lisp/magit-git.el
@@ -2662,10 +2662,9 @@ and this option only controls what face is used.")
(when (and commit-at-point (not branch-at-point))
(setq choices (cons commit-at-point choices)))
(minibuffer-with-setup-hook #'magit--minibuf-default-add-commit
- (or (magit-completing-read
- prompt choices nil nil nil 'magit-revision-history
- (or branch-at-point commit-at-point secondary-default current))
- (user-error "Nothing selected")))))
+ (magit-completing-read
+ prompt choices nil 'any nil 'magit-revision-history
+ (or branch-at-point commit-at-point secondary-default current)))))
(defun magit-read-range-or-commit (prompt &optional secondary-default)
(magit-read-range
@@ -2686,7 +2685,7 @@ and this option only controls what face is used.")
(magit-completing-read-multiple
(concat prompt ": ")
(magit-list-refnames)
- nil nil nil 'magit-revision-history default nil t)))
+ nil 'any nil 'magit-revision-history default nil t)))
(defun magit-read-remote-branch
(prompt &optional remote default local-branch require-match)
@@ -2699,7 +2698,8 @@ and this option only controls what face is used.")
(magit-list-remotes))))
(magit-list-remote-branch-names remote t)
:test #'equal)
- nil require-match nil 'magit-revision-history default)))
+ nil (or require-match 'any)
+ nil 'magit-revision-history default)))
(if (or remote (string-match "\\`\\([^/]+\\)/\\(.+\\)" choice))
choice
(user-error "`%s' doesn't have the form REMOTE/BRANCH" choice))))
@@ -2708,7 +2708,8 @@ and this option only controls what face is used.")
(magit-completing-read prompt
(prog2 (message "Determining available refs...")
(magit-remote-list-refs remote)
- (message "Determining available refs...done"))))
+ (message "Determining available refs...done"))
+ nil 'any))
(defun magit-read-local-branch (prompt &optional secondary-default)
(magit-completing-read prompt (magit-list-local-branch-names)
@@ -2724,10 +2725,9 @@ and this option only controls what face is used.")
(when commit
(push commit choices))
(minibuffer-with-setup-hook #'magit--minibuf-default-add-commit
- (or (magit-completing-read prompt choices
- nil nil nil 'magit-revision-history
- (or (magit-local-branch-at-point) commit))
- (user-error "Nothing selected")))))
+ (magit-completing-read prompt choices
+ nil 'any nil 'magit-revision-history
+ (or (magit-local-branch-at-point) commit)))))
(defun magit-read-local-branch-or-ref (prompt &optional secondary-default)
(magit-completing-read prompt (nconc (magit-list-local-branch-names)
@@ -2762,9 +2762,8 @@ and this option only controls what face is used.")
secondary-default
(magit-get-previous-branch))))
(minibuffer-with-setup-hook #'magit--minibuf-default-add-commit
- (or (magit-completing-read prompt (delete exclude (magit-list-refnames))
- nil nil nil 'magit-revision-history default)
- (user-error "Nothing selected")))))
+ (magit-completing-read prompt (delete exclude (magit-list-refnames))
+ nil 'any nil 'magit-revision-history default))))
(defun magit-read-other-local-branch
(prompt &optional exclude secondary-default)
@@ -2827,7 +2826,7 @@ out. Only existing branches can be selected."
(nconc (list "HEAD")
(magit-list-refnames)
(directory-files (magit-gitdir) nil "_HEAD\\'"))
- nil nil nil 'magit-revision-history
+ nil 'any nil 'magit-revision-history
(or default (magit--default-starting-point)))
(user-error "Nothing selected")))
@@ -2875,7 +2874,7 @@ out. Only existing branches can be selected."
(magit-completing-read prompt
(nconc (magit-list-remotes)
(list "https://" "git://" "git@"))
- nil nil nil nil
+ nil 'any nil nil
(or default
(magit-remote-at-point)
(magit-get-remote))))
diff --git a/lisp/magit-gitignore.el b/lisp/magit-gitignore.el
index 4f8baf9..62b0ef5 100644
--- a/lisp/magit-gitignore.el
+++ b/lisp/magit-gitignore.el
@@ -138,7 +138,7 @@ Rules that are defined in that file affect all local repositories."
(unless (member default choices)
(setq default nil))))
(magit-completing-read "File or pattern to ignore"
- choices nil nil nil nil default)))
+ choices nil 'any nil nil default)))
;;; Skip Worktree Commands
diff --git a/lisp/magit-log.el b/lisp/magit-log.el
index 66b30a3..c82cc95 100644
--- a/lisp/magit-log.el
+++ b/lisp/magit-log.el
@@ -651,7 +651,7 @@ commits before and half after."
(split-string (magit-completing-read-multiple
"Log rev,s: "
(magit-list-refnames nil t)
- nil nil nil 'magit-revision-history
+ nil 'any nil 'magit-revision-history
(or (magit-branch-or-commit-at-point)
(and (not use-current)
(magit-get-previous-branch)))
@@ -953,14 +953,13 @@ nothing else.
If invoked outside any log buffer, then display the log buffer
of the current repository first; creating it if necessary."
(interactive
- (list (or (magit-completing-read
- "In log, jump to"
- (magit-list-refnames nil t)
- nil nil nil 'magit-revision-history
- (or (and-let* ((rev (magit-commit-at-point)))
- (magit-rev-fixup-target rev))
- (magit-get-current-branch)))
- (user-error "Nothing selected"))))
+ (list (magit-completing-read
+ "In log, jump to"
+ (magit-list-refnames nil t)
+ nil 'any nil 'magit-revision-history
+ (or (and-let* ((rev (magit-commit-at-point)))
+ (magit-rev-fixup-target rev))
+ (magit-get-current-branch)))))
(with-current-buffer
(cond ((derived-mode-p 'magit-log-mode)
(current-buffer))
diff --git a/lisp/magit-merge.el b/lisp/magit-merge.el
index 28a702c..47865af 100644
--- a/lisp/magit-merge.el
+++ b/lisp/magit-merge.el
@@ -241,7 +241,7 @@ then also remove the respective remote branch."
"During a conflict checkout and stage side, or restore conflict."
(interactive
(let ((file (magit-completing-read "Checkout file"
- (magit-tracked-files) nil nil nil
+ (magit-tracked-files) nil 'any nil
'magit-read-file-hist
(magit-current-file))))
(cond ((member file (magit-unmerged-files))
diff --git a/lisp/magit-patch.el b/lisp/magit-patch.el
index 8b55299..4c1b44f 100644
--- a/lisp/magit-patch.el
+++ b/lisp/magit-patch.el
@@ -150,9 +150,8 @@ which creates patches for all commits that are reachable from
:reader #'magit-format-patch-select-base)
(defun magit-format-patch-select-base (prompt initial-input history)
- (or (magit-completing-read prompt (cons "auto" (magit-list-refnames))
- nil nil initial-input history "auto")
- (user-error "Nothing selected")))
+ (magit-completing-read prompt (cons "auto" (magit-list-refnames))
+ nil 'any initial-input history "auto"))
(transient-define-argument magit-format-patch:--reroll-count ()
:description "Reroll count"
diff --git a/lisp/magit-push.el b/lisp/magit-push.el
index 9fc944e..4b8f221 100644
--- a/lisp/magit-push.el
+++ b/lisp/magit-push.el
@@ -134,7 +134,7 @@ the upstream."
:test #'equal))
(upstream (magit-completing-read
(format "Set upstream of %s and push there" branch)
- branches nil nil nil 'magit-revision-history
+ branches nil 'any nil 'magit-revision-history
(or (car (member (magit-remote-branch-at-point) branches))
(car (member "origin/master" branches)))))
(upstream* (or (magit-get-tracked upstream)
@@ -218,7 +218,7 @@ is used."
(magit-completing-read-multiple
"Push refspec,s: "
(cons "HEAD" (magit-list-local-branch-names))
- nil nil nil 'magit-push-refspecs-history)
+ nil 'any nil 'magit-push-refspecs-history)
(magit-push-arguments)))
(run-hooks 'magit-credential-hook)
(magit-run-git-async "push" "-v" args remote refspecs))
diff --git a/lisp/magit-repos.el b/lisp/magit-repos.el
index dcf6808..497df49 100644
--- a/lisp/magit-repos.el
+++ b/lisp/magit-repos.el
@@ -492,7 +492,7 @@ instead."
(if-let ((repos (and (not read-directory-name)
magit-repository-directories
(magit-repos-alist))))
- (let ((reply (magit-completing-read "Git repository" repos)))
+ (let ((reply (magit-completing-read "Git repository" repos nil 'any)))
(file-name-as-directory
(or (cdr (assoc reply repos))
(if (file-directory-p reply)
diff --git a/lisp/magit-transient.el b/lisp/magit-transient.el
index 55dc374..ad7135b 100644
--- a/lisp/magit-transient.el
+++ b/lisp/magit-transient.el
@@ -118,11 +118,10 @@
nil nil initial-input history))
(defun magit-transient-read-revision (prompt initial-input history)
- (or (magit-completing-read prompt (cons "HEAD" (magit-list-refnames))
- nil nil initial-input history
- (or (magit-branch-or-commit-at-point)
- (magit-get-current-branch)))
- (user-error "Nothing selected")))
+ (magit-completing-read prompt (cons "HEAD" (magit-list-refnames))
+ nil 'any initial-input history
+ (or (magit-branch-or-commit-at-point)
+ (magit-get-current-branch))))
;;;; Set