Function: magit-read-file-choice

magit-read-file-choice is a byte-compiled function defined in magit-files.el.

Signature

(magit-read-file-choice PROMPT FILES &optional ERROR DEFAULT)

Documentation

Read file from FILES.

If FILES has only one member, return that instead of prompting. If FILES has no members, give a user error. ERROR can be given to provide a more informative error.

If DEFAULT is non-nil, use this as the default value instead of magit-current-file.

Source Code

;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/magit-files.el
(defun magit-read-file-choice (prompt files &optional error default)
  "Read file from FILES.

If FILES has only one member, return that instead of prompting.
If FILES has no members, give a user error.  ERROR can be given
to provide a more informative error.

If DEFAULT is non-nil, use this as the default value instead of
`magit-current-file'."
  (pcase (length files)
    (0 (user-error (or error "No file choices")))
    (1 (car files))
    (_ (magit-completing-read
        prompt files nil t nil 'magit-read-file-hist
        (car (member (or default (magit-current-file)) files))))))