blame: use find_commit_subject() instead of custom code
Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
49b7120ef1
commit
ad98a58b3d
@ -1371,7 +1371,8 @@ static void get_commit_info(struct commit *commit,
|
|||||||
int detailed)
|
int detailed)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
char *tmp, *endp, *reencoded, *message;
|
const char *subject;
|
||||||
|
char *reencoded, *message;
|
||||||
static char author_name[1024];
|
static char author_name[1024];
|
||||||
static char author_mail[1024];
|
static char author_mail[1024];
|
||||||
static char committer_name[1024];
|
static char committer_name[1024];
|
||||||
@ -1413,22 +1414,13 @@ static void get_commit_info(struct commit *commit,
|
|||||||
&ret->committer_time, &ret->committer_tz);
|
&ret->committer_time, &ret->committer_tz);
|
||||||
|
|
||||||
ret->summary = summary_buf;
|
ret->summary = summary_buf;
|
||||||
tmp = strstr(message, "\n\n");
|
len = find_commit_subject(message, &subject);
|
||||||
if (!tmp) {
|
if (len && len < sizeof(summary_buf)) {
|
||||||
error_out:
|
memcpy(summary_buf, subject, len);
|
||||||
sprintf(summary_buf, "(%s)", sha1_to_hex(commit->object.sha1));
|
|
||||||
free(reencoded);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
tmp += 2;
|
|
||||||
endp = strchr(tmp, '\n');
|
|
||||||
if (!endp)
|
|
||||||
endp = tmp + strlen(tmp);
|
|
||||||
len = endp - tmp;
|
|
||||||
if (len >= sizeof(summary_buf) || len == 0)
|
|
||||||
goto error_out;
|
|
||||||
memcpy(summary_buf, tmp, len);
|
|
||||||
summary_buf[len] = 0;
|
summary_buf[len] = 0;
|
||||||
|
} else {
|
||||||
|
sprintf(summary_buf, "(%s)", sha1_to_hex(commit->object.sha1));
|
||||||
|
}
|
||||||
free(reencoded);
|
free(reencoded);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user