MCPcopy Index your code
hub / github.com/git/git / walker_fetch

Function walker_fetch

walker.c:279–354  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

277}
278
279int walker_fetch(struct walker *walker, int targets, char **target,
280 const char **write_ref, const char *write_ref_log_details)
281{
282 struct strbuf refname = STRBUF_INIT;
283 struct strbuf err = STRBUF_INIT;
284 struct ref_transaction *transaction = NULL;
285 struct object_id *oids;
286 char *msg = NULL;
287 int i, ret = -1;
288
289 save_commit_buffer = 0;
290
291 ALLOC_ARRAY(oids, targets);
292
293 if (write_ref) {
294 transaction = ref_store_transaction_begin(get_main_ref_store(the_repository),
295 0, &err);
296 if (!transaction) {
297 error("%s", err.buf);
298 goto done;
299 }
300 }
301
302 if (!walker->get_recover) {
303 refs_for_each_ref(get_main_ref_store(the_repository),
304 mark_complete, NULL);
305 }
306
307 for (i = 0; i < targets; i++) {
308 if (interpret_target(walker, target[i], oids + i)) {
309 error("Could not interpret response from server '%s' as something to pull", target[i]);
310 goto done;
311 }
312 if (process(walker, lookup_unknown_object(the_repository, &oids[i])))
313 goto done;
314 }
315
316 if (loop(walker))
317 goto done;
318 if (!write_ref) {
319 ret = 0;
320 goto done;
321 }
322 if (write_ref_log_details) {
323 msg = xstrfmt("fetch from %s", write_ref_log_details);
324 } else {
325 msg = NULL;
326 }
327 for (i = 0; i < targets; i++) {
328 if (!write_ref[i])
329 continue;
330 strbuf_reset(&refname);
331 strbuf_addf(&refname, "refs/%s", write_ref[i]);
332 if (ref_transaction_update(transaction, refname.buf,
333 oids + i, NULL, NULL, NULL, 0,
334 msg ? msg : "fetch (unknown)",
335 &err)) {
336 error("%s", err.buf);

Callers 2

fetch_dumbFunction · 0.85
fetch_using_walkerFunction · 0.85

Calls 14

get_main_ref_storeFunction · 0.85
errorFunction · 0.85
refs_for_each_refFunction · 0.85
interpret_targetFunction · 0.85
processFunction · 0.85
lookup_unknown_objectFunction · 0.85
loopFunction · 0.85
xstrfmtFunction · 0.85
strbuf_addfFunction · 0.85
ref_transaction_updateFunction · 0.85
ref_transaction_commitFunction · 0.85

Tested by

no test coverage detected