Skip to contentSkip to conversation

"Stash save" exits with 0 when nothing to stash

PATCH Pascal Malaise 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

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

Quoted 2 lines

On branch master
nothing to commit, working directory clean

and exits with code 1.

Thanks

git-stash.sh +1 -1
diff -u  git-master/git-stash.sh exit1/git-stash.sh 
@@ -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")"