rebase (autostash): store the full OID in <state-dir>/autostash

It was reported by Gábor Szeder and analyzed by Alban Gruin that the built-in rebase stores only abbreviated stash hashes in the `autostash` file. This is problematic e.g. in t5520-pull.sh, where the abbreviated hash is so short that it sometimes consists only of digits, which are subsequently mistaken ("DWIMmed") for numbers by `git stash apply`. Let's align the behavior of the built-in rebase with the scripted rebase and store the full stash hash instead. That makes it a lot less likely that it consists only of digits. 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>

Johannes Schindelin committed Oct 22, 2018 at 15:15 UTC 12aeb00a22e589f85e26da833e05bb1a7e412d07
1 file changed +1 -1
builtin/rebase.c
+1 -1
@@ -1374,7 +1374,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1374 if (safe_create_leading_directories_const(autostash))
1375 die(_("Could not create directory for '%s'"),
1376 options.state_dir);
1377 - write_file(autostash, "%s", buf.buf);
1377 + write_file(autostash, "%s", oid_to_hex(&oid));
1378 printf(_("Created autostash: %s\n"), buf.buf);
1379 if (reset_head(&head->object.oid, "reset --hard",
1380 NULL, 0, NULL, NULL) < 0)