summaryrefslogtreecommitdiff
path: root/read-cache.c
diff options
context:
space:
mode:
authorLuiz Fernando N. Capitulino <lcapitulino@mandriva.com.br>2007-04-25 11:18:17 -0300
committerJunio C Hamano <junkio@cox.net>2007-04-25 13:44:27 -0700
commit3511a3774e60783d979ebc2ef7b04371a23602bb (patch)
treed84f54426e8e84bfa56df3a3b6120717b2a99ccb /read-cache.c
parentefbc5831264fbe3696e6fc264bba9319265d7344 (diff)
downloadgit-3511a3774e60783d979ebc2ef7b04371a23602bb.tar.gz
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 <lcapitulino@mandriva.com.br> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'read-cache.c')
-rw-r--r--read-cache.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/read-cache.c b/read-cache.c
index e04e99112d..d9f46da5cc 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;