gc: use argv-array for sub-commands
commit234587fc87b156dc20461fc61353beeb904b43bc
authorJeff King <peff@peff.net>
Wed, 18 Apr 2012 21:10:19 +0000 (18 14:10 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 18 Apr 2012 23:17:42 +0000 (18 16:17 -0700)
tree698f4806c37f7117e9cc2ef86c5fe35bd8e98c62
parentd15bbe1379a12e2d9a5f18f7dc96b38afafc6c5d
gc: use argv-array for sub-commands

git-gc executes many sub-commands. The argument list for
some of these is constant, but for others we add more
arguments at runtime. The latter is implemented by allocating
a constant extra number of NULLs, and either using a custom
append function, or just referencing unused slots by number.

As of commit 7e52f56, which added two new arguments, it is
possible to exceed the constant number of slots for "repack"
by running "git gc --aggressive", causing "git gc" to die.

This patch converts all of the static argv lists to use
argv-array. In addition to fixing the overflow caused by
7e52f56, it has a few advantages:

  1. We can drop the custom append function (which,
     incidentally, had an off-by-one error exacerbating the
     static limit).

  2. We can drop the ugly magic numbers used when adding
     arguments to "prune".

  3. Adding further arguments will be easier; you can just
     add new "push" calls without worrying about increasing
     any static limits.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/gc.c