git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Makes 'git-stash show' stay quiet when there are no stashes.

From
JXJing Xue <jingxue@digizenstudio.com>
Date
Dec 14, 2007, 01:28 UTC
Message-ID
<20071214012838.GA8914@fawkes>

(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
Next: Junio C Hamano
Message 1 of 5 in “Makes 'git-stash show' stay quiet when there are no stashes.”
  1. Makes 'git-stash show' stay quiet when there are no stashes.Jing Xue, Dec 14, 2007
  2. Junio C HamanoDec 14, 2007
  3. Replace the cryptic messages from "git stash show".Jing Xue, Dec 15, 2007
  4. Junio C HamanoDec 15, 2007
  5. Jing XueDec 15, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.