• Johannes Sixt's avatar
    rerere forget: do not segfault if not all stages are present · b9e31f59
    Johannes Sixt authored
    The loop that fills in the buffers that are later passed to the merge
    driver exits early when not all stages of a path are present in the index.
    But since the buffer pointers are not initialized in advance, the
    subsequent accesses are undefined.
    Initialize buffer pointers in advance to avoid undefined behavior later.
    That is not sufficient, though, to get correct operation of handle_cache().
    The function replays a conflicted merge to extract the part inside the
    conflict markers. As written, the loop exits early when a stage is missing.
    Consequently, the buffers for later stages that would be present in the
    index are not filled in and the merge is replayed with incomplete data.
    Fix it by investigating all stages of the given path.
    Signed-off-by: default avatarJohannes Sixt <j6t@kdbg.org>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
t2030-unresolve-info.sh 4.98 KB