Skip to content

Commit 626f689

Browse files
committed
Merge branch 'jc/fail-stash-to-store-non-stash'
Feeding "git stash store" with a random commit that was not created by "git stash create" now errors out. * jc/fail-stash-to-store-non-stash: stash: be careful what we store
2 parents 755fb09 + d9b6634 commit 626f689

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

builtin/stash.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,12 @@ static int show_stash(int argc, const char **argv, const char *prefix)
989989
static int do_store_stash(const struct object_id *w_commit, const char *stash_msg,
990990
int quiet)
991991
{
992+
struct stash_info info;
993+
char revision[GIT_MAX_HEXSZ];
994+
995+
oid_to_hex_r(revision, w_commit);
996+
assert_stash_like(&info, revision);
997+
992998
if (!stash_msg)
993999
stash_msg = "Created via \"git stash store\".";
9941000

t/t3903-stash.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,10 @@ test_expect_success 'store called with invalid commit' '
931931
test_must_fail git stash store foo
932932
'
933933

934+
test_expect_success 'store called with non-stash commit' '
935+
test_must_fail git stash store HEAD
936+
'
937+
934938
test_expect_success 'store updates stash ref and reflog' '
935939
git stash clear &&
936940
git reset --hard &&

0 commit comments

Comments
 (0)