@ -221,6 +221,9 @@ static int git_sequencer_config(const char *k, const char *v, void *cb)
return ret;
return ret;
}
}
if (opts->action == REPLAY_REVERT && !strcmp(k, "revert.reference"))
opts->commit_use_reference = git_config_bool(k, v);
status = git_gpg_config(k, v, NULL);
status = git_gpg_config(k, v, NULL);
if (status)
if (status)
return status;
return status;
@ -2059,6 +2062,20 @@ static int should_edit(struct replay_opts *opts) {
return opts->edit;
return opts->edit;
}
}
static void refer_to_commit(struct replay_opts *opts,
struct strbuf *msgbuf, struct commit *commit)
{
if (opts->commit_use_reference) {
struct pretty_print_context ctx = {
.abbrev = DEFAULT_ABBREV,
.date_mode.type = DATE_SHORT,
};
format_commit_message(commit, "%h (%s, %ad)", msgbuf, &ctx);
} else {
strbuf_addstr(msgbuf, oid_to_hex(&commit->object.oid));
}
}
static int do_pick_commit(struct repository *r,
static int do_pick_commit(struct repository *r,
struct todo_item *item,
struct todo_item *item,
struct replay_opts *opts,
struct replay_opts *opts,
@ -2167,14 +2184,20 @@ static int do_pick_commit(struct repository *r,
base_label = msg.label;
base_label = msg.label;
next = parent;
next = parent;
next_label = msg.parent_label;
next_label = msg.parent_label;
strbuf_addstr(&msgbuf, "Revert \"");
if (opts->commit_use_reference) {
strbuf_addstr(&msgbuf, msg.subject);
strbuf_addstr(&msgbuf,
strbuf_addstr(&msgbuf, "\"\n\nThis reverts commit ");
"# *** SAY WHY WE ARE REVERTING ON THE TITLE LINE ***");
strbuf_addstr(&msgbuf, oid_to_hex(&commit->object.oid));
} else {
strbuf_addstr(&msgbuf, "Revert \"");
strbuf_addstr(&msgbuf, msg.subject);
strbuf_addstr(&msgbuf, "\"");
}
strbuf_addstr(&msgbuf, "\n\nThis reverts commit ");
refer_to_commit(opts, &msgbuf, commit);
if (commit->parents && commit->parents->next) {
if (commit->parents && commit->parents->next) {
strbuf_addstr(&msgbuf, ", reversing\nchanges made to ");
strbuf_addstr(&msgbuf, ", reversing\nchanges made to ");
strbuf_addstr(&msgbuf, oid_to_hex(&parent->object.oid));
refer_to_commit(opts, &msgbuf, parent);
}
}
strbuf_addstr(&msgbuf, ".\n");
strbuf_addstr(&msgbuf, ".\n");
} else {
} else {