From: Junio C Hamano Date: Fri, 6 Jun 2014 18:36:10 +0000 (-0700) Subject: Merge branch 'nd/status-auto-comment-char' X-Git-Tag: v2.1.0-rc0~152 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1e2600dd6a2acf8d2e9c0923184ca2335b861138;p=thirdparty%2Fgit.git Merge branch 'nd/status-auto-comment-char' * nd/status-auto-comment-char: commit: allow core.commentChar=auto for character auto selection config: be strict on core.commentChar --- 1e2600dd6a2acf8d2e9c0923184ca2335b861138 diff --cc builtin/commit.c index d28505a857,515c4c4c05..99c2044635 --- a/builtin/commit.c +++ b/builtin/commit.c @@@ -608,18 -585,45 +608,48 @@@ static void determine_author_info(struc } } -static char *cut_ident_timestamp_part(char *string) +static void split_ident_or_die(struct ident_split *id, const struct strbuf *buf) +{ + if (split_ident_line(id, buf->buf, buf->len) || + !sane_ident_split(id)) + die(_("Malformed ident string: '%s'"), buf->buf); +} + +static int author_date_is_interesting(void) { - char *ket = strrchr(string, '>'); - if (!ket || ket[1] != ' ') - die(_("Malformed ident string: '%s'"), string); - *++ket = '\0'; - return ket; + return author_message || force_date; } + static void adjust_comment_line_char(const struct strbuf *sb) + { + char candidates[] = "#;@!$%^&|:"; + char *candidate; + const char *p; + + comment_line_char = candidates[0]; + if (!memchr(sb->buf, comment_line_char, sb->len)) + return; + + p = sb->buf; + candidate = strchr(candidates, *p); + if (candidate) + *candidate = ' '; + for (p = sb->buf; *p; p++) { + if ((p[0] == '\n' || p[0] == '\r') && p[1]) { + candidate = strchr(candidates, p[1]); + if (candidate) + *candidate = ' '; + } + } + + for (p = candidates; *p == ' '; p++) + ; + if (!*p) + die(_("unable to select a comment character that is not used\n" + "in the current commit message")); + comment_line_char = *p; + } + static int prepare_to_commit(const char *index_file, const char *prefix, struct commit *current_head, struct wt_status *s,