Skip to content

Commit 9001cce

Browse files
committed
rebase (autostash): use an explicit OID to apply the stash
When `git stash apply <argument>` sees an argument that consists only of digits, it tries to be smart and interpret it as `stash@{<number>}`. Unfortunately, an all-digit hash (which is unlikely but still possible) is therefore misinterpreted as `stash@{<n>}` reflog. To prevent that from happening, let's append `^0` after the stash hash, to make sure that it is interpreted as an OID rather than as a number. Signed-off-by: Johannes Schindelin <[email protected]> Reviewed-by: SZEDER Gábor <[email protected]> Signed-off-by: Junio C Hamano <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 6d7b674 commit 9001cce

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

builtin/rebase.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@ static int apply_autostash(struct rebase_options *opts)
252252

253253
if (read_one(path, &autostash))
254254
return error(_("Could not read '%s'"), path);
255+
/* Ensure that the hash is not mistaken for a number */
256+
strbuf_addstr(&autostash, "^0");
255257
argv_array_pushl(&stash_apply.args,
256258
"stash", "apply", autostash.buf, NULL);
257259
stash_apply.git_cmd = 1;

0 commit comments

Comments
 (0)