@@ -353,7 +353,8 @@ static int push_with_options(struct transport *transport, int flags)
353353 return 1 ;
354354}
355355
356- static int do_push (const char * repo , int flags )
356+ static int do_push (const char * repo , int flags ,
357+ const struct string_list * push_options )
357358{
358359 int i , errs ;
359360 struct remote * remote = pushremote_get (repo );
@@ -376,6 +377,9 @@ static int do_push(const char *repo, int flags)
376377 if (remote -> mirror )
377378 flags |= (TRANSPORT_PUSH_MIRROR |TRANSPORT_PUSH_FORCE );
378379
380+ if (push_options -> nr )
381+ flags |= TRANSPORT_PUSH_OPTIONS ;
382+
379383 if ((flags & TRANSPORT_PUSH_ALL ) && refspec ) {
380384 if (!strcmp (* refspec , "refs/tags/*" ))
381385 return error (_ ("--all and --tags are incompatible" ));
@@ -406,13 +410,16 @@ static int do_push(const char *repo, int flags)
406410 for (i = 0 ; i < url_nr ; i ++ ) {
407411 struct transport * transport =
408412 transport_get (remote , url [i ]);
413+ if (flags & TRANSPORT_PUSH_OPTIONS )
414+ transport -> push_options = push_options ;
409415 if (push_with_options (transport , flags ))
410416 errs ++ ;
411417 }
412418 } else {
413419 struct transport * transport =
414420 transport_get (remote , NULL );
415-
421+ if (flags & TRANSPORT_PUSH_OPTIONS )
422+ transport -> push_options = push_options ;
416423 if (push_with_options (transport , flags ))
417424 errs ++ ;
418425 }
@@ -500,6 +507,9 @@ int cmd_push(int argc, const char **argv, const char *prefix)
500507 int push_cert = -1 ;
501508 int rc ;
502509 const char * repo = NULL ; /* default repository */
510+ static struct string_list push_options = STRING_LIST_INIT_DUP ;
511+ static struct string_list_item * item ;
512+
503513 struct option options [] = {
504514 OPT__VERBOSITY (& verbosity ),
505515 OPT_STRING ( 0 , "repo" , & repo , N_ ("repository" ), N_ ("repository" )),
@@ -533,6 +543,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
533543 0 , "signed" , & push_cert , "yes|no|if-asked" , N_ ("GPG sign the push" ),
534544 PARSE_OPT_OPTARG , option_parse_push_signed },
535545 OPT_BIT (0 , "atomic" , & flags , N_ ("request atomic transaction on remote side" ), TRANSPORT_PUSH_ATOMIC ),
546+ OPT_STRING_LIST ('o' , "push-option" , & push_options , N_ ("server-specific" ), N_ ("option to transmit" )),
536547 OPT_SET_INT ('4' , "ipv4" , & family , N_ ("use IPv4 addresses only" ),
537548 TRANSPORT_FAMILY_IPV4 ),
538549 OPT_SET_INT ('6' , "ipv6" , & family , N_ ("use IPv6 addresses only" ),
@@ -563,7 +574,11 @@ int cmd_push(int argc, const char **argv, const char *prefix)
563574 set_refspecs (argv + 1 , argc - 1 , repo );
564575 }
565576
566- rc = do_push (repo , flags );
577+ for_each_string_list_item (item , & push_options )
578+ if (strchr (item -> string , '\n' ))
579+ die (_ ("push options must not have new line characters" ));
580+
581+ rc = do_push (repo , flags , & push_options );
567582 if (rc == -1 )
568583 usage_with_options (push_usage , options );
569584 else
0 commit comments