builtin-push.c: Cleanup - use OPT_BIT() and remove some variables
Signed-off-by: Michele Ballabio <barra_cuda@katamail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
74f5b7fba4
commit
c29c1b406e
@ -14,7 +14,7 @@ static const char * const push_usage[] = {
|
|||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int thin, verbose;
|
static int thin;
|
||||||
static const char *receivepack;
|
static const char *receivepack;
|
||||||
|
|
||||||
static const char **refspec;
|
static const char **refspec;
|
||||||
@ -84,7 +84,7 @@ static int do_push(const char *repo, int flags)
|
|||||||
if (thin)
|
if (thin)
|
||||||
transport_set_option(transport, TRANS_OPT_THIN, "yes");
|
transport_set_option(transport, TRANS_OPT_THIN, "yes");
|
||||||
|
|
||||||
if (verbose)
|
if (flags & TRANSPORT_PUSH_VERBOSE)
|
||||||
fprintf(stderr, "Pushing to %s\n", remote->url[i]);
|
fprintf(stderr, "Pushing to %s\n", remote->url[i]);
|
||||||
err = transport_push(transport, refspec_nr, refspec, flags);
|
err = transport_push(transport, refspec_nr, refspec, flags);
|
||||||
err |= transport_disconnect(transport);
|
err |= transport_disconnect(transport);
|
||||||
@ -101,22 +101,19 @@ static int do_push(const char *repo, int flags)
|
|||||||
int cmd_push(int argc, const char **argv, const char *prefix)
|
int cmd_push(int argc, const char **argv, const char *prefix)
|
||||||
{
|
{
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
int all = 0;
|
|
||||||
int mirror = 0;
|
|
||||||
int dry_run = 0;
|
|
||||||
int force = 0;
|
|
||||||
int tags = 0;
|
int tags = 0;
|
||||||
int rc;
|
int rc;
|
||||||
const char *repo = NULL; /* default repository */
|
const char *repo = NULL; /* default repository */
|
||||||
|
|
||||||
struct option options[] = {
|
struct option options[] = {
|
||||||
OPT__VERBOSE(&verbose),
|
OPT_BIT('v', "verbose", &flags, "be verbose", TRANSPORT_PUSH_VERBOSE),
|
||||||
OPT_STRING( 0 , "repo", &repo, "repository", "repository"),
|
OPT_STRING( 0 , "repo", &repo, "repository", "repository"),
|
||||||
OPT_BOOLEAN( 0 , "all", &all, "push all refs"),
|
OPT_BIT( 0 , "all", &flags, "push all refs", TRANSPORT_PUSH_ALL),
|
||||||
OPT_BOOLEAN( 0 , "mirror", &mirror, "mirror all refs"),
|
OPT_BIT( 0 , "mirror", &flags, "mirror all refs",
|
||||||
|
(TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE)),
|
||||||
OPT_BOOLEAN( 0 , "tags", &tags, "push tags"),
|
OPT_BOOLEAN( 0 , "tags", &tags, "push tags"),
|
||||||
OPT_BOOLEAN( 0 , "dry-run", &dry_run, "dry run"),
|
OPT_BIT( 0 , "dry-run", &flags, "dry run", TRANSPORT_PUSH_DRY_RUN),
|
||||||
OPT_BOOLEAN('f', "force", &force, "force updates"),
|
OPT_BIT('f', "force", &flags, "force updates", TRANSPORT_PUSH_FORCE),
|
||||||
OPT_BOOLEAN( 0 , "thin", &thin, "use thin pack"),
|
OPT_BOOLEAN( 0 , "thin", &thin, "use thin pack"),
|
||||||
OPT_STRING( 0 , "receive-pack", &receivepack, "receive-pack", "receive pack program"),
|
OPT_STRING( 0 , "receive-pack", &receivepack, "receive-pack", "receive pack program"),
|
||||||
OPT_STRING( 0 , "exec", &receivepack, "receive-pack", "receive pack program"),
|
OPT_STRING( 0 , "exec", &receivepack, "receive-pack", "receive pack program"),
|
||||||
@ -125,18 +122,8 @@ int cmd_push(int argc, const char **argv, const char *prefix)
|
|||||||
|
|
||||||
argc = parse_options(argc, argv, options, push_usage, 0);
|
argc = parse_options(argc, argv, options, push_usage, 0);
|
||||||
|
|
||||||
if (force)
|
|
||||||
flags |= TRANSPORT_PUSH_FORCE;
|
|
||||||
if (dry_run)
|
|
||||||
flags |= TRANSPORT_PUSH_DRY_RUN;
|
|
||||||
if (verbose)
|
|
||||||
flags |= TRANSPORT_PUSH_VERBOSE;
|
|
||||||
if (tags)
|
if (tags)
|
||||||
add_refspec("refs/tags/*");
|
add_refspec("refs/tags/*");
|
||||||
if (all)
|
|
||||||
flags |= TRANSPORT_PUSH_ALL;
|
|
||||||
if (mirror)
|
|
||||||
flags |= (TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE);
|
|
||||||
|
|
||||||
if (argc > 0) {
|
if (argc > 0) {
|
||||||
repo = argv[0];
|
repo = argv[0];
|
||||||
|
Loading…
Reference in New Issue
Block a user