@@ -117,6 +117,37 @@ func TestCommitDecodingWithEmptyName(t *testing.T) {
117117 assert .Equal (t , "initial commit" , commit .Message )
118118}
119119
120+ func TestCommitDecodingWithLargeCommitMessage (t * testing.T ) {
121+ message := "This message text is, with newline, exactly 64 characters long. " ;
122+ // This message will be exactly 1 MiB in size when part of the commit.
123+ longMessage := strings .Repeat (message , (1024 * 1024 / 64 ) - 1 )
124+ longMessage += strings .TrimSpace (message );
125+
126+ author := & Signature {Name : "" , Email : "john@example.com" , When : time .Now ()}
127+ committer := & Signature {Name : "" , Email : "jane@example.com" , When : time .Now ()}
128+
129+ treeId := []byte ("cccccccccccccccccccc" )
130+
131+ from := new (bytes.Buffer )
132+
133+ fmt .Fprintf (from , "author %s\n " , author )
134+ fmt .Fprintf (from , "committer %s\n " , committer )
135+ fmt .Fprintf (from , "tree %s\n " , hex .EncodeToString (treeId ))
136+ fmt .Fprintf (from , "\n %s\n " , longMessage )
137+
138+ flen := from .Len ()
139+
140+ commit := new (Commit )
141+ n , err := commit .Decode (from , int64 (flen ))
142+
143+ assert .Nil (t , err )
144+ assert .Equal (t , flen , n )
145+
146+ assert .Equal (t , author .String (), commit .Author )
147+ assert .Equal (t , committer .String (), commit .Committer )
148+ assert .Equal (t , longMessage , commit .Message )
149+ }
150+
120151func TestCommitDecodingWithMessageKeywordPrefix (t * testing.T ) {
121152 author := & Signature {Name : "John Doe" , Email : "john@example.com" , When : time .Now ()}
122153 committer := & Signature {Name : "Jane Doe" , Email : "jane@example.com" , When : time .Now ()}
0 commit comments