read-cache.c: drop PROT_WRITE from mmap of index
commita1293ef7c3690829a6ac47fc45f3f26b96b5c9f5
authorJeff King <peff@peff.net>
Thu, 28 May 2015 07:54:00 +0000 (28 03:54 -0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 28 May 2015 18:32:04 +0000 (28 11:32 -0700)
treea683cb52e5e6f965b1d8e4142d4af765e310ad3c
parentfdf96a20acf96a6ac538df8113b2aafd6ed71d50
read-cache.c: drop PROT_WRITE from mmap of index

Once upon a time, git's in-memory representation of a cache
entry actually pointed to the mmap'd on-disk data. So in
520fc24 (Allow writing to the private index file mapping.,
2005-04-26), we specified PROT_WRITE so that we could tweak
the entries while we run (in our own MAP_PRIVATE copy-on-write
version, of course).

Later, 7a51ed6 (Make on-disk index representation separate
from in-core one, 2008-01-14) stopped doing this; we copy
the data into our in-core representation, and then drop the
mmap immediately. We can therefore drop the PROT_WRITE flag.
It's probably not hurting anything as it is, but it's
potentially confusing.

Note that we could also mark the mapping as "const" to
verify that we never write to it. However, we don't
typically do that for our other maps, as it then requires
casting to munmap() it.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
read-cache.c