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

"Stash save" exits with 0 when nothing to stash

From
PMPascal Malaise <malaise@magic.fr>
Date
Dec 24, 2014, 09:20 UTC
Message-ID
<20141224090636.M86902@magic.fr>
Hi,

When calling "git stash save" in a clean situation (no change since last commit), git-stash reports "No local changes to save", which is OK. But it exits with code 0, despite no stash has been saved. It would be better to exit with code 1 in this case.

N.B. In a similar situation  "git commit -a -m 'Test'" reports
> On branch master
> nothing to commit, working directory clean
and exits with code 1.
Thanks

diff -u git-master/git-stash.sh exit1/git-stash.sh --- git-master/git-stash.sh 2014-12-22 20:43:48.000000000 +0000 +++ exit1/git-stash.sh 2014-12-24 08:59:00.804150443 +0000

@@ -257,7 +257,7 @@
 	if no_changes
 	then
 		say "$(gettext "No local changes to save")"
-		exit 0
+		exit 1
 	fi
 	test -f "$GIT_DIR/logs/$ref_stash" ||
 		clear_stash || die "$(gettext "Cannot initialize stash")"
Message 1 of 1 in “"Stash save" exits with 0 when nothing to stash”
  1. Pascal MalaiseDec 24, 2014

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.