stash: be careful what we store
commitd9b6634589d5c59b49fd2fc41953469173a40ff5
authorJunio C Hamano <gitster@pobox.com>
Wed, 11 Oct 2023 20:44:03 +0000 (11 13:44 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 11 Oct 2023 23:27:30 +0000 (11 16:27 -0700)
tree969536ef180a7f91e32f6264836bdba6e075fd4c
parent0d1bd1dfb37ef25e1911777c94129fc769ffec38
stash: be careful what we store

"git stash store" is meant to store what "git stash create"
produces, as these two are implementation details of the end-user
facing "git stash save" command.  Even though it is clearly
documented as such, users would try silly things like "git stash
store HEAD" to render their stash unusable.

Worse yet, because "git stash drop" does not allow such a stash
entry to be removed, "git stash clear" would be the only way to
recover from such a mishap.  Reuse the logic that allows "drop" to
refrain from working on such a stash entry to teach "store" to avoid
storing an object that is not a stash entry in the first place.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/stash.c
t/t3903-stash.sh