Just like other hints such as "Change to be committed" we show in the editor to remind the committer what paths were involved in the resulting commit to improve their log message, this section is merely a reminder. Traditionally, it was not made into comments primarily because it has to be generated outside wt-status infrastructure, and secondary it was meant as a bit stronger reminder than the rest (i.e. explaining how you resolved conflicts is much more important than mentioning what you did to every paths involved in the commit), but that still does not make this hint a hint, which should be commented out by default.
Signed-off-by: Junio C Hamano <gits...@pobox.com> --- builtin/commit.c | 42 ++++++++++++++++++++--------------------- sequencer.c | 7 +++---- t/t3507-cherry-pick-conflict.sh | 22 +++++++++++++-------- 3 files changed, 38 insertions(+), 33 deletions(-) diff --git a/builtin/commit.c b/builtin/commit.c index fedb45a..3a1d1a8 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -719,30 +719,30 @@ static int prepare_to_commit(const char *index_file, const char *prefix, stripspace(&sb, 0); if (signoff) { - /* - * See if we have a Conflicts: block at the end. If yes, count - * its size, so we can ignore it. - */ - int ignore_footer = 0; - int i, eol, previous = 0; - const char *nl; - - for (i = 0; i < sb.len; i++) { - nl = memchr(sb.buf + i, '\n', sb.len - i); - if (nl) - eol = nl - sb.buf; + /* Ignore comments and blanks after the trailer */ + int boc = 0; + int bol = 0; + + while (bol < sb.len) { + char *next_line; + + if (!(next_line = memchr(sb.buf + bol, '\n', sb.len - bol))) + next_line = sb.buf + sb.len; else - eol = sb.len; - if (!prefixcmp(sb.buf + previous, "\nConflicts:\n")) { - ignore_footer = sb.len - previous; - break; + next_line++; + + if (sb.buf[bol] == comment_line_char || sb.buf[bol] == '\n') { + /* is this the first of the run of comments? */ + if (!boc) + boc = bol; + /* otherwise, it is just continuing */ + } else if (boc) { + /* the previous was not trailing comment */ + boc = 0; } - while (i < eol) - i++; - previous = eol; + bol = next_line - sb.buf; } - - append_signoff(&sb, ignore_footer, 0); + append_signoff(&sb, boc ? sb.len - boc : 0, 0); } if (fwrite(sb.buf, 1, sb.len, s->fp) < sb.len) diff --git a/sequencer.c b/sequencer.c index 0f84bbe..1d97da3 100644 --- a/sequencer.c +++ b/sequencer.c @@ -291,13 +291,12 @@ void append_conflicts_hint(struct strbuf *msgbuf) { int i; - strbuf_addstr(msgbuf, "\nConflicts:\n"); + strbuf_addch(msgbuf, '\n'); + strbuf_commented_addf(msgbuf, "Conflicts:\n"); for (i = 0; i < active_nr;) { const struct cache_entry *ce = active_cache[i++]; if (ce_stage(ce)) { - strbuf_addch(msgbuf, '\t'); - strbuf_addstr(msgbuf, ce->name); - strbuf_addch(msgbuf, '\n'); + strbuf_commented_addf(msgbuf, "\t%s\n", ce->name); while (i < active_nr && !strcmp(ce->name, active_cache[i]->name)) i++; diff --git a/t/t3507-cherry-pick-conflict.sh b/t/t3507-cherry-pick-conflict.sh index 223b984..fa04226 100755 --- a/t/t3507-cherry-pick-conflict.sh +++ b/t/t3507-cherry-pick-conflict.sh @@ -351,18 +351,24 @@ test_expect_success 'commit after failed cherry-pick does not add duplicated -s' test_expect_success 'commit after failed cherry-pick adds -s at the right place' ' pristine_detach initial && test_must_fail git cherry-pick picked && + git commit -a -s && - pwd && - cat <<EOF > expected && -picked -Signed-off-by: C O Mitter <commit...@example.com> + # Do S-o-b and Conflicts appear in the right order? + cat <<-\EOF >expect && + Signed-off-by: C O Mitter <commit...@example.com> + # Conflicts: + EOF + grep -e "^# Conflicts:" -e '^Signed-off-by' <.git/COMMIT_EDITMSG >actual && + test_cmp expect actual && + + cat <<-\EOF >expected && + picked -Conflicts: - foo -EOF + Signed-off-by: C O Mitter <commit...@example.com> + EOF - git show -s --pretty=format:%B > actual && + git show -s --pretty=format:%B >actual && test_cmp expected actual ' -- 2.1.2-595-g1568c45 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html