Skip to content

Commit 77e0751

Browse files
committed
Merge branch 'ss/receive-pack-parse-options'
The command line argument parser for "receive-pack" has been rewritten to use parse-options. * ss/receive-pack-parse-options: builtin/receive-pack.c: use parse_options API
2 parents 12508a8 + 1b68387 commit 77e0751

File tree

1 file changed

+20
-33
lines changed

1 file changed

+20
-33
lines changed

builtin/receive-pack.c

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@
2121
#include "sigchain.h"
2222
#include "fsck.h"
2323

24-
static const char receive_pack_usage[] = "git receive-pack <git-dir>";
24+
static const char * const receive_pack_usage[] = {
25+
N_("git receive-pack <git-dir>"),
26+
NULL
27+
};
2528

2629
enum deny_action {
2730
DENY_UNCONFIGURED,
@@ -49,7 +52,7 @@ static int quiet;
4952
static int prefer_ofs_delta = 1;
5053
static int auto_update_server_info;
5154
static int auto_gc = 1;
52-
static int fix_thin = 1;
55+
static int reject_thin;
5356
static int stateless_rpc;
5457
static const char *service_dir;
5558
static const char *head_name;
@@ -1548,7 +1551,7 @@ static const char *unpack(int err_fd, struct shallow_info *si)
15481551
if (fsck_objects)
15491552
argv_array_pushf(&child.args, "--strict%s",
15501553
fsck_msg_types.buf);
1551-
if (fix_thin)
1554+
if (!reject_thin)
15521555
argv_array_push(&child.args, "--fix-thin");
15531556
child.out = -1;
15541557
child.err = err_fd;
@@ -1707,45 +1710,29 @@ static int delete_only(struct command *commands)
17071710
int cmd_receive_pack(int argc, const char **argv, const char *prefix)
17081711
{
17091712
int advertise_refs = 0;
1710-
int i;
17111713
struct command *commands;
17121714
struct sha1_array shallow = SHA1_ARRAY_INIT;
17131715
struct sha1_array ref = SHA1_ARRAY_INIT;
17141716
struct shallow_info si;
17151717

1716-
packet_trace_identity("receive-pack");
1718+
struct option options[] = {
1719+
OPT__QUIET(&quiet, N_("quiet")),
1720+
OPT_HIDDEN_BOOL(0, "stateless-rpc", &stateless_rpc, NULL),
1721+
OPT_HIDDEN_BOOL(0, "advertise-refs", &advertise_refs, NULL),
1722+
OPT_HIDDEN_BOOL(0, "reject-thin-pack-for-testing", &reject_thin, NULL),
1723+
OPT_END()
1724+
};
17171725

1718-
argv++;
1719-
for (i = 1; i < argc; i++) {
1720-
const char *arg = *argv++;
1726+
packet_trace_identity("receive-pack");
17211727

1722-
if (*arg == '-') {
1723-
if (!strcmp(arg, "--quiet")) {
1724-
quiet = 1;
1725-
continue;
1726-
}
1728+
argc = parse_options(argc, argv, prefix, options, receive_pack_usage, 0);
17271729

1728-
if (!strcmp(arg, "--advertise-refs")) {
1729-
advertise_refs = 1;
1730-
continue;
1731-
}
1732-
if (!strcmp(arg, "--stateless-rpc")) {
1733-
stateless_rpc = 1;
1734-
continue;
1735-
}
1736-
if (!strcmp(arg, "--reject-thin-pack-for-testing")) {
1737-
fix_thin = 0;
1738-
continue;
1739-
}
1730+
if (argc > 1)
1731+
usage_msg_opt(_("Too many arguments."), receive_pack_usage, options);
1732+
if (argc == 0)
1733+
usage_msg_opt(_("You must specify a directory."), receive_pack_usage, options);
17401734

1741-
usage(receive_pack_usage);
1742-
}
1743-
if (service_dir)
1744-
usage(receive_pack_usage);
1745-
service_dir = arg;
1746-
}
1747-
if (!service_dir)
1748-
usage(receive_pack_usage);
1735+
service_dir = argv[0];
17491736

17501737
setup_path();
17511738

0 commit comments

Comments
 (0)