git stash does not return a usable stash id

Project:Linux software
Component:Documentation
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Related pages:#5472: git stash
Tags:git stash
Description

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.

Comments

#1

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.

#2

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

Hence:

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

#3

In case something got actually stashed, the exact reference can be found in:
refs/stash@{0}