• J
    gc: use argv-array for sub-commands · 234587fc
    Jeff King 提交于
    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 7e52f566, 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
    7e52f566, 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: NJeff King <peff@peff.net>
    Signed-off-by: NJunio C Hamano <gitster@pobox.com>
    234587fc
gc.c 6.4 KB