git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 2/3] rebase (autostash): store the full OID in <state-dir>/autostash

From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
Date
Oct 22, 2018, 22:15 UTC
Message-ID
<86107a6d0a044e3338e6f70313917066d200a1f4.1540246499.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.52.v2.git.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>

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>
---
 builtin/rebase.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/rebase.c b/builtin/rebase.c
index d21504d9f..418624837 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -1375,7 +1375,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 			if (safe_create_leading_directories_const(autostash))
 				die(_("Could not create directory for '%s'"),
 				    options.state_dir);
-			write_file(autostash, "%s", buf.buf);
+			write_file(autostash, "%s", oid_to_hex(&oid));
 			printf(_("Created autostash: %s\n"), buf.buf);
 			if (reset_head(&head->object.oid, "reset --hard",
 				       NULL, 0, NULL, NULL) < 0)
-- 
gitgitgadget
Previous: Alban GruinNext: Johannes Schindelin via GitGitGadget
Message 8 of 9 in “Fix rebase autostash”
  1. 0/3 Fix rebase autostashJohannes Schindelin via GitGitGadget, Oct 22, 2018
  2. 3/3 rebase (autostash): use an explicit OID to apply the stashJohannes Schindelin via GitGitGadget, Oct 22, 2018
  3. Eric SunshineOct 22, 2018
  4. SZEDER GáborOct 22, 2018
  5. Junio C HamanoOct 23, 2018
  6. Johannes SchindelinOct 23, 2018
  7. Alban GruinOct 23, 2018
  8. 2/3 rebase (autostash): store the full OID in <state-dir>/autostashJohannes Schindelin via GitGitGadget, Oct 22, 2018
  9. 1/3 rebase (autostash): avoid duplicate call to state_dir_path()Johannes Schindelin via GitGitGadget, Oct 22, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.