382
}
383
384
static int do_push(const char *repo, int flags,
385
- const struct string_list *push_options)
385
+ const struct string_list *push_options,
386
+ struct remote *remote)
387
{
388
int i, errs;
388
- struct remote *remote = pushremote_get(repo);
389
const char **url;
390
int url_nr;
391
struct refspec *push_refspec = &rs;
392
393
- if (!remote) {
394
- if (repo)
395
- die(_("bad repository '%s'"), repo);
396
- die(_("No configured push destination.\n"
397
- "Either specify the URL from the command-line or configure a remote repository using\n"
398
- "\n"
399
- " git remote add <name> <url>\n"
400
- "\n"
401
- "and then push using the remote name\n"
402
- "\n"
403
- " git push <name>\n"));
404
- }
405
-
406
- if (remote->mirror)
407
- flags |= (TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE);
408
-
393
if (push_options->nr)
394
flags |= TRANSPORT_PUSH_OPTIONS;
395
529
struct string_list push_options_cmdline = STRING_LIST_INIT_DUP;
530
struct string_list *push_options;
531
const struct string_list_item *item;
532
+ struct remote *remote;
533
534
struct option options[] = {
535
OPT__VERBOSITY(&verbosity),
584
die(_("--delete is incompatible with --all, --mirror and --tags"));
585
if (deleterefs && argc < 2)
586
die(_("--delete doesn't make sense without any refs"));
602
- if (flags & TRANSPORT_PUSH_ALL) {
603
- if (tags)
604
- die(_("--all and --tags are incompatible"));
605
- if (argc >= 2)
606
- die(_("--all can't be combined with refspecs"));
607
- }
608
- if (flags & TRANSPORT_PUSH_MIRROR) {
609
- if (tags)
610
- die(_("--mirror and --tags are incompatible"));
611
- if (argc >= 2)
612
- die(_("--mirror can't be combined with refspecs"));
613
- }
614
- if ((flags & TRANSPORT_PUSH_ALL) && (flags & TRANSPORT_PUSH_MIRROR))
615
- die(_("--all and --mirror are incompatible"));
587
588
if (recurse_submodules == RECURSE_SUBMODULES_CHECK)
589
flags |= TRANSPORT_RECURSE_SUBMODULES_CHECK;
600
set_refspecs(argv + 1, argc - 1, repo);
601
}
602
603
+ remote = pushremote_get(repo);
604
+ if (!remote) {
605
+ if (repo)
606
+ die(_("bad repository '%s'"), repo);
607
+ die(_("No configured push destination.\n"
608
+ "Either specify the URL from the command-line or configure a remote repository using\n"
609
+ "\n"
610
+ " git remote add <name> <url>\n"
611
+ "\n"
612
+ "and then push using the remote name\n"
613
+ "\n"
614
+ " git push <name>\n"));
615
+ }
616
+
617
+ if (remote->mirror)
618
+ flags |= (TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE);
619
+
620
+ if (flags & TRANSPORT_PUSH_ALL) {
621
+ if (tags)
622
+ die(_("--all and --tags are incompatible"));
623
+ if (argc >= 2)
624
+ die(_("--all can't be combined with refspecs"));
625
+ }
626
+ if (flags & TRANSPORT_PUSH_MIRROR) {
627
+ if (tags)
628
+ die(_("--mirror and --tags are incompatible"));
629
+ if (argc >= 2)
630
+ die(_("--mirror can't be combined with refspecs"));
631
+ }
632
+ if ((flags & TRANSPORT_PUSH_ALL) && (flags & TRANSPORT_PUSH_MIRROR))
633
+ die(_("--all and --mirror are incompatible"));
634
+
635
for_each_string_list_item(item, push_options)
636
if (strchr(item->string, '\n'))
637
die(_("push options must not have new line characters"));
638
636
- rc = do_push(repo, flags, push_options);
639
+ rc = do_push(repo, flags, push_options, remote);
640
string_list_clear(&push_options_cmdline, 0);
641
string_list_clear(&push_options_config, 0);
642
if (rc == -1)