git stash does not return a usable stash id

Project:Linux software
Category:feature request
Related pages:#5472: git stash
Tags:git stash

Not only git stash does not return a usable stash id that is unchanging, it does not provide a way to programmatically know if anything was stashed.

I am sure there are workarounds, but none is obvious by reading the man page. Provide recipes on the wiki page.



To explain what I am after:

I have a script set to git stash uncommitted changes upon doing a release, and do git stash pop at the end of the release script, but only if anything was stashed at the previous step.


Check the output:

$ git stash
Saved working directory and index state WIP on master: 5ou0ub4 Fix bug.
HEAD is now at 5ou0ub4 Fix bug.
$ git stash
No local changes to save


$ test=`git stash`
$ echo $test
No local changes to save


In case something got actually stashed, the exact reference can be found in: