allow editing of log message comments with 'got histedit' This makes it possible to remove just comment lines from log messages during a histedit operation, leaving the rest of the log message as-is. The behaviour of treating changes to comment lines as no-ops was coded to prevent mistakes during 'got commit/import/tag', where the command will error out if the log message template is not modified. This is not appropriate for histedit because histedit is used to fix such mistakes. ok millert@
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
diff --git a/got/got.c b/got/got.c
index 6d42787..a25e475 100644
--- a/got/got.c
+++ b/got/got.c
@@ -431,7 +431,7 @@ doneediting:
static const struct got_error *
edit_logmsg(char **logmsg, const char *editor, const char *logmsg_path,
- const char *initial_content, size_t initial_content_len)
+ const char *initial_content, size_t initial_content_len, int check_comments)
{
const struct got_error *err = NULL;
char *line = NULL;
@@ -526,7 +526,7 @@ edit_logmsg(char **logmsg, const char *editor, const char *logmsg_path,
"commit message cannot be empty, aborting");
goto done;
}
- if (strcmp(*logmsg, initial_content_stripped) == 0)
+ if (check_comments && strcmp(*logmsg, initial_content_stripped) == 0)
err = got_error_msg(GOT_ERR_COMMIT_MSG_EMPTY,
"no changes made to commit message, aborting");
done:
@@ -567,7 +567,7 @@ collect_import_msg(char **logmsg, char **logmsg_path, const char *editor,
}
err = edit_logmsg(logmsg, editor, *logmsg_path, initial_content,
- initial_content_len);
+ initial_content_len, 1);
done:
if (fd != -1 && close(fd) == -1 && err == NULL)
err = got_error_from_errno2("close", *logmsg_path);
@@ -5901,7 +5901,7 @@ get_tag_message(char **tagmsg, char **tagmsg_path, const char *commit_id_str,
if (err)
goto done;
err = edit_logmsg(tagmsg, editor, *tagmsg_path, initial_content,
- initial_content_len);
+ initial_content_len, 1);
done:
free(initial_content);
free(template);
@@ -6782,7 +6782,7 @@ collect_commit_logmsg(struct got_pathlist_head *commitable_paths, char **logmsg,
}
err = edit_logmsg(logmsg, a->editor, a->logmsg_path, initial_content,
- initial_content_len);
+ initial_content_len, 1);
done:
free(initial_content);
free(template);
@@ -8020,7 +8020,7 @@ histedit_edit_logmsg(struct got_histedit_list_entry *hle,
goto done;
err = edit_logmsg(&hle->logmsg, editor, logmsg_path, logmsg,
- logmsg_len);
+ logmsg_len, 0);
if (err) {
if (err->code != GOT_ERR_COMMIT_MSG_EMPTY)
goto done;