Commit Diff


commit - 8b3ae425fe39895d4f5d1be49b178703173e964d
commit + c7ee7a0aebd0cf0ba96bd4215bd263d8f1dd8e6b
blob - e5e8dfe5ea486023e1fa66c734427420deb1b9b8
blob + 1ebe8e6bc34a5cf56e0824f9c4b8c0f986f38301
--- got/got.c
+++ got/got.c
@@ -8914,9 +8914,7 @@ lookup_logmsg_ref(char **logmsg_path, struct got_pathl
 
 	TAILQ_INIT(&refs);
 
-	err = got_opentemp_named(logmsg_path, &f, "got-commit-logmsg", "");
-	if (err)
-		goto done;
+	*logmsg_path = NULL;
 
 	err = got_worktree_get_uuid(&uuidstr, worktree);
 	if (err)
@@ -8968,6 +8966,12 @@ lookup_logmsg_ref(char **logmsg_path, struct got_pathl
 			goto done;
 
 		if (add_logmsg) {
+			if (f == NULL) {
+				err = got_opentemp_named(logmsg_path, &f,
+				    "got-commit-logmsg", "");
+				if (err)
+					goto done;
+			}
 			err = cat_logmsg(f, commit, refname, type,
 			    added_logmsg);
 			if (err)