From: Luiz Fernando N. Capitulino Date: Wed, 25 Apr 2007 14:18:17 +0000 (-0300) Subject: read_cache_from(): small simplification X-Git-Tag: v1.5.2-rc1~26 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=3511a3774e60783d979ebc2ef7b04371a23602bb;p=git.git read_cache_from(): small simplification This change 'opens' the code block which maps the index file into memory, making the code clearer and easier to read. Signed-off-by: Luiz Fernando N. Capitulino Signed-off-by: Junio C Hamano --- diff --git a/read-cache.c b/read-cache.c index e04e99112..d9f46da5c 100644 --- a/read-cache.c +++ b/read-cache.c @@ -864,16 +864,15 @@ int read_index_from(struct index_state *istate, const char *path) die("index file open failed (%s)", strerror(errno)); } - if (!fstat(fd, &st)) { - istate->mmap_size = xsize_t(st.st_size); - errno = EINVAL; - if (istate->mmap_size >= sizeof(struct cache_header) + 20) - istate->mmap = xmmap(NULL, istate->mmap_size, - PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); - else - die("index file smaller than expected"); - } else + if (fstat(fd, &st)) die("cannot stat the open index (%s)", strerror(errno)); + + errno = EINVAL; + istate->mmap_size = xsize_t(st.st_size); + if (istate->mmap_size < sizeof(struct cache_header) + 20) + die("index file smaller than expected"); + + istate->mmap = xmmap(NULL, istate->mmap_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); close(fd); hdr = istate->mmap;