Commit 858ef372 by Marc Pegon

Changed commit short messages so that they match git log --oneline output.

In git, the short message of a commit is the part of the commit message before 2 consecutive line breaks. In the short message, line breaks are replaced by space characters.
parent 3a12891f
...@@ -292,6 +292,7 @@ int commit_parse_buffer(git_commit *commit, const void *data, size_t len) ...@@ -292,6 +292,7 @@ int commit_parse_buffer(git_commit *commit, const void *data, size_t len)
if (buffer < buffer_end) { if (buffer < buffer_end) {
const char *line_end; const char *line_end;
unsigned int i;
size_t message_len; size_t message_len;
/* Long message */ /* Long message */
...@@ -301,12 +302,18 @@ int commit_parse_buffer(git_commit *commit, const void *data, size_t len) ...@@ -301,12 +302,18 @@ int commit_parse_buffer(git_commit *commit, const void *data, size_t len)
commit->message[message_len] = 0; commit->message[message_len] = 0;
/* Short message */ /* Short message */
if((line_end = memchr(buffer, '\n', buffer_end - buffer)) == NULL) if((line_end = strstr(buffer, "\n\n")) == NULL) {
line_end = buffer_end; /* Cut the last '\n' if there is one */
if (message_len && buffer[message_len - 1] == '\n')
line_end = buffer_end - 1;
else
line_end = buffer_end;
}
message_len = line_end - buffer; message_len = line_end - buffer;
commit->message_short = git__malloc(message_len + 1); commit->message_short = git__malloc(message_len + 1);
memcpy(commit->message_short, buffer, message_len); for (i = 0; i < message_len; ++i) {
commit->message_short[i] = (buffer[i] == '\n') ? ' ' : buffer[i];
}
commit->message_short[message_len] = 0; commit->message_short[message_len] = 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment