push: return immediately in trivial switch case
[git/debian.git] / builtin / push.c
blob0aa1d0f07de51f63c59adb50969bab2d048af111
1 /*
2 * "git push"
3 */
4 #include "cache.h"
5 #include "config.h"
6 #include "refs.h"
7 #include "refspec.h"
8 #include "run-command.h"
9 #include "builtin.h"
10 #include "remote.h"
11 #include "transport.h"
12 #include "parse-options.h"
13 #include "submodule.h"
14 #include "submodule-config.h"
15 #include "send-pack.h"
16 #include "color.h"
18 static const char * const push_usage[] = {
19 N_("git push [<options>] [<repository> [<refspec>...]]"),
20 NULL,
23 static int push_use_color = -1;
24 static char push_colors[][COLOR_MAXLEN] = {
25 GIT_COLOR_RESET,
26 GIT_COLOR_RED, /* ERROR */
29 enum color_push {
30 PUSH_COLOR_RESET = 0,
31 PUSH_COLOR_ERROR = 1
34 static int parse_push_color_slot(const char *slot)
36 if (!strcasecmp(slot, "reset"))
37 return PUSH_COLOR_RESET;
38 if (!strcasecmp(slot, "error"))
39 return PUSH_COLOR_ERROR;
40 return -1;
43 static const char *push_get_color(enum color_push ix)
45 if (want_color_stderr(push_use_color))
46 return push_colors[ix];
47 return "";
50 static int thin = 1;
51 static int deleterefs;
52 static const char *receivepack;
53 static int verbosity;
54 static int progress = -1;
55 static int recurse_submodules = RECURSE_SUBMODULES_DEFAULT;
56 static enum transport_family family;
58 static struct push_cas_option cas;
60 static struct refspec rs = REFSPEC_INIT_PUSH;
62 static struct string_list push_options_config = STRING_LIST_INIT_DUP;
64 static void refspec_append_mapped(struct refspec *refspec, const char *ref,
65 struct remote *remote, struct ref *local_refs)
67 const char *branch_name;
68 struct ref *matched = NULL;
70 /* Does "ref" uniquely name our ref? */
71 if (count_refspec_match(ref, local_refs, &matched) != 1) {
72 refspec_append(refspec, ref);
73 return;
76 if (remote->push.nr) {
77 struct refspec_item query;
78 memset(&query, 0, sizeof(struct refspec_item));
79 query.src = matched->name;
80 if (!query_refspecs(&remote->push, &query) && query.dst) {
81 refspec_appendf(refspec, "%s%s:%s",
82 query.force ? "+" : "",
83 query.src, query.dst);
84 return;
88 if (push_default == PUSH_DEFAULT_UPSTREAM &&
89 skip_prefix(matched->name, "refs/heads/", &branch_name)) {
90 struct branch *branch = branch_get(branch_name);
91 if (branch->merge_nr == 1 && branch->merge[0]->src) {
92 refspec_appendf(refspec, "%s:%s",
93 ref, branch->merge[0]->src);
94 return;
98 refspec_append(refspec, ref);
101 static void set_refspecs(const char **refs, int nr, const char *repo)
103 struct remote *remote = NULL;
104 struct ref *local_refs = NULL;
105 int i;
107 for (i = 0; i < nr; i++) {
108 const char *ref = refs[i];
109 if (!strcmp("tag", ref)) {
110 if (nr <= ++i)
111 die(_("tag shorthand without <tag>"));
112 ref = refs[i];
113 if (deleterefs)
114 refspec_appendf(&rs, ":refs/tags/%s", ref);
115 else
116 refspec_appendf(&rs, "refs/tags/%s", ref);
117 } else if (deleterefs) {
118 if (strchr(ref, ':') || !*ref)
119 die(_("--delete only accepts plain target ref names"));
120 refspec_appendf(&rs, ":%s", ref);
121 } else if (!strchr(ref, ':')) {
122 if (!remote) {
123 /* lazily grab remote and local_refs */
124 remote = remote_get(repo);
125 local_refs = get_local_heads();
127 refspec_append_mapped(&rs, ref, remote, local_refs);
128 } else
129 refspec_append(&rs, ref);
133 static int push_url_of_remote(struct remote *remote, const char ***url_p)
135 if (remote->pushurl_nr) {
136 *url_p = remote->pushurl;
137 return remote->pushurl_nr;
139 *url_p = remote->url;
140 return remote->url_nr;
143 static NORETURN void die_push_simple(struct branch *branch,
144 struct remote *remote)
147 * There's no point in using shorten_unambiguous_ref here,
148 * as the ambiguity would be on the remote side, not what
149 * we have locally. Plus, this is supposed to be the simple
150 * mode. If the user is doing something crazy like setting
151 * upstream to a non-branch, we should probably be showing
152 * them the big ugly fully qualified ref.
154 const char *advice_maybe = "";
155 const char *short_upstream = branch->merge[0]->src;
157 skip_prefix(short_upstream, "refs/heads/", &short_upstream);
160 * Don't show advice for people who explicitly set
161 * push.default.
163 if (push_default == PUSH_DEFAULT_UNSPECIFIED)
164 advice_maybe = _("\n"
165 "To choose either option permanently, "
166 "see push.default in 'git help config'.");
167 die(_("The upstream branch of your current branch does not match\n"
168 "the name of your current branch. To push to the upstream branch\n"
169 "on the remote, use\n"
170 "\n"
171 " git push %s HEAD:%s\n"
172 "\n"
173 "To push to the branch of the same name on the remote, use\n"
174 "\n"
175 " git push %s HEAD\n"
176 "%s"),
177 remote->name, short_upstream,
178 remote->name, advice_maybe);
181 static const char message_detached_head_die[] =
182 N_("You are not currently on a branch.\n"
183 "To push the history leading to the current (detached HEAD)\n"
184 "state now, use\n"
185 "\n"
186 " git push %s HEAD:<name-of-remote-branch>\n");
188 static const char *get_upstream_ref(struct branch *branch, const char *remote_name)
190 if (!branch->merge_nr || !branch->merge || !branch->remote_name)
191 die(_("The current branch %s has no upstream branch.\n"
192 "To push the current branch and set the remote as upstream, use\n"
193 "\n"
194 " git push --set-upstream %s %s\n"),
195 branch->name,
196 remote_name,
197 branch->name);
198 if (branch->merge_nr != 1)
199 die(_("The current branch %s has multiple upstream branches, "
200 "refusing to push."), branch->name);
202 return branch->merge[0]->src;
205 static void setup_push_upstream(struct remote *remote, struct branch *branch,
206 int same_remote)
208 const char *upstream_ref;
209 if (!branch)
210 die(_(message_detached_head_die), remote->name);
211 upstream_ref = get_upstream_ref(branch, remote->name);
212 if (!same_remote)
213 die(_("You are pushing to remote '%s', which is not the upstream of\n"
214 "your current branch '%s', without telling me what to push\n"
215 "to update which remote branch."),
216 remote->name, branch->name);
218 refspec_appendf(&rs, "%s:%s", branch->refname, upstream_ref);
221 static void setup_push_current(struct remote *remote, struct branch *branch)
223 if (!branch)
224 die(_(message_detached_head_die), remote->name);
225 refspec_appendf(&rs, "%s:%s", branch->refname, branch->refname);
228 static void setup_push_simple(struct remote *remote, struct branch *branch, int same_remote)
230 if (!branch)
231 die(_(message_detached_head_die), remote->name);
233 if (same_remote) {
234 const char *upstream_ref;
236 upstream_ref = get_upstream_ref(branch, remote->name);
238 /* Additional safety */
239 if (strcmp(branch->refname, upstream_ref))
240 die_push_simple(branch, remote);
242 refspec_appendf(&rs, "%s:%s", branch->refname, branch->refname);
245 static int is_same_remote(struct remote *remote)
247 struct remote *fetch_remote = remote_get(NULL);
248 return (!fetch_remote || fetch_remote == remote);
251 static void setup_default_push_refspecs(struct remote *remote)
253 struct branch *branch = branch_get(NULL);
254 int same_remote = is_same_remote(remote);
256 switch (push_default) {
257 default:
258 case PUSH_DEFAULT_MATCHING:
259 refspec_append(&rs, ":");
260 return;
262 case PUSH_DEFAULT_UNSPECIFIED:
263 case PUSH_DEFAULT_SIMPLE:
264 setup_push_simple(remote, branch, same_remote);
265 return;
267 case PUSH_DEFAULT_UPSTREAM:
268 setup_push_upstream(remote, branch, same_remote);
269 return;
271 case PUSH_DEFAULT_CURRENT:
272 setup_push_current(remote, branch);
273 return;
275 case PUSH_DEFAULT_NOTHING:
276 die(_("You didn't specify any refspecs to push, and "
277 "push.default is \"nothing\"."));
278 return;
282 static const char message_advice_pull_before_push[] =
283 N_("Updates were rejected because the tip of your current branch is behind\n"
284 "its remote counterpart. Integrate the remote changes (e.g.\n"
285 "'git pull ...') before pushing again.\n"
286 "See the 'Note about fast-forwards' in 'git push --help' for details.");
288 static const char message_advice_checkout_pull_push[] =
289 N_("Updates were rejected because a pushed branch tip is behind its remote\n"
290 "counterpart. Check out this branch and integrate the remote changes\n"
291 "(e.g. 'git pull ...') before pushing again.\n"
292 "See the 'Note about fast-forwards' in 'git push --help' for details.");
294 static const char message_advice_ref_fetch_first[] =
295 N_("Updates were rejected because the remote contains work that you do\n"
296 "not have locally. This is usually caused by another repository pushing\n"
297 "to the same ref. You may want to first integrate the remote changes\n"
298 "(e.g., 'git pull ...') before pushing again.\n"
299 "See the 'Note about fast-forwards' in 'git push --help' for details.");
301 static const char message_advice_ref_already_exists[] =
302 N_("Updates were rejected because the tag already exists in the remote.");
304 static const char message_advice_ref_needs_force[] =
305 N_("You cannot update a remote ref that points at a non-commit object,\n"
306 "or update a remote ref to make it point at a non-commit object,\n"
307 "without using the '--force' option.\n");
309 static const char message_advice_ref_needs_update[] =
310 N_("Updates were rejected because the tip of the remote-tracking\n"
311 "branch has been updated since the last checkout. You may want\n"
312 "to integrate those changes locally (e.g., 'git pull ...')\n"
313 "before forcing an update.\n");
315 static void advise_pull_before_push(void)
317 if (!advice_push_non_ff_current || !advice_push_update_rejected)
318 return;
319 advise(_(message_advice_pull_before_push));
322 static void advise_checkout_pull_push(void)
324 if (!advice_push_non_ff_matching || !advice_push_update_rejected)
325 return;
326 advise(_(message_advice_checkout_pull_push));
329 static void advise_ref_already_exists(void)
331 if (!advice_push_already_exists || !advice_push_update_rejected)
332 return;
333 advise(_(message_advice_ref_already_exists));
336 static void advise_ref_fetch_first(void)
338 if (!advice_push_fetch_first || !advice_push_update_rejected)
339 return;
340 advise(_(message_advice_ref_fetch_first));
343 static void advise_ref_needs_force(void)
345 if (!advice_push_needs_force || !advice_push_update_rejected)
346 return;
347 advise(_(message_advice_ref_needs_force));
350 static void advise_ref_needs_update(void)
352 if (!advice_push_ref_needs_update || !advice_push_update_rejected)
353 return;
354 advise(_(message_advice_ref_needs_update));
357 static int push_with_options(struct transport *transport, struct refspec *rs,
358 int flags)
360 int err;
361 unsigned int reject_reasons;
362 char *anon_url = transport_anonymize_url(transport->url);
364 transport_set_verbosity(transport, verbosity, progress);
365 transport->family = family;
367 if (receivepack)
368 transport_set_option(transport,
369 TRANS_OPT_RECEIVEPACK, receivepack);
370 transport_set_option(transport, TRANS_OPT_THIN, thin ? "yes" : NULL);
372 if (!is_empty_cas(&cas)) {
373 if (!transport->smart_options)
374 die("underlying transport does not support --%s option",
375 CAS_OPT_NAME);
376 transport->smart_options->cas = &cas;
379 if (verbosity > 0)
380 fprintf(stderr, _("Pushing to %s\n"), anon_url);
381 trace2_region_enter("push", "transport_push", the_repository);
382 err = transport_push(the_repository, transport,
383 rs, flags, &reject_reasons);
384 trace2_region_leave("push", "transport_push", the_repository);
385 if (err != 0) {
386 fprintf(stderr, "%s", push_get_color(PUSH_COLOR_ERROR));
387 error(_("failed to push some refs to '%s'"), anon_url);
388 fprintf(stderr, "%s", push_get_color(PUSH_COLOR_RESET));
391 err |= transport_disconnect(transport);
392 free(anon_url);
393 if (!err)
394 return 0;
396 if (reject_reasons & REJECT_NON_FF_HEAD) {
397 advise_pull_before_push();
398 } else if (reject_reasons & REJECT_NON_FF_OTHER) {
399 advise_checkout_pull_push();
400 } else if (reject_reasons & REJECT_ALREADY_EXISTS) {
401 advise_ref_already_exists();
402 } else if (reject_reasons & REJECT_FETCH_FIRST) {
403 advise_ref_fetch_first();
404 } else if (reject_reasons & REJECT_NEEDS_FORCE) {
405 advise_ref_needs_force();
406 } else if (reject_reasons & REJECT_REF_NEEDS_UPDATE) {
407 advise_ref_needs_update();
410 return 1;
413 static int do_push(int flags,
414 const struct string_list *push_options,
415 struct remote *remote)
417 int i, errs;
418 const char **url;
419 int url_nr;
420 struct refspec *push_refspec = &rs;
422 if (push_options->nr)
423 flags |= TRANSPORT_PUSH_OPTIONS;
425 if (!push_refspec->nr && !(flags & TRANSPORT_PUSH_ALL)) {
426 if (remote->push.nr) {
427 push_refspec = &remote->push;
428 } else if (!(flags & TRANSPORT_PUSH_MIRROR))
429 setup_default_push_refspecs(remote);
431 errs = 0;
432 url_nr = push_url_of_remote(remote, &url);
433 if (url_nr) {
434 for (i = 0; i < url_nr; i++) {
435 struct transport *transport =
436 transport_get(remote, url[i]);
437 if (flags & TRANSPORT_PUSH_OPTIONS)
438 transport->push_options = push_options;
439 if (push_with_options(transport, push_refspec, flags))
440 errs++;
442 } else {
443 struct transport *transport =
444 transport_get(remote, NULL);
445 if (flags & TRANSPORT_PUSH_OPTIONS)
446 transport->push_options = push_options;
447 if (push_with_options(transport, push_refspec, flags))
448 errs++;
450 return !!errs;
453 static int option_parse_recurse_submodules(const struct option *opt,
454 const char *arg, int unset)
456 int *recurse_submodules = opt->value;
458 if (unset)
459 *recurse_submodules = RECURSE_SUBMODULES_OFF;
460 else
461 *recurse_submodules = parse_push_recurse_submodules_arg(opt->long_name, arg);
463 return 0;
466 static void set_push_cert_flags(int *flags, int v)
468 switch (v) {
469 case SEND_PACK_PUSH_CERT_NEVER:
470 *flags &= ~(TRANSPORT_PUSH_CERT_ALWAYS | TRANSPORT_PUSH_CERT_IF_ASKED);
471 break;
472 case SEND_PACK_PUSH_CERT_ALWAYS:
473 *flags |= TRANSPORT_PUSH_CERT_ALWAYS;
474 *flags &= ~TRANSPORT_PUSH_CERT_IF_ASKED;
475 break;
476 case SEND_PACK_PUSH_CERT_IF_ASKED:
477 *flags |= TRANSPORT_PUSH_CERT_IF_ASKED;
478 *flags &= ~TRANSPORT_PUSH_CERT_ALWAYS;
479 break;
484 static int git_push_config(const char *k, const char *v, void *cb)
486 const char *slot_name;
487 int *flags = cb;
488 int status;
490 status = git_gpg_config(k, v, NULL);
491 if (status)
492 return status;
494 if (!strcmp(k, "push.followtags")) {
495 if (git_config_bool(k, v))
496 *flags |= TRANSPORT_PUSH_FOLLOW_TAGS;
497 else
498 *flags &= ~TRANSPORT_PUSH_FOLLOW_TAGS;
499 return 0;
500 } else if (!strcmp(k, "push.gpgsign")) {
501 const char *value;
502 if (!git_config_get_value("push.gpgsign", &value)) {
503 switch (git_parse_maybe_bool(value)) {
504 case 0:
505 set_push_cert_flags(flags, SEND_PACK_PUSH_CERT_NEVER);
506 break;
507 case 1:
508 set_push_cert_flags(flags, SEND_PACK_PUSH_CERT_ALWAYS);
509 break;
510 default:
511 if (value && !strcasecmp(value, "if-asked"))
512 set_push_cert_flags(flags, SEND_PACK_PUSH_CERT_IF_ASKED);
513 else
514 return error("Invalid value for '%s'", k);
517 } else if (!strcmp(k, "push.recursesubmodules")) {
518 const char *value;
519 if (!git_config_get_value("push.recursesubmodules", &value))
520 recurse_submodules = parse_push_recurse_submodules_arg(k, value);
521 } else if (!strcmp(k, "submodule.recurse")) {
522 int val = git_config_bool(k, v) ?
523 RECURSE_SUBMODULES_ON_DEMAND : RECURSE_SUBMODULES_OFF;
524 recurse_submodules = val;
525 } else if (!strcmp(k, "push.pushoption")) {
526 if (!v)
527 return config_error_nonbool(k);
528 else
529 if (!*v)
530 string_list_clear(&push_options_config, 0);
531 else
532 string_list_append(&push_options_config, v);
533 return 0;
534 } else if (!strcmp(k, "color.push")) {
535 push_use_color = git_config_colorbool(k, v);
536 return 0;
537 } else if (skip_prefix(k, "color.push.", &slot_name)) {
538 int slot = parse_push_color_slot(slot_name);
539 if (slot < 0)
540 return 0;
541 if (!v)
542 return config_error_nonbool(k);
543 return color_parse(v, push_colors[slot]);
544 } else if (!strcmp(k, "push.useforceifincludes")) {
545 if (git_config_bool(k, v))
546 *flags |= TRANSPORT_PUSH_FORCE_IF_INCLUDES;
547 else
548 *flags &= ~TRANSPORT_PUSH_FORCE_IF_INCLUDES;
549 return 0;
552 return git_default_config(k, v, NULL);
555 int cmd_push(int argc, const char **argv, const char *prefix)
557 int flags = 0;
558 int tags = 0;
559 int push_cert = -1;
560 int rc;
561 const char *repo = NULL; /* default repository */
562 struct string_list push_options_cmdline = STRING_LIST_INIT_DUP;
563 struct string_list *push_options;
564 const struct string_list_item *item;
565 struct remote *remote;
567 struct option options[] = {
568 OPT__VERBOSITY(&verbosity),
569 OPT_STRING( 0 , "repo", &repo, N_("repository"), N_("repository")),
570 OPT_BIT( 0 , "all", &flags, N_("push all refs"), TRANSPORT_PUSH_ALL),
571 OPT_BIT( 0 , "mirror", &flags, N_("mirror all refs"),
572 (TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE)),
573 OPT_BOOL('d', "delete", &deleterefs, N_("delete refs")),
574 OPT_BOOL( 0 , "tags", &tags, N_("push tags (can't be used with --all or --mirror)")),
575 OPT_BIT('n' , "dry-run", &flags, N_("dry run"), TRANSPORT_PUSH_DRY_RUN),
576 OPT_BIT( 0, "porcelain", &flags, N_("machine-readable output"), TRANSPORT_PUSH_PORCELAIN),
577 OPT_BIT('f', "force", &flags, N_("force updates"), TRANSPORT_PUSH_FORCE),
578 OPT_CALLBACK_F(0, CAS_OPT_NAME, &cas, N_("<refname>:<expect>"),
579 N_("require old value of ref to be at this value"),
580 PARSE_OPT_OPTARG | PARSE_OPT_LITERAL_ARGHELP, parseopt_push_cas_option),
581 OPT_BIT(0, TRANS_OPT_FORCE_IF_INCLUDES, &flags,
582 N_("require remote updates to be integrated locally"),
583 TRANSPORT_PUSH_FORCE_IF_INCLUDES),
584 OPT_CALLBACK(0, "recurse-submodules", &recurse_submodules, "(check|on-demand|no)",
585 N_("control recursive pushing of submodules"), option_parse_recurse_submodules),
586 OPT_BOOL_F( 0 , "thin", &thin, N_("use thin pack"), PARSE_OPT_NOCOMPLETE),
587 OPT_STRING( 0 , "receive-pack", &receivepack, "receive-pack", N_("receive pack program")),
588 OPT_STRING( 0 , "exec", &receivepack, "receive-pack", N_("receive pack program")),
589 OPT_BIT('u', "set-upstream", &flags, N_("set upstream for git pull/status"),
590 TRANSPORT_PUSH_SET_UPSTREAM),
591 OPT_BOOL(0, "progress", &progress, N_("force progress reporting")),
592 OPT_BIT(0, "prune", &flags, N_("prune locally removed refs"),
593 TRANSPORT_PUSH_PRUNE),
594 OPT_BIT(0, "no-verify", &flags, N_("bypass pre-push hook"), TRANSPORT_PUSH_NO_HOOK),
595 OPT_BIT(0, "follow-tags", &flags, N_("push missing but relevant tags"),
596 TRANSPORT_PUSH_FOLLOW_TAGS),
597 OPT_CALLBACK_F(0, "signed", &push_cert, "(yes|no|if-asked)", N_("GPG sign the push"),
598 PARSE_OPT_OPTARG, option_parse_push_signed),
599 OPT_BIT(0, "atomic", &flags, N_("request atomic transaction on remote side"), TRANSPORT_PUSH_ATOMIC),
600 OPT_STRING_LIST('o', "push-option", &push_options_cmdline, N_("server-specific"), N_("option to transmit")),
601 OPT_SET_INT('4', "ipv4", &family, N_("use IPv4 addresses only"),
602 TRANSPORT_FAMILY_IPV4),
603 OPT_SET_INT('6', "ipv6", &family, N_("use IPv6 addresses only"),
604 TRANSPORT_FAMILY_IPV6),
605 OPT_END()
608 packet_trace_identity("push");
609 git_config(git_push_config, &flags);
610 argc = parse_options(argc, argv, prefix, options, push_usage, 0);
611 push_options = (push_options_cmdline.nr
612 ? &push_options_cmdline
613 : &push_options_config);
614 set_push_cert_flags(&flags, push_cert);
616 if (deleterefs && (tags || (flags & (TRANSPORT_PUSH_ALL | TRANSPORT_PUSH_MIRROR))))
617 die(_("--delete is incompatible with --all, --mirror and --tags"));
618 if (deleterefs && argc < 2)
619 die(_("--delete doesn't make sense without any refs"));
621 if (recurse_submodules == RECURSE_SUBMODULES_CHECK)
622 flags |= TRANSPORT_RECURSE_SUBMODULES_CHECK;
623 else if (recurse_submodules == RECURSE_SUBMODULES_ON_DEMAND)
624 flags |= TRANSPORT_RECURSE_SUBMODULES_ON_DEMAND;
625 else if (recurse_submodules == RECURSE_SUBMODULES_ONLY)
626 flags |= TRANSPORT_RECURSE_SUBMODULES_ONLY;
628 if (tags)
629 refspec_append(&rs, "refs/tags/*");
631 if (argc > 0) {
632 repo = argv[0];
633 set_refspecs(argv + 1, argc - 1, repo);
636 remote = pushremote_get(repo);
637 if (!remote) {
638 if (repo)
639 die(_("bad repository '%s'"), repo);
640 die(_("No configured push destination.\n"
641 "Either specify the URL from the command-line or configure a remote repository using\n"
642 "\n"
643 " git remote add <name> <url>\n"
644 "\n"
645 "and then push using the remote name\n"
646 "\n"
647 " git push <name>\n"));
650 if (remote->mirror)
651 flags |= (TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE);
653 if (flags & TRANSPORT_PUSH_ALL) {
654 if (tags)
655 die(_("--all and --tags are incompatible"));
656 if (argc >= 2)
657 die(_("--all can't be combined with refspecs"));
659 if (flags & TRANSPORT_PUSH_MIRROR) {
660 if (tags)
661 die(_("--mirror and --tags are incompatible"));
662 if (argc >= 2)
663 die(_("--mirror can't be combined with refspecs"));
665 if ((flags & TRANSPORT_PUSH_ALL) && (flags & TRANSPORT_PUSH_MIRROR))
666 die(_("--all and --mirror are incompatible"));
668 if (!is_empty_cas(&cas) && (flags & TRANSPORT_PUSH_FORCE_IF_INCLUDES))
669 cas.use_force_if_includes = 1;
671 for_each_string_list_item(item, push_options)
672 if (strchr(item->string, '\n'))
673 die(_("push options must not have new line characters"));
675 rc = do_push(flags, push_options, remote);
676 string_list_clear(&push_options_cmdline, 0);
677 string_list_clear(&push_options_config, 0);
678 if (rc == -1)
679 usage_with_options(push_usage, options);
680 else
681 return rc;