magit-read-rev: add mechanism to mask uninteresting refs
This commit is contained in:
parent
adce2cbfc3
commit
50156dedc1
1 changed files with 13 additions and 8 deletions
21
magit.el
21
magit.el
|
@ -819,12 +819,14 @@ working directory state (or HEAD in a log buffer). If it's a
|
|||
pair (START . END), then the range is START..END.")
|
||||
(make-variable-buffer-local 'magit-current-range)
|
||||
|
||||
(defun magit-list-interesting-refs ()
|
||||
(defun magit-list-interesting-refs (&optional uninteresting)
|
||||
(let ((refs ()))
|
||||
(dolist (line (magit-git-lines "show-ref"))
|
||||
(if (string-match "[^ ]+ +\\(.*\\)" line)
|
||||
(let ((ref (match-string 1 line)))
|
||||
(cond ((string-match "refs/heads/\\(.*\\)" ref)
|
||||
(cond ((loop for i in uninteresting
|
||||
thereis (string-match i ref)))
|
||||
((string-match "refs/heads/\\(.*\\)" ref)
|
||||
(let ((branch (match-string 1 ref)))
|
||||
(push (cons branch branch) refs)))
|
||||
((string-match "refs/tags/\\(.*\\)" ref)
|
||||
|
@ -844,13 +846,16 @@ pair (START . END), then the range is START..END.")
|
|||
(match-string 2 ref)))
|
||||
ref)
|
||||
refs))))))
|
||||
refs))
|
||||
(nreverse refs)))
|
||||
|
||||
(defun magit-read-rev (prompt &optional def)
|
||||
(let* ((prompt (if def
|
||||
(format "%s (default %s): " prompt def)
|
||||
(format "%s: " prompt)))
|
||||
(interesting-refs (magit-list-interesting-refs))
|
||||
(defvar magit-uninteresting-refs '("refs/remotes/\\([^/]+\\)/HEAD$"))
|
||||
|
||||
;; TODO: fix this so that def can (must?) be git rev instead of, say, "master (origin)"
|
||||
;; which involves a particular display strategy and shouldn't be visible to callers
|
||||
;; of magit-read-rev
|
||||
(defun magit-read-rev (prompt &optional def uninteresting)
|
||||
(let* ((interesting-refs (magit-list-interesting-refs
|
||||
(or uninteresting magit-uninteresting-refs)))
|
||||
(reply (magit-completing-read prompt interesting-refs nil nil nil
|
||||
'magit-read-rev-history def))
|
||||
(rev (or (cdr (assoc reply interesting-refs)) reply)))
|
||||
|
|
Loading…
Reference in a new issue