Merge branch 'cc/interpret-trailers-more'
"git interpret-trailers" learned to properly handle the "Conflicts:" block at the end. * cc/interpret-trailers-more: trailer: add test with an old style conflict block trailer: reuse ignore_non_trailer() to ignore conflict lines commit: make ignore_non_trailer() non static merge & sequencer: turn "Conflicts:" hint into a comment builtin/commit.c: extract ignore_non_trailer() helper function merge & sequencer: unify codepaths that write "Conflicts:" hint builtin/merge.c: drop a parameter that is never used
This commit is contained in:
@ -800,32 +800,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
|
||||
if (clean_message_contents)
|
||||
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;
|
||||
else
|
||||
eol = sb.len;
|
||||
if (starts_with(sb.buf + previous, "\nConflicts:\n")) {
|
||||
ignore_footer = sb.len - previous;
|
||||
break;
|
||||
}
|
||||
while (i < eol)
|
||||
i++;
|
||||
previous = eol;
|
||||
}
|
||||
|
||||
append_signoff(&sb, ignore_footer, 0);
|
||||
}
|
||||
if (signoff)
|
||||
append_signoff(&sb, ignore_non_trailer(&sb), 0);
|
||||
|
||||
if (fwrite(sb.buf, 1, sb.len, s->fp) < sb.len)
|
||||
die_errno(_("could not write commit template"));
|
||||
|
Reference in New Issue
Block a user