libgit2/libgit2 — pull request #875 by arrbee (2012-08-14 18:24:51+00:00)
Title: Fix message prettify length check

As an alternative to #869, this updates `git_message_prettify` in two ways:

1. This computes the prettified message **before** checking the length of the output buffer so the length check will be exact instead of roughly right. This means if you have a message with a lot of comments, you won't have to include space for them in the output buffer just to pass the estimated length check.
2. The function now returns the number of bytes that are / would be written to the output buffer. In combination with allowing a NULL output buffer, this means you can use this like `snprintf` to get the necessary buffer size and do an allocation to insure sufficient space. You can, of course, still use the function the old way and you will get a -1 output if there is insufficient space in the output buffer.