@@ -29,7 +29,7 @@ void git_commit__free(void *_commit)
2929 git_signature_free (commit -> committer );
3030
3131 git__free (commit -> raw_header );
32- git__free (commit -> message );
32+ git__free (commit -> raw_message );
3333 git__free (commit -> message_encoding );
3434
3535 git__free (commit );
@@ -240,13 +240,13 @@ int git_commit__parse(void *_commit, git_odb_object *odb_obj)
240240 buffer_end = buffer + git_odb_object_size (odb_obj );
241241
242242 buffer += header_len ;
243- while ( buffer < buffer_end && * buffer == '\n' )
243+ if ( * buffer == '\n' )
244244 ++ buffer ;
245245
246246 /* extract commit message */
247247 if (buffer <= buffer_end ) {
248- commit -> message = git__strndup (buffer , buffer_end - buffer );
249- GITERR_CHECK_ALLOC (commit -> message );
248+ commit -> raw_message = git__strndup (buffer , buffer_end - buffer );
249+ GITERR_CHECK_ALLOC (commit -> raw_message );
250250 }
251251
252252 return 0 ;
@@ -265,14 +265,27 @@ int git_commit__parse(void *_commit, git_odb_object *odb_obj)
265265
266266GIT_COMMIT_GETTER (const git_signature * , author , commit -> author )
267267GIT_COMMIT_GETTER (const git_signature * , committer , commit -> committer )
268- GIT_COMMIT_GETTER (const char * , message , commit - > message )
268+ GIT_COMMIT_GETTER (const char * , message_raw , commit - > raw_message )
269269GIT_COMMIT_GETTER (const char * , message_encoding , commit - > message_encoding )
270270GIT_COMMIT_GETTER (const char * , raw_header , commit - > raw_header )
271271GIT_COMMIT_GETTER (git_time_t , time , commit - > committer - > when .time )
272272GIT_COMMIT_GETTER (int , time_offset , commit - > committer - > when .offset )
273273GIT_COMMIT_GETTER (unsigned int , parentcount , (unsigned int )git_array_size (commit - > parent_ids ))
274274GIT_COMMIT_GETTER (const git_oid * , tree_id , & commit -> tree_id );
275275
276+ const char * git_commit_message (const git_commit * commit )
277+ {
278+ const char * message = commit -> raw_message ;
279+
280+ assert (commit );
281+
282+ /* trim leading newlines from raw message */
283+ while (* message && * message == '\n' )
284+ ++ message ;
285+
286+ return message ;
287+ }
288+
276289int git_commit_tree (git_tree * * tree_out , const git_commit * commit )
277290{
278291 assert (commit );
0 commit comments