git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jing Xue <jingxue@digizenstudio.com>
To: git <git@vger.kernel.org>
Subject: [PATCH] Makes 'git-stash show' stay quiet when there are no stashes.
Date: Thu, 13 Dec 2007 20:28:38 -0500	[thread overview]
Message-ID: <20071214012838.GA8914@fawkes> (raw)


(I tried to send this trivial patch for a couple of times using
git-send-email, but somehow it never turned up.)

Currently when there are no stashes, 'git stash show' basically aborts with an
error message from rev-parse: "fatal: Needed a single revision", which can be
confusing. This patch makes git-stash keep quiet and exit gracefully in that
case.

---
 git-stash.sh |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/git-stash.sh b/git-stash.sh
index f16fd9c..dbdaeaf 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -119,6 +119,10 @@ show_stash () {
 		flags=--stat
 	fi
 	s=$(git rev-parse --revs-only --no-flags --default $ref_stash "$@")
+	if test -z "$s"
+	then
+		exit 0
+	fi
 
 	w_commit=$(git rev-parse --verify "$s") &&
 	b_commit=$(git rev-parse --verify "$s^") &&
-- 
1.5.4.rc0.1.g3696

             reply	other threads:[~2007-12-14  1:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-14  1:28 Jing Xue [this message]
2007-12-14  1:34 ` [PATCH] Makes 'git-stash show' stay quiet when there are no stashes Junio C Hamano
2007-12-15  5:14   ` [PATCH] Replace the cryptic messages from "git stash show" Jing Xue
2007-12-15  6:12     ` Junio C Hamano
2007-12-15 17:08       ` Jing Xue

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071214012838.GA8914@fawkes \
    --to=jingxue@digizenstudio.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).