summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorChristian Couder <chriscool@tuxfamily.org>2010-07-22 13:18:35 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-07-23 23:12:48 (GMT)
commitad98a58b3d7a151dca59364b72097b6b875a56f6 (patch)
tree838cb60c1e827630582f79e16f35807fda696225 /builtin
parent49b7120ef1c915439b01f23f30ddfe64565ec9cc (diff)
downloadgit-ad98a58b3d7a151dca59364b72097b6b875a56f6.zip
git-ad98a58b3d7a151dca59364b72097b6b875a56f6.tar.gz
git-ad98a58b3d7a151dca59364b72097b6b875a56f6.tar.bz2
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>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/blame.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/builtin/blame.c b/builtin/blame.c
index 8506286..8dca385 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -1371,7 +1371,8 @@ static void get_commit_info(struct commit *commit,
int detailed)
{
int len;
- char *tmp, *endp, *reencoded, *message;
+ const char *subject;
+ char *reencoded, *message;
static char author_name[1024];
static char author_mail[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->summary = summary_buf;
- tmp = strstr(message, "\n\n");
- if (!tmp) {
- error_out:
+ len = find_commit_subject(message, &subject);
+ if (len && len < sizeof(summary_buf)) {
+ memcpy(summary_buf, subject, len);
+ summary_buf[len] = 0;
+ } else {
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;
free(reencoded);
}