@matheusbsbs / matheus-bagliano / commits / 97bc00a490
Fork 0

Emit helpful status for accidental "git stash" save

If the user types "git stash" mistakenly thinking that this will list their stashes he/she may be surprised to see that it actually saved a new stash and reset their working tree and index. In the worst case they might not know how to recover the state. So help them by telling them exactly what was saved and also how to restore it immediately. Signed-off-by: Wincent Colaiuta <win@wincent.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Wincent Colaiuta committed Dec 22, 2007 at 18:31 UTC 97bc00a4909fb73eba8a05dc89fe7914d7123245
1 file changed +4 -2
git-stash.sh
+4 -2
@@ -99,7 +99,7 @@ save_stash () {
99
100 git update-ref -m "$stash_msg" $ref_stash $w_commit ||
101 die "Cannot save the current status"
102 - printf >&2 'Saved "%s"\n' "$stash_msg"
102 + printf >&2 'Saved working directory and index state "%s"\n' "$stash_msg"
103 }
104
105 have_stash () {
@@ -228,7 +228,9 @@ create)
228 *)
229 if test $# -eq 0
230 then
231 - save_stash && git-reset --hard
231 + save_stash &&
232 + echo >&2 '(To restore them type "git stash apply")' &&
233 + git-reset --hard
234 else
235 usage
236 fi