Skip to content

Commit 1eff26c

Browse files
committed
stash: refresh the index before deciding if the work tree is dirty
Unlike the case where the user does have a real change in the work tree, refusing to work because of unclean stat information is not very helpful. Signed-off-by: Junio C Hamano <[email protected]> Acked-by: Nanako Shiraishi <[email protected]>
1 parent 1b118da commit 1eff26c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

git-stash.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ clear_stash () {
3939
create_stash () {
4040
stash_msg="$1"
4141

42+
git update-index -q --refresh
4243
if no_changes
4344
then
4445
exit 0
@@ -101,6 +102,7 @@ save_stash () {
101102

102103
stash_msg="$*"
103104

105+
git update-index -q --refresh
104106
if no_changes
105107
then
106108
echo 'No local changes to save'
@@ -150,6 +152,7 @@ show_stash () {
150152
}
151153

152154
apply_stash () {
155+
git update-index -q --refresh &&
153156
git diff-files --quiet --ignore-submodules ||
154157
die 'Cannot restore on top of a dirty state'
155158

0 commit comments

Comments
 (0)