diff options
| author | Tom Tromey | 2020-08-19 13:38:44 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2020-08-19 13:38:44 +0200 |
| commit | ed96a2121de61390d7acce6f2f03521b47b7d978 (patch) | |
| tree | 26548635d851790613eceb3f2ea116c906fbe8ca | |
| parent | 3b8dfc46ce95ae657b4c33af12ad46827f29084d (diff) | |
| download | emacs-ed96a2121de61390d7acce6f2f03521b47b7d978.tar.gz emacs-ed96a2121de61390d7acce6f2f03521b47b7d978.zip | |
Add a variable to control VC completion over branch names
* lisp/vc/vc-git.el (vc-git-revision-complete-only-branches): New
variable (bug#25710).
(vc-git-revision-table): Use it.
| -rw-r--r-- | etc/NEWS | 4 | ||||
| -rw-r--r-- | lisp/vc/vc-git.el | 18 |
2 files changed, 19 insertions, 3 deletions
| @@ -259,6 +259,10 @@ invoke 'C-u C-x v s' ('vc-create-tag'). | |||
| 259 | --- | 259 | --- |
| 260 | *** 'vc-hg' now uses 'hg summary' to populate extra 'vc-dir' headers. | 260 | *** 'vc-hg' now uses 'hg summary' to populate extra 'vc-dir' headers. |
| 261 | 261 | ||
| 262 | --- | ||
| 263 | *** New variable 'vc-git-revision-complete-only-branches' | ||
| 264 | If non-nil, only branches and remotes are considered when doing | ||
| 265 | completion over branch names. | ||
| 262 | 266 | ||
| 263 | ** Gnus | 267 | ** Gnus |
| 264 | 268 | ||
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 78a2fa08795..84aeb0a1105 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el | |||
| @@ -210,6 +210,16 @@ toggle display of the entire list." | |||
| 210 | widget)))) | 210 | widget)))) |
| 211 | :version "27.1") | 211 | :version "27.1") |
| 212 | 212 | ||
| 213 | (defcustom vc-git-revision-complete-only-branches nil | ||
| 214 | "Control whether tags are returned by revision completion for Git. | ||
| 215 | |||
| 216 | When non-nil, only branches and remotes will be returned by | ||
| 217 | `vc-git-revision-completion-table'. This is used by various VC | ||
| 218 | commands when completing branch names. When nil, tags are also | ||
| 219 | included in the completions." | ||
| 220 | :type 'boolean | ||
| 221 | :version "28.1") | ||
| 222 | |||
| 213 | ;; History of Git commands. | 223 | ;; History of Git commands. |
| 214 | (defvar vc-git-history nil) | 224 | (defvar vc-git-history nil) |
| 215 | 225 | ||
| @@ -1415,9 +1425,11 @@ This requires git 1.8.4 or later, for the \"-L\" option of \"git log\"." | |||
| 1415 | (with-temp-buffer | 1425 | (with-temp-buffer |
| 1416 | (vc-git-command t nil nil "for-each-ref" "--format=%(refname)") | 1426 | (vc-git-command t nil nil "for-each-ref" "--format=%(refname)") |
| 1417 | (goto-char (point-min)) | 1427 | (goto-char (point-min)) |
| 1418 | (while (re-search-forward "^refs/\\(heads\\|tags\\|remotes\\)/\\(.*\\)$" | 1428 | (let ((regexp (if vc-git-revision-complete-only-branches |
| 1419 | nil t) | 1429 | "^refs/\\(heads\\|remotes\\)/\\(.*\\)$" |
| 1420 | (push (match-string 2) table))) | 1430 | "^refs/\\(heads\\|tags\\|remotes\\)/\\(.*\\)$"))) |
| 1431 | (while (re-search-forward regexp nil t) | ||
| 1432 | (push (match-string 2) table)))) | ||
| 1421 | table)) | 1433 | table)) |
| 1422 | 1434 | ||
| 1423 | (defun vc-git-revision-completion-table (files) | 1435 | (defun vc-git-revision-completion-table (files) |