Commit 71392a05f2ee999ddda39f6b5eb64d0bc292c0ce

Stefan Sperling 2020-12-13T11:43:41

prevent log message loss of folded commits during histedit If the histedit log message editor exits without saving its buffer, Got threw away log messages of all commits which were folded. Only the last commit message is preserved, which could be something meaningless like "fixup". Instead, preserve the initial editor buffer content as-is. That is 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 a0ff...' Problem reported by jrick

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
diff --git a/got/got.c b/got/got.c
index 4df2db7..6d42787 100644
--- a/got/got.c
+++ b/got/got.c
@@ -8024,7 +8024,10 @@ histedit_edit_logmsg(struct got_histedit_list_entry *hle,
 	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)