Skip to content

Commit edfbb2a

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1be111d commit edfbb2a

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

builtin/pack-objects.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "pack-bitmap.h"
2323
#include "reachable.h"
2424
#include "sha1-array.h"
25+
#include "argv-array.h"
2526

2627
static const char *pack_usage[] = {
2728
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)
26142615
int use_internal_rev_list = 0;
26152616
int thin = 0;
26162617
int all_progress_implied = 0;
2617-
const char *rp_av[6];
2618-
int rp_ac = 0;
2618+
struct argv_array rp = ARGV_ARRAY_INIT;
26192619
int rev_list_unpacked = 0, rev_list_all = 0, rev_list_reflog = 0;
26202620
struct option pack_objects_options[] = {
26212621
OPT_SET_INT('q', "quiet", &progress,
@@ -2705,24 +2705,24 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
27052705
if (pack_to_stdout != !base_name || argc)
27062706
usage_with_options(pack_usage, pack_objects_options);
27072707

2708-
rp_av[rp_ac++] = "pack-objects";
2708+
argv_array_push(&rp, "pack-objects");
27092709
if (thin) {
27102710
use_internal_rev_list = 1;
2711-
rp_av[rp_ac++] = "--objects-edge";
2711+
argv_array_push(&rp, "--objects-edge");
27122712
} else
2713-
rp_av[rp_ac++] = "--objects";
2713+
argv_array_push(&rp, "--objects");
27142714

27152715
if (rev_list_all) {
27162716
use_internal_rev_list = 1;
2717-
rp_av[rp_ac++] = "--all";
2717+
argv_array_push(&rp, "--all");
27182718
}
27192719
if (rev_list_reflog) {
27202720
use_internal_rev_list = 1;
2721-
rp_av[rp_ac++] = "--reflog";
2721+
argv_array_push(&rp, "--reflog");
27222722
}
27232723
if (rev_list_unpacked) {
27242724
use_internal_rev_list = 1;
2725-
rp_av[rp_ac++] = "--unpacked";
2725+
argv_array_push(&rp, "--unpacked");
27262726
}
27272727

27282728
if (!reuse_object)
@@ -2766,8 +2766,8 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
27662766
if (!use_internal_rev_list)
27672767
read_object_list_from_stdin();
27682768
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);
27712771
}
27722772
cleanup_preferred_base();
27732773
if (include_tag && nr_result)

0 commit comments

Comments
 (0)