emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master ed96a21: Add a variable to control VC completion over branch name


From: Lars Ingebrigtsen
Subject: master ed96a21: Add a variable to control VC completion over branch names
Date: Wed, 19 Aug 2020 07:38:53 -0400 (EDT)

branch: master
commit ed96a2121de61390d7acce6f2f03521b47b7d978
Author: Tom Tromey <tom@tromey.com>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    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.
---
 etc/NEWS          |  4 ++++
 lisp/vc/vc-git.el | 18 +++++++++++++++---
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 14101b4..a1255a6 100644
--- 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
 
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 78a2fa0..84aeb0a 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]