mirror of
https://github.com/git/git.git
synced 2025-03-27 20:18:48 +00:00
builtin/receive-pack.c: use parse_options API
Make receive-pack use the parse_options API, bringing it more in line with send-pack and push. Helped-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr> Signed-off-by: Sidhant Sharma [:tk] <tigerkid001@gmail.com> Reviewed-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
f02fbc4f94
commit
1b68387e02
@ -21,7 +21,10 @@
|
|||||||
#include "sigchain.h"
|
#include "sigchain.h"
|
||||||
#include "fsck.h"
|
#include "fsck.h"
|
||||||
|
|
||||||
static const char receive_pack_usage[] = "git receive-pack <git-dir>";
|
static const char * const receive_pack_usage[] = {
|
||||||
|
N_("git receive-pack <git-dir>"),
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
enum deny_action {
|
enum deny_action {
|
||||||
DENY_UNCONFIGURED,
|
DENY_UNCONFIGURED,
|
||||||
@ -49,7 +52,7 @@ static int quiet;
|
|||||||
static int prefer_ofs_delta = 1;
|
static int prefer_ofs_delta = 1;
|
||||||
static int auto_update_server_info;
|
static int auto_update_server_info;
|
||||||
static int auto_gc = 1;
|
static int auto_gc = 1;
|
||||||
static int fix_thin = 1;
|
static int reject_thin;
|
||||||
static int stateless_rpc;
|
static int stateless_rpc;
|
||||||
static const char *service_dir;
|
static const char *service_dir;
|
||||||
static const char *head_name;
|
static const char *head_name;
|
||||||
@ -1548,7 +1551,7 @@ static const char *unpack(int err_fd, struct shallow_info *si)
|
|||||||
if (fsck_objects)
|
if (fsck_objects)
|
||||||
argv_array_pushf(&child.args, "--strict%s",
|
argv_array_pushf(&child.args, "--strict%s",
|
||||||
fsck_msg_types.buf);
|
fsck_msg_types.buf);
|
||||||
if (fix_thin)
|
if (!reject_thin)
|
||||||
argv_array_push(&child.args, "--fix-thin");
|
argv_array_push(&child.args, "--fix-thin");
|
||||||
child.out = -1;
|
child.out = -1;
|
||||||
child.err = err_fd;
|
child.err = err_fd;
|
||||||
@ -1707,45 +1710,29 @@ static int delete_only(struct command *commands)
|
|||||||
int cmd_receive_pack(int argc, const char **argv, const char *prefix)
|
int cmd_receive_pack(int argc, const char **argv, const char *prefix)
|
||||||
{
|
{
|
||||||
int advertise_refs = 0;
|
int advertise_refs = 0;
|
||||||
int i;
|
|
||||||
struct command *commands;
|
struct command *commands;
|
||||||
struct sha1_array shallow = SHA1_ARRAY_INIT;
|
struct sha1_array shallow = SHA1_ARRAY_INIT;
|
||||||
struct sha1_array ref = SHA1_ARRAY_INIT;
|
struct sha1_array ref = SHA1_ARRAY_INIT;
|
||||||
struct shallow_info si;
|
struct shallow_info si;
|
||||||
|
|
||||||
|
struct option options[] = {
|
||||||
|
OPT__QUIET(&quiet, N_("quiet")),
|
||||||
|
OPT_HIDDEN_BOOL(0, "stateless-rpc", &stateless_rpc, NULL),
|
||||||
|
OPT_HIDDEN_BOOL(0, "advertise-refs", &advertise_refs, NULL),
|
||||||
|
OPT_HIDDEN_BOOL(0, "reject-thin-pack-for-testing", &reject_thin, NULL),
|
||||||
|
OPT_END()
|
||||||
|
};
|
||||||
|
|
||||||
packet_trace_identity("receive-pack");
|
packet_trace_identity("receive-pack");
|
||||||
|
|
||||||
argv++;
|
argc = parse_options(argc, argv, prefix, options, receive_pack_usage, 0);
|
||||||
for (i = 1; i < argc; i++) {
|
|
||||||
const char *arg = *argv++;
|
|
||||||
|
|
||||||
if (*arg == '-') {
|
if (argc > 1)
|
||||||
if (!strcmp(arg, "--quiet")) {
|
usage_msg_opt(_("Too many arguments."), receive_pack_usage, options);
|
||||||
quiet = 1;
|
if (argc == 0)
|
||||||
continue;
|
usage_msg_opt(_("You must specify a directory."), receive_pack_usage, options);
|
||||||
}
|
|
||||||
|
|
||||||
if (!strcmp(arg, "--advertise-refs")) {
|
service_dir = argv[0];
|
||||||
advertise_refs = 1;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!strcmp(arg, "--stateless-rpc")) {
|
|
||||||
stateless_rpc = 1;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!strcmp(arg, "--reject-thin-pack-for-testing")) {
|
|
||||||
fix_thin = 0;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
usage(receive_pack_usage);
|
|
||||||
}
|
|
||||||
if (service_dir)
|
|
||||||
usage(receive_pack_usage);
|
|
||||||
service_dir = arg;
|
|
||||||
}
|
|
||||||
if (!service_dir)
|
|
||||||
usage(receive_pack_usage);
|
|
||||||
|
|
||||||
setup_path();
|
setup_path();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user