Fix git_config_get_multivar with interleaved missing entries

This contains the changes in #1712 plus more tests to exercise the previously failing scenario, plus a little code cleanup.