Avoid double lookups of commits during walking operations.

Fix a performance regression since the grafts code.
Pass chunks rather than full text to _parse_commit_or_tag.
Simplify handling of message-like objects.
Move commit parsing into a separate function.