From 5faaf24634a4d3a630bd3655cc85fa96f8bc1903 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 14 Feb 2007 13:20:41 -0800 Subject: [PATCH] Make sure packedgitwindowsize is multiple of (pagesize * 2) The next patch depends on this. Signed-off-by: Junio C Hamano --- config.c | 12 +++++++----- git-compat-util.h | 3 +++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/config.c b/config.c index d82107124a..c938aa0b15 100644 --- a/config.c +++ b/config.c @@ -310,12 +310,14 @@ int git_default_config(const char *var, const char *value) } if (!strcmp(var, "core.packedgitwindowsize")) { - int pgsz = getpagesize(); + int pgsz_x2 = getpagesize() * 2; packed_git_window_size = git_config_int(var, value); - packed_git_window_size /= pgsz; - if (packed_git_window_size < 2) - packed_git_window_size = 2; - packed_git_window_size *= pgsz; + + /* This value must be multiple of (pagesize * 2) */ + packed_git_window_size /= pgsz_x2; + if (packed_git_window_size < 1) + packed_git_window_size = 1; + packed_git_window_size *= pgsz_x2; return 0; } diff --git a/git-compat-util.h b/git-compat-util.h index c1bcb001a5..105ac28f97 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -96,11 +96,14 @@ extern void set_warn_routine(void (*routine)(const char *warn, va_list params)); extern void *git_mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset); extern int git_munmap(void *start, size_t length); +/* This value must be multiple of (pagesize * 2) */ #define DEFAULT_PACKED_GIT_WINDOW_SIZE (1 * 1024 * 1024) #else /* NO_MMAP */ #include + +/* This value must be multiple of (pagesize * 2) */ #define DEFAULT_PACKED_GIT_WINDOW_SIZE \ (sizeof(void*) >= 8 \ ? 1 * 1024 * 1024 * 1024 \ -- 2.11.4.GIT