MCPcopy Create free account
hub / github.com/git/git / fetch_one

Function fetch_one

builtin/fetch.c:2389–2465  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2387}
2388
2389static int fetch_one(struct remote *remote, int argc, const char **argv,
2390 int prune_tags_ok, int use_stdin_refspecs,
2391 const struct fetch_config *config,
2392 struct list_objects_filter_options *filter_options)
2393{
2394 struct refspec rs = REFSPEC_INIT_FETCH;
2395 int i;
2396 int exit_code;
2397 int maybe_prune_tags;
2398 int remote_via_config = remote_is_configured(remote, 0);
2399
2400 if (!remote)
2401 die(_("no remote repository specified; please specify either a URL or a\n"
2402 "remote name from which new revisions should be fetched"));
2403
2404 gtransport = prepare_transport(remote, 1, filter_options);
2405
2406 if (prune < 0) {
2407 /* no command line request */
2408 if (0 <= remote->prune)
2409 prune = remote->prune;
2410 else if (0 <= config->prune)
2411 prune = config->prune;
2412 else
2413 prune = PRUNE_BY_DEFAULT;
2414 }
2415
2416 if (prune_tags < 0) {
2417 /* no command line request */
2418 if (0 <= remote->prune_tags)
2419 prune_tags = remote->prune_tags;
2420 else if (0 <= config->prune_tags)
2421 prune_tags = config->prune_tags;
2422 else
2423 prune_tags = PRUNE_TAGS_BY_DEFAULT;
2424 }
2425
2426 maybe_prune_tags = prune_tags_ok && prune_tags;
2427 if (maybe_prune_tags && remote_via_config)
2428 refspec_append(&remote->fetch, TAG_REFSPEC);
2429
2430 if (maybe_prune_tags && (argc || !remote_via_config))
2431 refspec_append(&rs, TAG_REFSPEC);
2432
2433 for (i = 0; i < argc; i++) {
2434 if (!strcmp(argv[i], "tag")) {
2435 i++;
2436 if (i >= argc)
2437 die(_("you need to specify a tag name"));
2438
2439 refspec_appendf(&rs, "refs/tags/%s:refs/tags/%s",
2440 argv[i], argv[i]);
2441 } else {
2442 refspec_append(&rs, argv[i]);
2443 }
2444 }
2445
2446 if (use_stdin_refspecs) {

Callers 1

cmd_fetchFunction · 0.85

Calls 13

remote_is_configuredFunction · 0.85
prepare_transportFunction · 0.85
refspec_appendFunction · 0.85
refspec_appendfFunction · 0.85
strbuf_getline_lfFunction · 0.85
strbuf_releaseFunction · 0.85
sigchain_push_commonFunction · 0.85
sigchain_pushFunction · 0.85
do_fetchFunction · 0.85
sigchain_popFunction · 0.85
refspec_clearFunction · 0.85
transport_disconnectFunction · 0.85

Tested by

no test coverage detected