This seems like it would end up consuming the separator between the headers and commit (message) body, causing the `buf = readline().strip()` at the end of the `while` to consume an extra line and potentially the entire commit message.  I think `buf` could be reused in the inner `while True` loop.