| 1192 | } |
| 1193 | |
| 1194 | static int fetch_git(struct discovery *heads, |
| 1195 | int nr_heads, struct ref **to_fetch) |
| 1196 | { |
| 1197 | struct rpc_state rpc = RPC_STATE_INIT; |
| 1198 | struct strbuf preamble = STRBUF_INIT; |
| 1199 | int i, err; |
| 1200 | struct strvec args = STRVEC_INIT; |
| 1201 | struct strbuf rpc_result = STRBUF_INIT; |
| 1202 | |
| 1203 | strvec_pushl(&args, "fetch-pack", "--stateless-rpc", |
| 1204 | "--stdin", "--lock-pack", NULL); |
| 1205 | if (options.followtags) |
| 1206 | strvec_push(&args, "--include-tag"); |
| 1207 | if (options.thin) |
| 1208 | strvec_push(&args, "--thin"); |
| 1209 | if (options.verbosity >= 3) |
| 1210 | strvec_pushl(&args, "-v", "-v", NULL); |
| 1211 | if (options.check_self_contained_and_connected) |
| 1212 | strvec_push(&args, "--check-self-contained-and-connected"); |
| 1213 | if (options.cloning) |
| 1214 | strvec_push(&args, "--cloning"); |
| 1215 | if (options.update_shallow) |
| 1216 | strvec_push(&args, "--update-shallow"); |
| 1217 | if (!options.progress) |
| 1218 | strvec_push(&args, "--no-progress"); |
| 1219 | if (options.depth) |
| 1220 | strvec_pushf(&args, "--depth=%lu", options.depth); |
| 1221 | if (options.deepen_since) |
| 1222 | strvec_pushf(&args, "--shallow-since=%s", options.deepen_since); |
| 1223 | for (i = 0; i < options.deepen_not.nr; i++) |
| 1224 | strvec_pushf(&args, "--shallow-exclude=%s", |
| 1225 | options.deepen_not.items[i].string); |
| 1226 | if (options.deepen_relative && options.depth) |
| 1227 | strvec_push(&args, "--deepen-relative"); |
| 1228 | if (options.from_promisor) |
| 1229 | strvec_push(&args, "--from-promisor"); |
| 1230 | if (options.refetch) |
| 1231 | strvec_push(&args, "--refetch"); |
| 1232 | if (options.filter) |
| 1233 | strvec_pushf(&args, "--filter=%s", options.filter); |
| 1234 | strvec_push(&args, url.buf); |
| 1235 | |
| 1236 | for (i = 0; i < nr_heads; i++) { |
| 1237 | struct ref *ref = to_fetch[i]; |
| 1238 | if (!*ref->name) |
| 1239 | die(_("cannot fetch by sha1 over smart http")); |
| 1240 | packet_buf_write(&preamble, "%s %s\n", |
| 1241 | oid_to_hex(&ref->old_oid), ref->name); |
| 1242 | } |
| 1243 | packet_buf_flush(&preamble); |
| 1244 | |
| 1245 | memset(&rpc, 0, sizeof(rpc)); |
| 1246 | rpc.service_name = "git-upload-pack"; |
| 1247 | rpc.gzip_request = 1; |
| 1248 | |
| 1249 | err = rpc_service(&rpc, heads, args.v, &preamble, &rpc_result); |
| 1250 | if (rpc_result.len) |
| 1251 | write_or_die(1, rpc_result.buf, rpc_result.len); |
no test coverage detected