commit - beb452e226a6110ef7ace94ab1c804f8e5287e04
commit + c7d9bedcc682ecd8d2276eec2a87a2fd4072388e
blob - db215a3dfb509c965b6cad95da9e863781b562eb
blob + 0400c0dc5db068066471e6f4bc56718144e4f0e3
--- got/got.c
+++ got/got.c
struct collect_commit_logmsg_arg {
const char *cmdline_log;
const char *prepared_log;
+ const char *merged_log;
int non_interactive;
const char *editor;
const char *worktree_path;
struct got_pathlist_entry *pe;
const struct got_error *err = NULL;
char *template = NULL;
+ char *prepared_msg = NULL, *merged_msg = NULL;
struct collect_commit_logmsg_arg *a = arg;
int initial_content_len;
int fd = -1;
goto done;
if (a->prepared_log) {
- char *msg;
- err = read_prepared_logmsg(&msg, a->prepared_log);
+ err = read_prepared_logmsg(&prepared_msg, a->prepared_log);
if (err)
goto done;
- if (write(fd, msg, strlen(msg)) == -1) {
- err = got_error_from_errno2("write", a->logmsg_path);
- free(msg);
+ } else if (a->merged_log) {
+ err = read_prepared_logmsg(&merged_msg, a->merged_log);
+ if (err)
goto done;
- }
- free(msg);
}
initial_content_len = asprintf(&initial_content,
- "\n# changes to be committed on branch %s:\n",
- a->branch_name);
+ "%s%s\n# changes to be committed on branch %s:\n",
+ prepared_msg ? prepared_msg : "",
+ merged_msg ? merged_msg : "", a->branch_name);
if (initial_content_len == -1) {
err = got_error_from_errno("asprintf");
goto done;
done:
free(initial_content);
free(template);
+ free(prepared_msg);
+ free(merged_msg);
if (fd != -1 && close(fd) == -1 && err == NULL)
err = got_error_from_errno2("close", a->logmsg_path);
char *cwd = NULL, *id_str = NULL;
struct got_object_id *id = NULL;
const char *logmsg = NULL;
- char *prepared_logmsg = NULL;
+ char *prepared_logmsg = NULL, *merged_logmsg = NULL;
struct collect_commit_logmsg_arg cl_arg;
const char *author = NULL;
char *gitconfig_path = NULL, *editor = NULL, *committer = NULL;
goto done;
if (prepared_logmsg == NULL) {
- error = lookup_logmsg_ref(&prepared_logmsg,
- argc > 0 ? &paths : NULL, &refs,
- worktree, repo);
+ error = lookup_logmsg_ref(&merged_logmsg,
+ argc > 0 ? &paths : NULL, &refs, worktree, repo);
if (error)
goto done;
}
cl_arg.editor = editor;
cl_arg.cmdline_log = logmsg;
cl_arg.prepared_log = prepared_logmsg;
+ cl_arg.merged_log = merged_logmsg;
cl_arg.non_interactive = non_interactive;
cl_arg.worktree_path = got_worktree_get_root_path(worktree);
cl_arg.branch_name = got_worktree_get_head_ref_name(worktree);