From f9fc64560dcf892826eddca535c0c869d2922041 Mon Sep 17 00:00:00 2001 From: Alexander Kuleshov Date: Thu, 21 Jul 2016 18:42:48 +0600 Subject: [PATCH] vc-git: prevent execution of git stash in error cases * lisp/vc/vc-git.el (vc-git-stash-show): prevent execution if stash name is empty or a repo hasn't stashes. --- lisp/vc/vc-git.el | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index e6fe019..940738d 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -1348,12 +1348,16 @@ vc-git-stash (defun vc-git-stash-show (name) "Show the contents of stash NAME." (interactive "sStash name: ") - (vc-setup-buffer "*vc-git-stash*") - (vc-git-command "*vc-git-stash*" 'async nil "stash" "show" "-p" name) - (set-buffer "*vc-git-stash*") - (diff-mode) - (setq buffer-read-only t) - (pop-to-buffer (current-buffer))) + (if (string= name "") + (error "stash name can't be empty string.")) + (if (eq (vc-git-stash-list) nil) + (error "There are no stashes.") + (vc-setup-buffer "*vc-git-stash*") + (vc-git-command "*vc-git-stash*" 'async nil "stash" "show" "-p" name) + (set-buffer "*vc-git-stash*") + (diff-mode) + (setq buffer-read-only t) + (pop-to-buffer (current-buffer)))) (defun vc-git-stash-apply (name) "Apply stash NAME." -- 2.8.0.rc3.1353.gea9bdc0