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

[PATCH] git stash: Give friendlier error when there is nothing to apply

From
Ori Avtalion <ori@avtalion.name>
Date
Aug 11, 2009, 11:12 UTC
Message-ID
<4a81559c.05ae660a.591b.010b@mx.google.com>
The old message was scary and included a 'fatal' error from rev-parse:
     fatal: Needed a single revision
     : no valid stashed state found

The new message is identical to the one given by 'git stash branch', and given *before* the check for a dirty working tree.

Previously, the command prompted the user to clean a dirty working tree when there is nothing to apply.

Signed-off-by: Ori Avtalion <ori@avtalion.name>
---
 git-stash.sh |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/git-stash.sh b/git-stash.sh
index 03e589f..aa84144 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -162,6 +162,8 @@ show_stash () {
 }
 
 apply_stash () {
+	have_stash || die 'Nothing to apply'
+
 	git update-index -q --refresh &&
 	git diff-files --quiet --ignore-submodules ||
 		die 'Cannot apply to a dirty working tree, please stage your changes'
-- 
1.6.4.73.gc144.dirty
Next: Thomas Rast
Message 1 of 7 in “git stash: Give friendlier error when there is nothing to apply”
  1. git stash: Give friendlier error when there is nothing to applyOri Avtalion, Aug 11, 2009
  2. Thomas RastAug 11, 2009
  3. git stash: Give friendlier errors when there is nothing to applyOri Avtalion, Aug 11, 2009
  4. Thomas RastAug 13, 2009
  5. Junio C HamanoAug 14, 2009
  6. Nanako ShiraishiAug 14, 2009
  7. Junio C HamanoAug 15, 2009

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.