cat-file: add --buffer option
commitfc4937c37219347f4e2c25a271577b333942453f
authorJeff King <peff@peff.net>
Mon, 22 Jun 2015 10:45:17 +0000 (22 06:45 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 22 Jun 2015 21:55:52 +0000 (22 14:55 -0700)
treec62993cbd67f3ec4e766e7cd470e9cfb28d436dc
parentbfd155943eecedb7b7e759ff022ca09e68f941b0
cat-file: add --buffer option

We use a direct write() to output the results of --batch and
--batch-check. This is good for processes feeding the input
and reading the output interactively, but it introduces
measurable overhead if you do not want this feature. For
example, on linux.git:

  $ git rev-list --objects --all | cut -d' ' -f1 >objects
  $ time git cat-file --batch-check='%(objectsize)' \
          <objects >/dev/null
  real    0m5.440s
  user    0m5.060s
  sys     0m0.384s

This patch adds an option to use regular stdio buffering:

  $ time git cat-file --batch-check='%(objectsize)' \
          --buffer <objects >/dev/null
  real    0m4.975s
  user    0m4.888s
  sys     0m0.092s

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-cat-file.txt
builtin/cat-file.c