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