Files
git/refs
Kim Gybels 4aaca6ca82 packed_ref_cache: don't use mmap() for small files
Take a hint from commit ea68b0ce9f (hash-object: don't use mmap() for
small files, 2010-02-21) and use read() instead of mmap() for small
packed-refs files.

This also fixes https://github.com/git-for-windows/git/issues/1410
(where xmmap() returns NULL for zero length[1], for which munmap() later
fails).

Alternatively, we could simply check for NULL before munmap(), or
introduce xmunmap() that could be used together with xmmap(). However,
always setting snapshot->buf to a valid pointer, by relying on
xmalloc(0)'s fallback to 1-byte allocation, makes using snapshots
easier.

[1] Logic introduced in commit 9130ac1e19 (Better error messages for
    corrupt databases, 2007-01-11)

This was cherry-picked from upstream's `pu` branch so that the fix is
included in Git for Windows v2.16.0.

Signed-off-by: Kim Gybels <kgybels@infogroep.be>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-03-23 14:00:58 +01:00
..