"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Stefan Sperling <stsp@stsp.name>
Subject:
prevent log message loss during histedit
To:
gameoftrees@openbsd.org
Date:
Fri, 11 Dec 2020 01:27:04 +0100

Download raw body.

Thread
If the histedit log message editor exits without saving its buffer,
we currently throw away log messages of all commits which were folded.
Only the last commit message is preserved, which could be something
meaningless like "fixup".

This patch makes us preserve the initial editor buffer content as-is.
That's not going to be an ideal log message, but doesn't throw away
information and stands out visually because the newly created log
message will start with a comment like:
[[[
# log message of folded commit aabbcc00...
]]]

Git's approach is to concatentate all log messages and strip comments.
That has other downsides such as resulting in a potentially nonsensical
log message.
I'd like to stick to a simple "what you see is what you get" approach.
 
Problem reported by jrick

ok?
 
diff a2c1255649ab1b8d0fc66ec6ff07646b6176e764 c10001dba47001c869fa9d1b8f1981b66c10cccc
blob - 7bdd9e142a5f26254c73c308684bb6d6da95ef20
blob + 997426c9255fb2e425f894acf4aa233d6fdb7722
--- got/got.c
+++ got/got.c
@@ -8018,7 +8018,10 @@ histedit_edit_logmsg(struct got_histedit_list_entry *h
 	if (err) {
 		if (err->code != GOT_ERR_COMMIT_MSG_EMPTY)
 			goto done;
-		err = got_object_commit_get_logmsg(&hle->logmsg, commit);
+		err = NULL;
+		hle->logmsg = strdup(new_msg);
+		if (hle->logmsg == NULL)
+			err = got_error_from_errno("strdup");
 	}
 done:
 	if (logmsg_path && unlink(logmsg_path) != 0 && err == NULL)