| 698 | |
| 699 | #ifndef WITH_BREAKING_CHANGES |
| 700 | static void adjust_comment_line_char(const struct strbuf *sb) |
| 701 | { |
| 702 | char candidates[] = "#;@!$%^&|:"; |
| 703 | char *candidate; |
| 704 | const char *p; |
| 705 | size_t cutoff; |
| 706 | |
| 707 | /* Ignore comment chars in trailing comments (e.g., Conflicts:) */ |
| 708 | cutoff = sb->len - ignored_log_message_bytes(sb->buf, sb->len); |
| 709 | |
| 710 | if (!memchr(sb->buf, candidates[0], sb->len)) { |
| 711 | free(comment_line_str_to_free); |
| 712 | comment_line_str = comment_line_str_to_free = |
| 713 | xstrfmt("%c", candidates[0]); |
| 714 | return; |
| 715 | } |
| 716 | |
| 717 | p = sb->buf; |
| 718 | candidate = strchr(candidates, *p); |
| 719 | if (candidate) |
| 720 | *candidate = ' '; |
| 721 | for (p = sb->buf; p + 1 < sb->buf + cutoff; p++) { |
| 722 | if ((p[0] == '\n' || p[0] == '\r') && p[1]) { |
| 723 | candidate = strchr(candidates, p[1]); |
| 724 | if (candidate) |
| 725 | *candidate = ' '; |
| 726 | } |
| 727 | } |
| 728 | |
| 729 | for (p = candidates; *p == ' '; p++) |
| 730 | ; |
| 731 | if (!*p) |
| 732 | die(_("unable to select a comment character that is not used\n" |
| 733 | "in the current commit message")); |
| 734 | free(comment_line_str_to_free); |
| 735 | comment_line_str = comment_line_str_to_free = xstrfmt("%c", *p); |
| 736 | } |
| 737 | #endif /* !WITH_BREAKING_CHANGES */ |
| 738 | |
| 739 | static void prepare_amend_commit(struct commit *commit, struct strbuf *sb, |
no test coverage detected