receive-pack: print --pack-header directly into argv array
commit446d5d911214fd3d61921478c98d4a88f84e410c
authorJeff King <peff@peff.net>
Tue, 28 Mar 2017 19:46:47 +0000 (28 15:46 -0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 30 Mar 2017 21:59:50 +0000 (30 14:59 -0700)
treeaba115ccfcf2e205ffbd5420abb02dbdf8c971e6
parent903fc7da44b091a87c4bc00a892930786c71a709
receive-pack: print --pack-header directly into argv array

After receive-pack reads the pack header from the client, it
feeds the already-read part to index-pack and unpack-objects
via their --pack-header command-line options.  To do so, we
format it into a fixed buffer, then duplicate it into the
child's argv_array.

Our buffer is long enough to handle any possible input, so
this isn't wrong. But it's more complicated than it needs to
be; we can just argv_array_pushf() the final value and avoid
the intermediate copy. This drops the magic number and is
more efficient, too.

Note that we need to push to the argv_array in order, which
means we can't do the push until we are in the "unpack-objects
versus index-pack" conditional.  Rather than duplicate the
slightly complicated format specifier, I pushed it into a
helper function.

Signed-off-by: Jeff King <peff@peff.net>
builtin/receive-pack.c