log_ref_write: use strbuf instead of hand-rolled malloc

Besides being fewer lines of code, a strbuf helps in a few
ways:

  1. It makes it much more obvious that the combination of
     malloc with a magic "100" followed by "sprintf" is not
     a buffer overflow (it is not currently, because that
     100 is accounting for 2 sha1s and some whitespace, but
     it takes some careful reading to realize it).

  2. It makes it easier to write the logic of what is
     getting formatted. For example, in the existing code,
     we write a newline after the committer, and then
     sometimes overwrite that newline with the reflog
     message, only to add another newline. This is much
     easier written by adding the newline afterwards.

  3. It makes future patches to tweak the format much
     easier.
log_ref_write: optionally write refname into log

The usual reflog format does not contain the ref name, since
it is implicit in the location of the log. However, ...
read and write everything log