mirror of
https://github.com/git/git.git
synced 2026-01-20 15:39:49 +00:00
Take a hint from commitea68b0ce9f(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 commit9130ac1e19(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>