| 1362 | } |
| 1363 | |
| 1364 | static int push_git(struct discovery *heads, int nr_spec, const char **specs) |
| 1365 | { |
| 1366 | struct rpc_state rpc = RPC_STATE_INIT; |
| 1367 | int i, err; |
| 1368 | struct strvec args; |
| 1369 | struct string_list_item *cas_option; |
| 1370 | struct strbuf preamble = STRBUF_INIT; |
| 1371 | struct strbuf rpc_result = STRBUF_INIT; |
| 1372 | |
| 1373 | strvec_init(&args); |
| 1374 | strvec_pushl(&args, "send-pack", "--stateless-rpc", "--helper-status", |
| 1375 | NULL); |
| 1376 | |
| 1377 | if (options.thin) |
| 1378 | strvec_push(&args, "--thin"); |
| 1379 | if (options.dry_run) |
| 1380 | strvec_push(&args, "--dry-run"); |
| 1381 | if (options.push_cert == SEND_PACK_PUSH_CERT_ALWAYS) |
| 1382 | strvec_push(&args, "--signed=yes"); |
| 1383 | else if (options.push_cert == SEND_PACK_PUSH_CERT_IF_ASKED) |
| 1384 | strvec_push(&args, "--signed=if-asked"); |
| 1385 | if (options.atomic) |
| 1386 | strvec_push(&args, "--atomic"); |
| 1387 | if (options.verbosity == 0) |
| 1388 | strvec_push(&args, "--quiet"); |
| 1389 | else if (options.verbosity > 1) |
| 1390 | strvec_push(&args, "--verbose"); |
| 1391 | for (i = 0; i < options.push_options.nr; i++) |
| 1392 | strvec_pushf(&args, "--push-option=%s", |
| 1393 | options.push_options.items[i].string); |
| 1394 | strvec_push(&args, options.progress ? "--progress" : "--no-progress"); |
| 1395 | for_each_string_list_item(cas_option, &cas_options) |
| 1396 | strvec_push(&args, cas_option->string); |
| 1397 | strvec_push(&args, url.buf); |
| 1398 | |
| 1399 | if (options.force_if_includes) |
| 1400 | strvec_push(&args, "--force-if-includes"); |
| 1401 | |
| 1402 | strvec_push(&args, "--stdin"); |
| 1403 | for (i = 0; i < nr_spec; i++) |
| 1404 | packet_buf_write(&preamble, "%s\n", specs[i]); |
| 1405 | packet_buf_flush(&preamble); |
| 1406 | |
| 1407 | memset(&rpc, 0, sizeof(rpc)); |
| 1408 | rpc.service_name = "git-receive-pack"; |
| 1409 | |
| 1410 | err = rpc_service(&rpc, heads, args.v, &preamble, &rpc_result); |
| 1411 | if (rpc_result.len) |
| 1412 | write_or_die(1, rpc_result.buf, rpc_result.len); |
| 1413 | strbuf_release(&rpc_result); |
| 1414 | strbuf_release(&preamble); |
| 1415 | strvec_clear(&args); |
| 1416 | return err; |
| 1417 | } |
| 1418 | |
| 1419 | static int push(int nr_spec, const char **specs) |
| 1420 | { |
no test coverage detected