git/refs
Michael Haggerty 01caf20d57 load_contents(): don't try to mmap an empty file
We don't actually create zero-length `packed-refs` files, but they are
valid and we should handle them correctly. The old code `xmmap()`ed
such files, which led to an error when `munmap()` was called. So, if
the `packed-refs` file is empty, leave the snapshot at its zero values
and return 0 without trying to read or mmap the file.

Returning 0 also makes `create_snapshot()` exit early, which avoids
the technically undefined comparison `NULL < NULL`.

Reported-by: Kim Gybels <kgybels@infogroep.be>
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-01-24 12:55:26 -08:00
..
files-backend.c Merge branch 'mh/avoid-rewriting-packed-refs' into maint 2017-12-06 09:08:50 -08:00
iterator.c prefix_ref_iterator: break when we leave the prefix 2017-09-14 15:19:07 +09:00
packed-backend.c load_contents(): don't try to mmap an empty file 2018-01-24 12:55:26 -08:00
packed-backend.h files-backend: don't rewrite the packed-refs file unnecessarily 2017-10-30 09:45:15 +09:00
ref-cache.c ref_cache: remove support for storing peeled values 2017-09-25 18:02:46 +09:00
ref-cache.h ref_cache: remove support for storing peeled values 2017-09-25 18:02:46 +09:00
refs-internal.h Merge branch 'mh/mmap-packed-refs' 2017-10-03 15:42:50 +09:00