static struct object_id *get_cache_tree_oid(struct index_state *istate)
{
- if (!istate->cache_tree)
- istate->cache_tree = cache_tree();
-
if (!cache_tree_fully_valid(istate->cache_tree))
if (cache_tree_update(istate, 0)) {
error(_("unable to update cache tree"));
#define CLEANUP_MSG (1<<3)
#define VERIFY_MSG (1<<4)
#define CREATE_ROOT_COMMIT (1<<5)
+#define VERBATIM_MSG (1<<6)
static int run_command_silent_on_success(struct child_process *cmd)
{
{
struct child_process cmd = CHILD_PROCESS_INIT;
+ if ((flags & CLEANUP_MSG) && (flags & VERBATIM_MSG))
+ BUG("CLEANUP_MSG and VERBATIM_MSG are mutually exclusive");
+
cmd.git_cmd = 1;
if (is_rebase_i(opts) && read_env_script(&cmd.env_array)) {
strvec_pushl(&cmd.args, "-C", "HEAD", NULL);
if ((flags & CLEANUP_MSG))
strvec_push(&cmd.args, "--cleanup=strip");
+ if ((flags & VERBATIM_MSG))
+ strvec_push(&cmd.args, "--cleanup=verbatim");
if ((flags & EDIT_MSG))
strvec_push(&cmd.args, "-e");
else if (!(flags & CLEANUP_MSG) &&
enum commit_msg_cleanup_mode cleanup;
int res = 0;
+ if ((flags & CLEANUP_MSG) && (flags & VERBATIM_MSG))
+ BUG("CLEANUP_MSG and VERBATIM_MSG are mutually exclusive");
+
if (parse_head(r, ¤t_head))
return -1;
if (flags & CLEANUP_MSG)
cleanup = COMMIT_MSG_CLEANUP_ALL;
+ else if (flags & VERBATIM_MSG)
+ cleanup = COMMIT_MSG_CLEANUP_NONE;
else if ((opts->signoff || opts->record_origin) &&
!opts->explicit_cleanup)
cleanup = COMMIT_MSG_CLEANUP_SPACE;
static const char skip_nth_commit_msg_fmt[] = N_("The commit message #%d will be skipped:");
static const char combined_commit_msg_fmt[] = N_("This is a combination of %d commits.");
- static int check_fixup_flag(enum todo_command command,
- enum todo_item_flags flag)
+ static int is_fixup_flag(enum todo_command command, unsigned flag)
{
return command == TODO_FIXUP && ((flag & TODO_REPLACE_FIXUP_MSG) ||
(flag & TODO_EDIT_FIXUP_MSG));
static int append_squash_message(struct strbuf *buf, const char *body,
enum todo_command command, struct replay_opts *opts,
- enum todo_item_flags flag)
+ unsigned flag)
{
const char *fixup_msg;
size_t commented_len = 0, fixup_off;
strbuf_addstr(buf, body + commented_len);
/* fixup -C after squash behaves like squash */
- if (check_fixup_flag(command, flag) && !seen_squash(opts)) {
+ if (is_fixup_flag(command, flag) && !seen_squash(opts)) {
/*
* We're replacing the commit message so we need to
* append the Signed-off-by: trailer if the user
enum todo_command command,
struct commit *commit,
struct replay_opts *opts,
- enum todo_item_flags flag)
+ unsigned flag)
{
struct strbuf buf = STRBUF_INIT;
int res = 0;
opts->current_fixup_count + 2);
strbuf_splice(&buf, 0, eol - buf.buf, header.buf, header.len);
strbuf_release(&header);
- if (check_fixup_flag(command, flag) && !seen_squash(opts))
+ if (is_fixup_flag(command, flag) && !seen_squash(opts))
update_squash_message_for_fixup(&buf);
} else {
struct object_id head;
strbuf_addf(&buf, "%c ", comment_line_char);
strbuf_addf(&buf, _(combined_commit_msg_fmt), 2);
strbuf_addf(&buf, "\n%c ", comment_line_char);
- strbuf_addstr(&buf, check_fixup_flag(command, flag) ?
+ strbuf_addstr(&buf, is_fixup_flag(command, flag) ?
_(skip_first_commit_msg_str) :
_(first_commit_msg_str));
strbuf_addstr(&buf, "\n\n");
- if (check_fixup_flag(command, flag))
+ if (is_fixup_flag(command, flag))
strbuf_add_commented_lines(&buf, body, strlen(body));
else
strbuf_addstr(&buf, body);
oid_to_hex(&commit->object.oid));
find_commit_subject(message, &body);
- if (command == TODO_SQUASH || check_fixup_flag(command, flag)) {
+ if (command == TODO_SQUASH || is_fixup_flag(command, flag)) {
res = append_squash_message(&buf, body, command, opts, flag);
} else if (command == TODO_FIXUP) {
strbuf_addf(&buf, "\n%c ", comment_line_char);
if (!final_fixup)
msg_file = rebase_path_squash_msg();
else if (file_exists(rebase_path_fixup_msg())) {
- flags |= CLEANUP_MSG;
+ flags |= VERBATIM_MSG;
msg_file = rebase_path_fixup_msg();
} else {
const char *dest = git_path_squash_msg(r);
int i, insert, nr = 0, alloc = 0;
struct todo_item *items = NULL, *base_items = NULL;
- base_items = xcalloc(commands->nr, sizeof(struct todo_item));
+ CALLOC_ARRAY(base_items, commands->nr);
for (i = 0; i < commands->nr; i++) {
size_t command_len = strlen(commands->items[i].string);
define_commit_slab(commit_todo_item, struct todo_item *);
- static inline int skip_fixup_amend_squash(const char *subject, const char **p) {
+ static int skip_fixupish(const char *subject, const char **p) {
return skip_prefix(subject, "fixup! ", p) ||
skip_prefix(subject, "amend! ", p) ||
skip_prefix(subject, "squash! ", p);
format_subject(&buf, subject, " ");
subject = subjects[i] = strbuf_detach(&buf, &subject_len);
unuse_commit_buffer(item->commit, commit_buffer);
- if (skip_fixup_amend_squash(subject, &p)) {
+ if (skip_fixupish(subject, &p)) {
struct commit *commit2;
for (;;) {
while (isspace(*p))
p++;
- if (!skip_fixup_amend_squash(p, &p))
+ if (!skip_fixupish(p, &p))
break;
}