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>
Christian Couder committed
Jul 22, 2010 at 15:18 UTC
ad98a58b3d7a151dca59364b72097b6b875a56f6
1 file changed
+7
-15
builtin/blame.c
+7
-15
@@ -1371,7 +1371,8 @@ static void get_commit_info(struct commit *commit,
1371
int detailed)
1372
{
1373
int len;
1374
- char *tmp, *endp, *reencoded, *message;
1374
+ const char *subject;
1375
+ char *reencoded, *message;
1376
static char author_name[1024];
1377
static char author_mail[1024];
1378
static char committer_name[1024];
@@ -1413,22 +1414,13 @@ static void get_commit_info(struct commit *commit,
1414
&ret->committer_time, &ret->committer_tz);
1415
1416
ret->summary = summary_buf;
1416
- tmp = strstr(message, "\n\n");
1417
- if (!tmp) {
1418
- error_out:
1417
+ len = find_commit_subject(message, &subject);
1418
+ if (len && len < sizeof(summary_buf)) {
1419
+ memcpy(summary_buf, subject, len);
1420
+ summary_buf[len] = 0;
1421
+ } else {
1422
sprintf(summary_buf, "(%s)", sha1_to_hex(commit->object.sha1));
1420
- free(reencoded);
1421
- return;
1423
}
1423
- tmp += 2;
1424
- endp = strchr(tmp, '\n');
1425
- if (!endp)
1426
- endp = tmp + strlen(tmp);
1427
- len = endp - tmp;
1428
- if (len >= sizeof(summary_buf) || len == 0)
1429
- goto error_out;
1430
- memcpy(summary_buf, tmp, len);
1431
- summary_buf[len] = 0;
1424
free(reencoded);
1425
}
1426