Function: vc-git-stash-read

vc-git-stash-read is a byte-compiled function defined in vc-git.el.gz.

Signature

(vc-git-stash-read PROMPT &key DEFAULT-MOST-RECENT)

Documentation

Prompt the user, with PROMPT, to select a git stash.

PROMPT is passed to format-prompt. If DEFAULT-MOST-RECENT is non-nil, then the most recently pushed stash is the default selection.

Source Code

;; Defined in /usr/src/emacs/lisp/vc/vc-git.el.gz
(cl-defun vc-git-stash-read (prompt &key default-most-recent)
  "Prompt the user, with PROMPT, to select a git stash.
PROMPT is passed to `format-prompt'.  If DEFAULT-MOST-RECENT is non-nil,
then the most recently pushed stash is the default selection."
  (if-let* ((stashes
             (split-string (vc-git--run-command-string nil
                                                       "stash" "list")
                           "\n" t)))
      (let* ((default (and default-most-recent (car stashes)))
             (prompt (format-prompt prompt
                                    (and default-most-recent
                                         "most recent, stash@{0}")))
             (stash (completing-read prompt stashes
                                     nil :require-match nil
                                     'vc-git-stash-read-history
                                     default)))
        (if (string-empty-p stash)
            (user-error "Not a stash")
          (string-match "^stash@{[[:digit:]]+}" stash)
          (match-string 0 stash)))
    (user-error "No stashes")))