diff options
author | Junio C Hamano <gitster@pobox.com> | 2010-08-18 12:46:55 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-08-18 12:46:55 -0700 |
commit | 165dc789d5e201a06e0de5a984e4529ae62027fc (patch) | |
tree | ae0b12015f7fabfe34ca73829aa81d2b4522461f /builtin/blame.c | |
parent | 29e1353a7debe4e73cb5d6d2d5a0c4479e9eb768 (diff) | |
parent | ad98a58b3d7a151dca59364b72097b6b875a56f6 (diff) | |
download | git-165dc789d5e201a06e0de5a984e4529ae62027fc.tar.gz |
Merge branch 'cc/find-commit-subject'
* cc/find-commit-subject:
blame: use find_commit_subject() instead of custom code
merge-recursive: use find_commit_subject() instead of custom code
bisect: use find_commit_subject() instead of custom code
revert: rename variables related to subject in get_message()
revert: refactor code to find commit subject in find_commit_subject()
revert: fix off by one read when searching the end of a commit subject
Diffstat (limited to 'builtin/blame.c')
-rw-r--r-- | builtin/blame.c | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/builtin/blame.c b/builtin/blame.c index 01e62fdeb0..437b1a433a 100644 --- a/builtin/blame.c +++ b/builtin/blame.c @@ -1407,7 +1407,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]; @@ -1449,22 +1450,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); } |