|
28 | 28 | #include "submodule.h" |
29 | 29 | #include "gpg-interface.h" |
30 | 30 | #include "column.h" |
| 31 | +#include "sequencer.h" |
31 | 32 |
|
32 | 33 | static const char * const builtin_commit_usage[] = { |
33 | 34 | N_("git commit [options] [--] <filepattern>..."), |
@@ -466,8 +467,6 @@ static int is_a_merge(const struct commit *current_head) |
466 | 467 | return !!(current_head->parents && current_head->parents->next); |
467 | 468 | } |
468 | 469 |
|
469 | | -static const char sign_off_header[] = "Signed-off-by: "; |
470 | | - |
471 | 470 | static void export_one(const char *var, const char *s, const char *e, int hack) |
472 | 471 | { |
473 | 472 | struct strbuf buf = STRBUF_INIT; |
@@ -552,47 +551,6 @@ static void determine_author_info(struct strbuf *author_ident) |
552 | 551 | } |
553 | 552 | } |
554 | 553 |
|
555 | | -static int ends_rfc2822_footer(struct strbuf *sb) |
556 | | -{ |
557 | | - int ch; |
558 | | - int hit = 0; |
559 | | - int i, j, k; |
560 | | - int len = sb->len; |
561 | | - int first = 1; |
562 | | - const char *buf = sb->buf; |
563 | | - |
564 | | - for (i = len - 1; i > 0; i--) { |
565 | | - if (hit && buf[i] == '\n') |
566 | | - break; |
567 | | - hit = (buf[i] == '\n'); |
568 | | - } |
569 | | - |
570 | | - while (i < len - 1 && buf[i] == '\n') |
571 | | - i++; |
572 | | - |
573 | | - for (; i < len; i = k) { |
574 | | - for (k = i; k < len && buf[k] != '\n'; k++) |
575 | | - ; /* do nothing */ |
576 | | - k++; |
577 | | - |
578 | | - if ((buf[k] == ' ' || buf[k] == '\t') && !first) |
579 | | - continue; |
580 | | - |
581 | | - first = 0; |
582 | | - |
583 | | - for (j = 0; i + j < len; j++) { |
584 | | - ch = buf[i + j]; |
585 | | - if (ch == ':') |
586 | | - break; |
587 | | - if (isalnum(ch) || |
588 | | - (ch == '-')) |
589 | | - continue; |
590 | | - return 0; |
591 | | - } |
592 | | - } |
593 | | - return 1; |
594 | | -} |
595 | | - |
596 | 554 | static char *cut_ident_timestamp_part(char *string) |
597 | 555 | { |
598 | 556 | char *ket = strrchr(string, '>'); |
@@ -717,21 +675,30 @@ static int prepare_to_commit(const char *index_file, const char *prefix, |
717 | 675 | stripspace(&sb, 0); |
718 | 676 |
|
719 | 677 | if (signoff) { |
720 | | - struct strbuf sob = STRBUF_INIT; |
721 | | - int i; |
722 | | - |
723 | | - strbuf_addstr(&sob, sign_off_header); |
724 | | - strbuf_addstr(&sob, fmt_name(getenv("GIT_COMMITTER_NAME"), |
725 | | - getenv("GIT_COMMITTER_EMAIL"))); |
726 | | - strbuf_addch(&sob, '\n'); |
727 | | - for (i = sb.len - 1; i > 0 && sb.buf[i - 1] != '\n'; i--) |
728 | | - ; /* do nothing */ |
729 | | - if (prefixcmp(sb.buf + i, sob.buf)) { |
730 | | - if (!i || !ends_rfc2822_footer(&sb)) |
731 | | - strbuf_addch(&sb, '\n'); |
732 | | - strbuf_addbuf(&sb, &sob); |
| 678 | + /* |
| 679 | + * See if we have a Conflicts: block at the end. If yes, count |
| 680 | + * its size, so we can ignore it. |
| 681 | + */ |
| 682 | + int ignore_footer = 0; |
| 683 | + int i, eol, previous = 0; |
| 684 | + const char *nl; |
| 685 | + |
| 686 | + for (i = 0; i < sb.len; i++) { |
| 687 | + nl = memchr(sb.buf + i, '\n', sb.len - i); |
| 688 | + if (nl) |
| 689 | + eol = nl - sb.buf; |
| 690 | + else |
| 691 | + eol = sb.len; |
| 692 | + if (!prefixcmp(sb.buf + previous, "\nConflicts:\n")) { |
| 693 | + ignore_footer = sb.len - previous; |
| 694 | + break; |
| 695 | + } |
| 696 | + while (i < eol) |
| 697 | + i++; |
| 698 | + previous = eol; |
733 | 699 | } |
734 | | - strbuf_release(&sob); |
| 700 | + |
| 701 | + append_signoff(&sb, ignore_footer); |
735 | 702 | } |
736 | 703 |
|
737 | 704 | if (fwrite(sb.buf, 1, sb.len, s->fp) < sb.len) |
|
0 commit comments