Merge branch 'sp/stream-clean-filter'
authorJunio C Hamano <gitster@pobox.com>
Wed, 8 Oct 2014 20:05:32 +0000 (13:05 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 8 Oct 2014 20:05:32 +0000 (13:05 -0700)
When running a required clean filter, we do not have to mmap the
original before feeding the filter. Instead, stream the file
contents directly to the filter and process its output.

* sp/stream-clean-filter:
sha1_file: don't convert off_t to size_t too early to avoid potential die()
convert: stream from fd to required clean filter to reduce used address space
copy_fd(): do not close the input file descriptor
mmap_limit: introduce GIT_MMAP_LIMIT to allow testing expected mmap size
memory_limit: use git_env_ulong() to parse GIT_ALLOC_LIMIT
config.c: add git_env_ulong() to parse environment variable
convert: drop arguments other than 'path' from would_convert_to_git()

1  2 
cache.h
config.c
convert.c
lockfile.c
sha1_file.c
t/t1050-large.sh
wrapper.c
diff --cc cache.h
Simple merge
diff --cc config.c
Simple merge
diff --cc convert.c
Simple merge
diff --cc lockfile.c
Simple merge
diff --cc sha1_file.c
Simple merge
Simple merge
diff --cc wrapper.c
index 25074d71b6ce72066efc02abda74ddfb10f71d6c,c5204f7a07bd011df913c888475746834df79d7d..5b77d2a1aecd494ea4bb5eb1e6f31afc9c96f82e
+++ b/wrapper.c
@@@ -9,23 -9,17 +9,24 @@@ static void do_nothing(size_t size
  
  static void (*try_to_free_routine)(size_t size) = do_nothing;
  
 -static void memory_limit_check(size_t size)
 +static int memory_limit_check(size_t size, int gentle)
  {
-       static int limit = -1;
-       if (limit == -1) {
-               const char *env = getenv("GIT_ALLOC_LIMIT");
-               limit = env ? atoi(env) * 1024 : 0;
+       static size_t limit = 0;
+       if (!limit) {
+               limit = git_env_ulong("GIT_ALLOC_LIMIT", 0);
+               if (!limit)
+                       limit = SIZE_MAX;
        }
-       if (limit && size > limit) {
 -      if (size > limit)
 -              die("attempting to allocate %"PRIuMAX" over limit %"PRIuMAX,
 -                  (uintmax_t)size, (uintmax_t)limit);
++      if (size > limit) {
 +              if (gentle) {
-                       error("attempting to allocate %"PRIuMAX" over limit %d",
-                             (intmax_t)size, limit);
++                      error("attempting to allocate %"PRIuMAX" over limit %"PRIuMAX,
++                            (uintmax_t)size, (uintmax_t)limit);
 +                      return -1;
 +              } else
-                       die("attempting to allocate %"PRIuMAX" over limit %d",
-                           (intmax_t)size, limit);
++                      die("attempting to allocate %"PRIuMAX" over limit %"PRIuMAX,
++                          (uintmax_t)size, (uintmax_t)limit);
 +      }
 +      return 0;
  }
  
  try_to_free_t set_try_to_free_routine(try_to_free_t routine)