pack-objects: use argv_array

This saves us from having to bump the rp_av count when we add new traversal options. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Oct 16, 2014 at 20:44 UTC edfbb2aa538148b38ee0ba6d62c95b7edda5d817
1 file changed +10 -10
builtin/pack-objects.c
+10 -10
@@ -22,6 +22,7 @@
22 #include "pack-bitmap.h"
23 #include "reachable.h"
24 #include "sha1-array.h"
25 +#include "argv-array.h"
26
27 static const char *pack_usage[] = {
28 N_("git pack-objects --stdout [options...] [< ref-list | < object-list]"),
@@ -2614,8 +2615,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
2615 int use_internal_rev_list = 0;
2616 int thin = 0;
2617 int all_progress_implied = 0;
2617 - const char *rp_av[6];
2618 - int rp_ac = 0;
2618 + struct argv_array rp = ARGV_ARRAY_INIT;
2619 int rev_list_unpacked = 0, rev_list_all = 0, rev_list_reflog = 0;
2620 struct option pack_objects_options[] = {
2621 OPT_SET_INT('q', "quiet", &progress,
@@ -2705,24 +2705,24 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
2705 if (pack_to_stdout != !base_name || argc)
2706 usage_with_options(pack_usage, pack_objects_options);
2707
2708 - rp_av[rp_ac++] = "pack-objects";
2708 + argv_array_push(&rp, "pack-objects");
2709 if (thin) {
2710 use_internal_rev_list = 1;
2711 - rp_av[rp_ac++] = "--objects-edge";
2711 + argv_array_push(&rp, "--objects-edge");
2712 } else
2713 - rp_av[rp_ac++] = "--objects";
2713 + argv_array_push(&rp, "--objects");
2714
2715 if (rev_list_all) {
2716 use_internal_rev_list = 1;
2717 - rp_av[rp_ac++] = "--all";
2717 + argv_array_push(&rp, "--all");
2718 }
2719 if (rev_list_reflog) {
2720 use_internal_rev_list = 1;
2721 - rp_av[rp_ac++] = "--reflog";
2721 + argv_array_push(&rp, "--reflog");
2722 }
2723 if (rev_list_unpacked) {
2724 use_internal_rev_list = 1;
2725 - rp_av[rp_ac++] = "--unpacked";
2725 + argv_array_push(&rp, "--unpacked");
2726 }
2727
2728 if (!reuse_object)
@@ -2766,8 +2766,8 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
2766 if (!use_internal_rev_list)
2767 read_object_list_from_stdin();
2768 else {
2769 - rp_av[rp_ac] = NULL;
2770 - get_object_list(rp_ac, rp_av);
2769 + get_object_list(rp.argc, rp.argv);
2770 + argv_array_clear(&rp);
2771 }
2772 cleanup_preferred_base();
2773 if (include_tag && nr_result)