convert: drop arguments other than 'path' from would_convert_to_git()

It is only the path that matters in the decision whether to filter
or not.  Clarify this by making path the only argument of
would_convert_to_git().

Signed-off-by: Steffen Prohaska <prohaska@zib.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sha1_file.c: introduce GIT_MMAP_LIMIT to limit mmap size

Similar to testing expectations about malloc with GIT_ALLOC_LIMIT
introduced in d41489a6 (Add more large blob test cases, 2012-03-07),
it can be useful to test expectations about mmap.

Introduce a new environment variable GIT_MMAP_LIMIT to limit the
largest allowed mmap length (in KB).  xmmap() is modified to check
the limit.  Together with GIT_ALLOC_LIMIT tests can now easily
confirm expectations about memory consumption.

GIT_MMAP_LIMIT will be used in the next commit to test that data
will be streamed to an external filter without mmaping the entire
file.

Signed-off-by: Steffen Prohaska <prohaska@zib.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
memory_limit_check(): allow a limit that does not fit in "int"

GIT_ALLOC_LIMIT limits xmalloc()'s size, which is of type size_t.
Use ssize_t to store the limit, not "int" which may be smaller.  The
change has no direct practical impact, because we use it primarily
to test small sizes.

The cast of size in the call to die() is changed to uintmax_t to
match the format string PRIuMAX.

Signed-off-by: Steffen Prohaska <prohaska@zib.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
convert: stream from fd to required clean filter instead of mmap

The data is streamed to the filter process anyway.  Better avoid
mapping the file if possible.  This is especially useful if a clean
filter reduces the size, for example if it computes a sha1 for
binary data, like git media.  The file size that the previous
implementation could handle was limited by the available address
space; large files for example could not be handled with (32-bit)
msysgit.  The new implementation can filter files of any size as
long as the filter output is small enough.

The new code path is only taken if the filter is required.  The
filter consumes data directly from the fd.  The original data is not
available to git, so it must fail if the filter fails.

The environment variable GIT_MMAP_LIMIT is used to test that the
expected code path is taken.  A related test that exercises required
filters is modified to verify that the data actually has been
modified on its way from the file system to the object store.

Signed-off-by: Steffen Prohaska <prohaska@zib.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
upload-pack: keep poll(2)'s timeout to -1

Keep poll's timeout at -1 when uploadpack.keepalive = 0, instead of
setting it to -1000, since some pedantic old systems (eg HP-UX) and
the gnulib compat/poll will treat only -1 as the valid value for
an infinite timeout.

Signed-off-by: Edward Thomson <ethomson@microsoft.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Merge branch 'et/spell-poll-infinite-with-minus-one-only' into jch

* et/spell-poll-infinite-with-minus-one-only:
  upload-pack: keep poll(2)'s timeout to -1
Merge branch 'sp/stream-clean-filter' into jch

* sp/stream-clean-filter:
  convert: stream from fd to required clean filter instead of mmap
  memory_limit_check(): allow a limit that does not fit in "int"
  sha1_file.c: introduce GIT_MMAP_LIMIT to limit mmap size
  convert: drop arguments other than 'path' from would_convert_to_git()