]> git.eshelyaron.com Git - emacs.git/commitdiff
Add a variable to control VC completion over branch names
authorTom Tromey <tom@tromey.com>
Wed, 19 Aug 2020 11:38:44 +0000 (13:38 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Wed, 19 Aug 2020 11:38:44 +0000 (13:38 +0200)
* lisp/vc/vc-git.el (vc-git-revision-complete-only-branches): New
variable (bug#25710).
(vc-git-revision-table): Use it.

etc/NEWS
lisp/vc/vc-git.el

index 14101b41d96eeeb2818a0893869f2b9713bab10b..a1255a6f42352f0efe5015426b94e7bcf7eb20e7 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -259,6 +259,10 @@ invoke 'C-u C-x v s' ('vc-create-tag').
 ---
 *** 'vc-hg' now uses 'hg summary' to populate extra 'vc-dir' headers.
 
+---
+*** New variable 'vc-git-revision-complete-only-branches'
+If non-nil, only branches and remotes are considered when doing
+completion over branch names.
 
 ** Gnus
 
index 78a2fa0879511ce6914887fa49c874dc118434fd..84aeb0a11053527f2cc0939a710987901a7eb9d8 100644 (file)
@@ -210,6 +210,16 @@ toggle display of the entire list."
                               widget))))
   :version "27.1")
 
+(defcustom vc-git-revision-complete-only-branches nil
+  "Control whether tags are returned by revision completion for Git.
+
+When non-nil, only branches and remotes will be returned by
+`vc-git-revision-completion-table'.  This is used by various VC
+commands when completing branch names.  When nil, tags are also
+included in the completions."
+  :type 'boolean
+  :version "28.1")
+
 ;; History of Git commands.
 (defvar vc-git-history nil)
 
@@ -1415,9 +1425,11 @@ This requires git 1.8.4 or later, for the \"-L\" option of \"git log\"."
     (with-temp-buffer
       (vc-git-command t nil nil "for-each-ref" "--format=%(refname)")
       (goto-char (point-min))
-      (while (re-search-forward "^refs/\\(heads\\|tags\\|remotes\\)/\\(.*\\)$"
-                                nil t)
-        (push (match-string 2) table)))
+      (let ((regexp (if vc-git-revision-complete-only-branches
+                        "^refs/\\(heads\\|remotes\\)/\\(.*\\)$"
+                      "^refs/\\(heads\\|tags\\|remotes\\)/\\(.*\\)$")))
+        (while (re-search-forward regexp nil t)
+          (push (match-string 2) table))))
     table))
 
 (defun vc-git-revision-completion-table (files)