From b02f05fc569f3946366ac2ede27349cd09618265 Mon Sep 17 00:00:00 2001 From: Robert Pluim Date: Tue, 5 Feb 2019 10:51:42 +0100 Subject: [PATCH] vc-git: allow not showing git stash list in vc-dir To: emacs-devel@gnu.org * lisp/vc/vc-git.el (vc-git-show-stash): New variable. (vc-git-dir-extra-headers): Only show stash list when vc-git-show-stash is t. --- etc/NEWS | 3 +++ lisp/vc/vc-git.el | 49 ++++++++++++++++++++++++++--------------------- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 271cc6e044..8c3993474c 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -733,6 +733,9 @@ The default value is 'find-dired-sort-by-filename'. *** New command 'log-edit-generate-changelog-from-diff', bound to C-c C-w. This generates ChangeLog entries from the VC fileset diff. +*** New customizable variable 'vc-git-show-stash'. +Default t, set it to nil to hide stashes in 'vc-dir' when using git. + *** Recording ChangeLog entries doesn't require an actual file. If a ChangeLog file doesn't exist, and if the new variable 'add-log-dont-create-changelog-file' is non-nil (which is the diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 9715aea1fd..615474cd76 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -192,6 +192,11 @@ vc-git-grep-template :type 'string :version "27.1") +(defcustom vc-git-show-stash t + "Whether to show the git stash list." + :type 'boolean + :version "27.1") + ;; History of Git commands. (defvar vc-git-history nil) @@ -655,7 +660,7 @@ vc-git-dir-extra-headers (let ((str (with-output-to-string (with-current-buffer standard-output (vc-git--out-ok "symbolic-ref" "HEAD")))) - (stash (vc-git-stash-list)) + (stash (when vc-git-show-stash (vc-git-stash-list))) (stash-help-echo "Use M-x vc-git-stash to create stashes.") branch remote remote-url) (if (string-match "^\\(refs/heads/\\)?\\(.+\\)$" str) @@ -688,30 +693,30 @@ vc-git-dir-extra-headers (propertize "Remote : " 'face 'font-lock-type-face) (propertize remote-url 'face 'font-lock-variable-name-face))) - "\n" ;; For now just a heading, key bindings can be added later for various bisect actions (when (file-exists-p (expand-file-name ".git/BISECT_START" (vc-git-root dir))) - (propertize "Bisect : in progress\n" 'face 'font-lock-warning-face)) + (propertize "\nBisect : in progress" 'face 'font-lock-warning-face)) (when (file-exists-p (expand-file-name ".git/rebase-apply" (vc-git-root dir))) - (propertize "Rebase : in progress\n" 'face 'font-lock-warning-face)) - (if stash - (concat - (propertize "Stash :\n" 'face 'font-lock-type-face - 'help-echo stash-help-echo) - (mapconcat - (lambda (x) - (propertize x - 'face 'font-lock-variable-name-face - 'mouse-face 'highlight - 'help-echo "mouse-3: Show stash menu\nRET: Show stash\nA: Apply stash\nP: Apply and remove stash (pop)\nC-k: Delete stash" - 'keymap vc-git-stash-map)) - stash "\n")) - (concat - (propertize "Stash : " 'face 'font-lock-type-face - 'help-echo stash-help-echo) - (propertize "Nothing stashed" - 'help-echo stash-help-echo - 'face 'font-lock-variable-name-face)))))) + (propertize "\nRebase : in progress" 'face 'font-lock-warning-face)) + (when vc-git-show-stash + (if stash + (concat + (propertize "\nStash :\n" 'face 'font-lock-type-face + 'help-echo stash-help-echo) + (mapconcat + (lambda (x) + (propertize x + 'face 'font-lock-variable-name-face + 'mouse-face 'highlight + 'help-echo "mouse-3: Show stash menu\nRET: Show stash\nA: Apply stash\nP: Apply and remove stash (pop)\nC-k: Delete stash" + 'keymap vc-git-stash-map)) + stash "\n")) + (concat + (propertize "\nStash : " 'face 'font-lock-type-face + 'help-echo stash-help-echo) + (propertize "Nothing stashed" + 'help-echo stash-help-echo + 'face 'font-lock-variable-name-face))))))) (defun vc-git-branches () "Return the existing branches, as a list of strings. -- 2.23.0