* Inspect the given string and determine the true "end" of the log message, in * order to find where to put a new Signed-off-by trailer. Ignored are * trailing comment lines and blank lines. To support "git commit -s * --amend" on an existing commit, we also ignore "Conflicts:". To * support "git commit -v", we truncate at cut lines. * * Returns the number of bytes from the tail to ignore
| 1955 | * the second parameter to append_signoff(). |
| 1956 | */ |
| 1957 | size_t ignored_log_message_bytes(const char *buf, size_t len) |
| 1958 | { |
| 1959 | size_t boc = 0; |
| 1960 | size_t bol = 0; |
| 1961 | int in_old_conflicts_block = 0; |
| 1962 | size_t cutoff = wt_status_locate_end(buf, len); |
| 1963 | |
| 1964 | while (bol < cutoff) { |
| 1965 | const char *next_line = memchr(buf + bol, '\n', len - bol); |
| 1966 | |
| 1967 | if (!next_line) |
| 1968 | next_line = buf + len; |
| 1969 | else |
| 1970 | next_line++; |
| 1971 | |
| 1972 | if (starts_with_mem(buf + bol, cutoff - bol, comment_line_str) || |
| 1973 | buf[bol] == '\n') { |
| 1974 | /* is this the first of the run of comments? */ |
| 1975 | if (!boc) |
| 1976 | boc = bol; |
| 1977 | /* otherwise, it is just continuing */ |
| 1978 | } else if (starts_with(buf + bol, "Conflicts:\n")) { |
| 1979 | in_old_conflicts_block = 1; |
| 1980 | if (!boc) |
| 1981 | boc = bol; |
| 1982 | } else if (in_old_conflicts_block && buf[bol] == '\t') { |
| 1983 | ; /* a pathname in the conflicts block */ |
| 1984 | } else if (boc) { |
| 1985 | /* the previous was not trailing comment */ |
| 1986 | boc = 0; |
| 1987 | in_old_conflicts_block = 0; |
| 1988 | } |
| 1989 | bol = next_line - buf; |
| 1990 | } |
| 1991 | return boc ? len - boc : len - cutoff; |
| 1992 | } |
| 1993 | |
| 1994 | int run_commit_hook(int editor_is_used, const char *index_file, |
| 1995 | int *invoked_hook, const char *name, ...) |
no test coverage detected