git-commit-vandalism/refs
Michael Haggerty a8811695e3 read_packed_refs(): make parsing of the header line more robust
The old code parsed the traits in the `packed-refs` header by looking
for the string " trait " (i.e., the name of the trait with a space on
either side) in the header line. This is fragile, because if any other
implementation of Git forgets to write the trailing space, the last
trait would silently be ignored (and the error might never be
noticed).

So instead, use `string_list_split_in_place()` to split the traits
into tokens then use `unsorted_string_list_has_string()` to look for
the tokens we are interested in. This means that we can read the
traits correctly even if the header line is missing a trailing
space (or indeed, if it is missing the space after the colon, or if it
has multiple spaces somewhere).

However, older Git clients (and perhaps other Git implementations)
still require the surrounding spaces, so we still have to output the
header with a trailing space.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-09-14 15:19:07 +09:00
..
files-backend.c ref_iterator: keep track of whether the iterator output is ordered 2017-09-14 15:19:07 +09:00
iterator.c prefix_ref_iterator: break when we leave the prefix 2017-09-14 15:19:07 +09:00
packed-backend.c read_packed_refs(): make parsing of the header line more robust 2017-09-14 15:19:07 +09:00
packed-backend.h packed-backend: rip out some now-unused code 2017-09-09 03:18:04 +09:00
ref-cache.c ref_iterator: keep track of whether the iterator output is ordered 2017-09-14 15:19:07 +09:00
ref-cache.h ref_iterator: keep track of whether the iterator output is ordered 2017-09-14 15:19:07 +09:00
refs-internal.h ref_iterator: keep track of whether the iterator output is ordered 2017-09-14 15:19:07 +09:00