]> git.ipfire.org Git - thirdparty/git.git/commitdiff
rebase (autostash): use an explicit OID to apply the stash
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Mon, 22 Oct 2018 22:15:05 +0000 (15:15 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 23 Oct 2018 04:18:01 +0000 (13:18 +0900)
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 <johannes.schindelin@gmx.de>
Reviewed-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/rebase.c

index cd6beb96b40f97027734fe2c5dd8bb89f86c7187..e9995c9a37251d30e5a08c63a8545d84ab88e14f 100644 (file)
@@ -252,6 +252,8 @@ static int apply_autostash(struct rebase_options *opts)
 
        if (read_one(path, &autostash))
                return error(_("Could not read '%s'"), path);
+       /* Ensure that the hash is not mistaken for a number */
+       strbuf_addstr(&autostash, "^0");
        argv_array_pushl(&stash_apply.args,
                         "stash", "apply", autostash.buf, NULL);
        stash_apply.git_cmd = 1;