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

[RFH] sequencer: simplify logic around stopped-sha file

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 25, 2020, 05:48 UTC
Message-ID
<xmqq8scymmo1.fsf@gitster.c.googlers.com>

While I was auditing the use of get_oid_committish(), I noticed that an abbreviated object name is written to rebase-merge/stopped-sha only to be read later and expanded to a full object name to be passed to record_in_rewritten(). Nobody seems to expose this to the end-user and it is unclear if there is a point in keeping it short by abbreviating and risking to make it ambiguous as the rebase progresses and creates new objects.

The attached patch tries to simplify the logic involved around this file, to write and read full object names to/from the file, and the result seems to pass testsuite---which in the ideal world would be sufficient signal that this change is safe and sane, but it could be that original authors thought that a change to stop abbreviating is nonsense and not worth protecting the code against, hence RFH here.

Is there something obvious I am not seeing that makes this change a bad idea (other than "somebody may be in the middle of a rebase and all of a sudden, version of Git gets updated to contain this one, which is unable to read abbreviated object name the current version left on disk", which I am deliberately ignoring)?

Thanks.
 sequencer.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/sequencer.c b/sequencer.c
index fd7701c88a..7dc9088d09 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -120,7 +120,7 @@ static GIT_PATH_FUNC(rebase_path_author_script, "rebase-merge/author-script")
 static GIT_PATH_FUNC(rebase_path_amend, "rebase-merge/amend")
 /*
  * When we stop at a given patch via the "edit" command, this file contains
- * the abbreviated commit name of the corresponding patch.
+ * the commit object name of the corresponding patch.
  */
 static GIT_PATH_FUNC(rebase_path_stopped_sha, "rebase-merge/stopped-sha")
 /*
@@ -3012,11 +3012,12 @@ static int make_patch(struct repository *r,
 {
 	struct strbuf buf = STRBUF_INIT;
 	struct rev_info log_tree_opt;
-	const char *subject, *p;
+	const char *subject;
+	char hex[GIT_MAX_HEXSZ + 1];
 	int res = 0;
 
-	p = short_commit_name(commit);
-	if (write_message(p, strlen(p), rebase_path_stopped_sha(), 1) < 0)
+	oid_to_hex_r(hex, &commit->object.oid);
+	if (write_message(hex, strlen(hex), rebase_path_stopped_sha(), 1) < 0)
 		return -1;
 	res |= write_rebase_head(&commit->object.oid);
 
@@ -4396,7 +4397,7 @@ int sequencer_continue(struct repository *r, struct replay_opts *opts)
 
 		if (read_oneliner(&buf, rebase_path_stopped_sha(),
 				  READ_ONELINER_SKIP_IF_EMPTY) &&
-		    !get_oid_committish(buf.buf, &oid))
+		    !get_oid_hex(buf.buf, &oid))
 			record_in_rewritten(&oid, peek_command(&todo_list, 0));
 		strbuf_release(&buf);
 	}
Next: Johannes Schindelin
Message 1 of 4 in “[RFH] sequencer: simplify logic around stopped-sha file”
  1. Junio C HamanoSep 25, 2020
  2. Johannes SchindelinSep 26, 2020
  3. Junio C HamanoSep 27, 2020
  4. Johannes SchindelinSep 28, 2020

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.