summaryrefslogtreecommitdiff
path: root/sequencer.c
diff options
context:
space:
mode:
authorDenton Liu <liu.denton@gmail.com>2019-04-17 10:23:30 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-04-19 03:05:36 (GMT)
commit1a2b985fb375e7ce14932bfc59365024af2fb6ab (patch)
tree037601e08fa0b4b958b8342b77f991c75799ca97 /sequencer.c
parentdc42e9a83a9e9206566b6bc9b57f431b98682b29 (diff)
downloadgit-1a2b985fb375e7ce14932bfc59365024af2fb6ab.zip
git-1a2b985fb375e7ce14932bfc59365024af2fb6ab.tar.gz
git-1a2b985fb375e7ce14932bfc59365024af2fb6ab.tar.bz2
cherry-pick/revert: add scissors line on merge conflict
Fix a bug where the scissors line is placed after the Conflicts: section, in the case where a merge conflict occurs and commit.cleanup = scissors. Helped-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sequencer.c')
-rw-r--r--sequencer.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/sequencer.c b/sequencer.c
index 501d99f..0375648 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -182,7 +182,7 @@ static int git_sequencer_config(const char *k, const char *v, void *cb)
opts->default_msg_cleanup = COMMIT_MSG_CLEANUP_ALL;
opts->explicit_cleanup = 1;
} else if (!strcmp(s, "scissors")) {
- opts->default_msg_cleanup = COMMIT_MSG_CLEANUP_SPACE;
+ opts->default_msg_cleanup = COMMIT_MSG_CLEANUP_SCISSORS;
opts->explicit_cleanup = 1;
} else {
warning(_("invalid commit message cleanup mode '%s'"),
@@ -554,10 +554,16 @@ static const char *describe_cleanup_mode(int cleanup_mode)
}
void append_conflicts_hint(struct index_state *istate,
- struct strbuf *msgbuf)
+ struct strbuf *msgbuf, enum commit_msg_cleanup_mode cleanup_mode)
{
int i;
+ if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS) {
+ strbuf_addch(msgbuf, '\n');
+ wt_status_append_cut_line(msgbuf);
+ strbuf_addch(msgbuf, comment_line_char);
+ }
+
strbuf_addch(msgbuf, '\n');
strbuf_commented_addf(msgbuf, "Conflicts:\n");
for (i = 0; i < istate->cache_nr;) {
@@ -625,7 +631,8 @@ static int do_recursive_merge(struct repository *r,
_(action_name(opts)));
if (!clean)
- append_conflicts_hint(r->index, msgbuf);
+ append_conflicts_hint(r->index, msgbuf,
+ opts->default_msg_cleanup);
return !clean;
}
@@ -944,7 +951,6 @@ static int run_git_commit(struct repository *r,
unsigned int flags)
{
struct child_process cmd = CHILD_PROCESS_INIT;
- const char *value;
if ((flags & CREATE_ROOT_COMMIT) && !(flags & AMEND_MSG)) {
struct strbuf msg = STRBUF_INIT, script = STRBUF_INIT;
@@ -1014,7 +1020,7 @@ static int run_git_commit(struct repository *r,
argv_array_push(&cmd.args, "-e");
else if (!(flags & CLEANUP_MSG) &&
!opts->signoff && !opts->record_origin &&
- git_config_get_value("commit.cleanup", &value))
+ !opts->explicit_cleanup)
argv_array_push(&cmd.args, "--cleanup=verbatim");
if ((flags & ALLOW_EMPTY))