Function: magit-read-branch-or-commit

magit-read-branch-or-commit is a byte-compiled function defined in magit-git.el.

Signature

(magit-read-branch-or-commit PROMPT &optional SECONDARY-DEFAULT EXCLUDE)

Source Code

;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/magit-git.el
(defun magit-read-branch-or-commit (prompt &optional secondary-default exclude)
  (let* ((current (magit-get-current-branch))
         (branch-at-point (magit-branch-at-point))
         (commit-at-point (magit-commit-at-point))
         (exclude (ensure-list exclude))
         (choices (cl-set-difference (magit-list-refnames nil t)
                                     exclude :test #'equal)))
    (when (member current exclude)
      (setq current nil))
    (when (member branch-at-point exclude)
      (setq branch-at-point nil))
    (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
      (magit-completing-read
       prompt choices nil 'any nil 'magit-revision-history
       (or branch-at-point commit-at-point secondary-default current)))))