Use git_bits_left() instead of size_in_bits - get_bits_count().