Branch Coverage

deps/libgit2/src/libgit2/remote.c
Criterion Covered Total %
branch 267 1110 24.0


line true false branch
41 0 13 GIT_ERROR_CHECK_ALLOC(spec);
43 0 13 if (git_refspec__parse(spec, string, is_fetch) < 0) {
49 0 13 if (git_vector_insert(vector, spec) < 0) {
69 0 10 if (git_str_printf(&buf, "remote.%s.tagopt", remote->name) < 0)
75 10 0 if (!error && ce && ce->value) {
0 10 if (!error && ce && ce->value) {
0 0 if (!error && ce && ce->value) {
76 0 0 if (!strcmp(ce->value, "--no-tags"))
78 0 0 else if (!strcmp(ce->value, "--tags"))
92 26 0 if (!error && !valid) {
0 26 if (!error && !valid) {
93 0 0 git_error_set(
110 0 3 if ((error = git_repository_config__weakptr(&cfg, repo)) < 0)
113 3 0 fmt = fetch ? CONFIG_FETCH_FMT : CONFIG_PUSH_FMT;
115 0 3 if ((error = ensure_remote_name_is_valid(name)) < 0)
118 0 3 if ((error = git_refspec__parse(&spec, refspec, fetch)) < 0)
123 0 3 if ((error = git_str_printf(&var, fmt, name)) < 0)
131 0 3 if ((error = git_config_set_multivar(cfg, var.ptr, "$^", refspec)) < 0) {
142 9 0 if (in == NULL || strlen(in) == 0) {
0 9 if (in == NULL || strlen(in) == 0) {
166 0 4 if (git_str_printf(buf, "+refs/heads/*:refs/remotes/%s/*", name) < 0)
179 4 0 if (error == GIT_ENOTFOUND)
182 0 0 if (error < 0)
194 0 0 GIT_INIT_STRUCTURE_FROM_TEMPLATE(
216 0 5 GIT_ASSERT_ARG(out);
217 0 5 GIT_ASSERT_ARG(url);
219 0 5 if (!opts) {
223 0 5 GIT_ERROR_CHECK_VERSION(opts, GIT_REMOTE_CREATE_OPTIONS_VERSION, "git_remote_create_options");
225 3 2 if (opts->name != NULL) {
226 0 3 if ((error = ensure_remote_name_is_valid(opts->name)) < 0)
229 3 0 if (opts->repository &&
0 3 if (opts->repository &&
234 5 0 if (opts->repository) {
235 0 5 if ((error = git_repository_config_snapshot(&config_ro, opts->repository)) < 0)
240 0 5 GIT_ERROR_CHECK_ALLOC(remote);
244 5 0 if ((error = git_vector_init(&remote->refs, 8, NULL)) < 0 ||
5 0 if ((error = git_vector_init(&remote->refs, 8, NULL)) < 0 ||
248 5 0 if (opts->repository && !(opts->flags & GIT_REMOTE_CREATE_SKIP_INSTEADOF)) {
5 0 if (opts->repository && !(opts->flags & GIT_REMOTE_CREATE_SKIP_INSTEADOF)) {
249 5 0 if ((error = apply_insteadof(&remote->url, config_ro, canonical_url.ptr, GIT_DIRECTION_FETCH, true)) < 0 ||
5 0 if ((error = apply_insteadof(&remote->url, config_ro, canonical_url.ptr, GIT_DIRECTION_FETCH, true)) < 0 ||
254 0 0 GIT_ERROR_CHECK_ALLOC(remote->url);
257 3 2 if (opts->name != NULL) {
259 0 3 GIT_ERROR_CHECK_ALLOC(remote->name);
261 3 0 if (opts->repository &&
3 0 if (opts->repository &&
262 3 0 ((error = git_str_printf(&var, CONFIG_URL_FMT, opts->name)) < 0 ||
263 3 0 (error = git_repository_config__weakptr(&config_rw, opts->repository)) < 0 ||
268 4 1 if (opts->fetchspec != NULL ||
2 2 if (opts->fetchspec != NULL ||
269 2 0 (opts->name && !(opts->flags & GIT_REMOTE_CREATE_SKIP_DEFAULT_FETCHSPEC))) {
271 1 2 if (opts->fetchspec) {
274 0 2 if ((error = default_fetchspec_for_name(&specbuf, opts->name)) < 0)
280 0 3 if ((error = add_refspec(remote, fetch, true)) < 0)
284 3 0 if (opts->repository && opts->name &&
3 0 if (opts->repository && opts->name &&
3 0 if (opts->repository && opts->name &&
285 3 0 ((error = write_add_refspec(opts->repository, opts->name, fetch, true)) < 0 ||
290 0 3 if ((error = dwim_refspecs(&remote->active_refspecs, &remote->refspecs, &remote->refs)) < 0)
295 2 3 if (!opts->name)
307 0 5 if (error)
324 0 2 if ((error = ensure_remote_name_is_valid(name)) < 0)
327 0 2 if (canonicalize_url(&buf, url) < 0)
347 0 1 if ((error = ensure_remote_name_is_valid(name)) < 0)
378 0 0 GIT_ERROR_CHECK_ALLOC(remote);
380 0 0 if (source->name != NULL) {
382 0 0 GIT_ERROR_CHECK_ALLOC(remote->name);
385 0 0 if (source->url != NULL) {
387 0 0 GIT_ERROR_CHECK_ALLOC(remote->url);
390 0 0 if (source->pushurl != NULL) {
392 0 0 GIT_ERROR_CHECK_ALLOC(remote->pushurl);
400 0 0 git_vector_init(&remote->refspecs, 2, NULL) < 0 ||
406 0 0 git_vector_foreach(&source->refspecs, i, spec) {
407 0 0 if ((error = add_refspec(remote, spec->string, !spec->push)) < 0)
415 0 0 if (error < 0)
439 0 48 if (git_str_oom(buf))
442 20 28 if (cb != NULL)
447 28 20 if (found)
450 25 23 if (error == GIT_ENOTFOUND) {
468 0 14 GIT_ASSERT_ARG(out);
469 0 14 GIT_ASSERT_ARG(repo);
470 0 14 GIT_ASSERT_ARG(name);
472 0 14 if ((error = ensure_remote_name_is_valid(name)) < 0)
475 0 14 if ((error = git_repository_config_snapshot(&config, repo)) < 0)
479 0 14 GIT_ERROR_CHECK_ALLOC(remote);
482 0 14 GIT_ERROR_CHECK_ALLOC(remote->name);
485 14 0 git_vector_init(&remote->refspecs, 2, NULL) < 0 ||
486 0 14 git_vector_init(&remote->passive_refspecs, 2, NULL) < 0 ||
492 0 14 if ((error = git_str_printf(&buf, "remote.%s.url", name)) < 0)
495 0 14 if ((error = get_optional_config(&found, config, &buf, NULL, (void *)&val)) < 0)
503 10 4 if (found && strlen(val) > 0) {
10 0 if (found && strlen(val) > 0) {
504 10 0 if ((error = apply_insteadof(&remote->url, config, val, GIT_DIRECTION_FETCH, true)) < 0 ||
10 0 if ((error = apply_insteadof(&remote->url, config, val, GIT_DIRECTION_FETCH, true)) < 0 ||
513 0 14 if ((error = get_optional_config(&found, config, &buf, NULL, (void *)&val)) < 0)
518 4 10 if (!optional_setting_found) {
524 3 7 if (found && strlen(val) > 0) {
3 0 if (found && strlen(val) > 0) {
525 0 3 if (remote->pushurl)
528 0 3 if ((error = apply_insteadof(&remote->pushurl, config, val, GIT_DIRECTION_FETCH, true)) < 0)
538 0 10 if ((error = get_optional_config(NULL, config, &buf, refspec_cb, &data)) < 0)
545 0 10 if ((error = get_optional_config(NULL, config, &buf, refspec_cb, &data)) < 0)
548 0 10 if ((error = download_tags_value(remote, config)) < 0)
551 0 10 if ((error = lookup_remote_prune_config(remote, config, name)) < 0)
555 0 10 if ((error = dwim_refspecs(&remote->active_refspecs, &remote->refspecs, &remote->refs)) < 0)
564 4 10 if (error < 0)
577 13 0 if ((error = git_config_get_bool(&remote->prune_refs, config, git_str_cstr(&buf))) < 0) {
578 13 0 if (error == GIT_ENOTFOUND) {
581 13 0 if ((error = git_config_get_bool(&remote->prune_refs, config, "fetch.prune")) < 0) {
582 13 0 if (error == GIT_ENOTFOUND) {
596 0 6 GIT_ASSERT_ARG_WITH_RETVAL(remote, NULL);
602 0 2 GIT_ASSERT_ARG_WITH_RETVAL(remote, NULL);
608 0 2 GIT_ASSERT_ARG_WITH_RETVAL(remote, NULL);
616 0 0 GIT_ASSERT_ARG(remote);
617 0 0 GIT_ASSERT_ARG(url);
619 0 0 if ((tmp = git__strdup(url)) == NULL)
634 0 2 GIT_ASSERT_ARG(repo);
635 0 2 GIT_ASSERT_ARG(remote);
637 0 2 if ((error = ensure_remote_name_is_valid(remote)) < 0)
640 0 2 if ((error = git_repository_config__weakptr(&cfg, repo)) < 0)
643 0 2 if ((error = git_str_printf(&buf, pattern, remote)) < 0)
646 2 0 if (url) {
647 0 2 if ((error = canonicalize_url(&canonical_url, url)) < 0)
669 0 1 GIT_ASSERT_ARG_WITH_RETVAL(remote, NULL);
677 0 0 GIT_ASSERT_ARG(remote);
678 0 0 GIT_ASSERT_ARG(url);
680 0 0 if ((tmp = git__strdup(url)) == NULL)
707 2 0 if (callbacks && callbacks->resolve_url) {
0 2 if (callbacks && callbacks->resolve_url) {
710 0 0 if (error != GIT_PASSTHROUGH) {
732 0 2 GIT_ASSERT_ARG(remote);
733 2 0 GIT_ASSERT_ARG(direction == GIT_DIRECTION_FETCH || direction == GIT_DIRECTION_PUSH);
0 2 GIT_ASSERT_ARG(direction == GIT_DIRECTION_FETCH || direction == GIT_DIRECTION_PUSH);
735 2 0 if (callbacks && callbacks->remote_ready) {
0 2 if (callbacks && callbacks->remote_ready) {
738 0 0 if (status != 0 && status != GIT_PASSTHROUGH) {
0 0 if (status != 0 && status != GIT_PASSTHROUGH) {
744 0 2 if (direction == GIT_DIRECTION_FETCH)
746 2 0 else if (direction == GIT_DIRECTION_PUSH)
747 0 2 url = remote->pushurl ? remote->pushurl : remote->url;
749 0 2 if (!url) {
750 0 0 git_error_set(GIT_ERROR_INVALID,
0 0 git_error_set(GIT_ERROR_INVALID,
764 0 6 GIT_INIT_STRUCTURE_FROM_TEMPLATE(
784 0 8 if (!opts)
794 0 0 if (!colon)
805 0 0 if ((c = strchr(http_header, '\r')) != NULL)
807 0 0 if ((c = strchr(http_header, '\n')) != NULL)
811 0 0 if ((name_len = http_header_name_length(http_header)) < 1)
832 0 0 for (i = 0; i < ARRAY_SIZE(forbidden_custom_headers); i++)
833 0 0 if (strncmp(forbidden_custom_headers[i], custom_header, name_len) == 0)
843 0 4 if (!custom_headers)
846 0 4 for (i = 0; i < custom_headers->count; i++) {
847 0 0 if (is_malformed_http_header(custom_headers->strings[i])) {
852 0 0 if (is_forbidden_custom_header(custom_headers->strings[i])) {
869 0 4 if (!repo) {
874 0 4 if ((error = git_repository_config_snapshot(&config, repo)) < 0)
877 4 0 if ((error = git_config_get_string(&value, config, "http.followRedirects")) < 0) {
878 4 0 if (error == GIT_ENOTFOUND) {
886 0 0 if (git_config_parse_bool(&bool_value, value) == 0) {
887 0 0 *out = bool_value ? GIT_REMOTE_REDIRECT_ALL :
889 0 0 } else if (strcasecmp(value, "initial") == 0) {
909 4 2 if (src) {
910 0 4 GIT_ERROR_CHECK_VERSION(src, GIT_REMOTE_CONNECT_OPTIONS_VERSION, "git_remote_connect_options");
911 0 4 GIT_ERROR_CHECK_VERSION(&src->callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks");
912 0 4 GIT_ERROR_CHECK_VERSION(&src->proxy_opts, GIT_PROXY_OPTIONS_VERSION, "git_proxy_options");
919 4 2 if (dst->follow_redirects == 0) {
920 0 4 if (lookup_redirect_config(&dst->follow_redirects, repo) < 0)
937 0 2 GIT_ASSERT_ARG(remote);
939 2 0 if (given_opts)
942 0 2 GIT_ERROR_CHECK_VERSION(&opts.callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks");
943 0 2 GIT_ERROR_CHECK_VERSION(&opts.proxy_opts, GIT_PROXY_OPTIONS_VERSION, "git_proxy_options");
947 0 2 if ((error = git_remote__urlfordirection(&url, remote, direction, &opts.callbacks)) < 0)
952 2 0 if (!t && opts.callbacks.transport &&
0 2 if (!t && opts.callbacks.transport &&
0 0 if (!t && opts.callbacks.transport &&
958 2 0 if (!t && (error = git_transport_new(&t, remote, url.ptr)) < 0)
0 2 if (!t && (error = git_transport_new(&t, remote, url.ptr)) < 0)
961 0 2 if ((error = t->connect(t, url.ptr, direction, &opts)) != 0)
971 0 0 if (t)
976 0 0 if (t == remote->transport)
991 0 0 if (callbacks)
994 0 0 if (proxy)
997 0 0 if (custom_headers)
1005 0 2 GIT_ASSERT_ARG(remote);
1007 0 2 if (!remote->transport) {
1017 0 0 GIT_ASSERT_ARG(remote);
1021 0 0 if (!remote->transport) {
1034 0 0 if ((error = git_config__lookup_entry(&ce, cfg, name, false)) < 0)
1037 0 0 if (ce && ce->value) {
0 0 if (ce && ce->value) {
1039 0 0 GIT_ERROR_CHECK_ALLOC(*out);
1052 0 0 if (url->path[len - 1] == '/') {
1055 0 0 while (len && url->path[len - 1] != '/')
0 0 while (len && url->path[len - 1] != '/')
1069 0 0 if ((error = git_net_url_dup(&lookup_url, url)) < 0)
1072 0 0 if (remote->repo) {
1073 0 0 if ((error = git_repository_config(&cfg, remote->repo)) < 0)
1076 0 0 if ((error = git_config_open_default(&cfg)) < 0)
1081 0 0 if (remote->name && remote->name[0]) {
0 0 if (remote->name && remote->name[0]) {
1084 0 0 if ((error = git_str_printf(&buf, "remote.%s.proxy", remote->name)) < 0 ||
0 0 if ((error = git_str_printf(&buf, "remote.%s.proxy", remote->name)) < 0 ||
1092 0 0 if ((error = git_str_puts(&buf, "http.")) < 0 ||
0 0 if ((error = git_str_puts(&buf, "http.")) < 0 ||
1093 0 0 (error = git_net_url_fmt(&buf, &lookup_url)) < 0 ||
1094 0 0 (error = git_str_puts(&buf, ".proxy")) < 0 ||
1098 0 0 if (! lookup_url.path[0])
1124 0 0 error = git__getenv(&proxy_env, use_ssl ? "https_proxy" : "http_proxy");
1127 0 0 if (error == GIT_ENOTFOUND)
1128 0 0 error = git__getenv(&proxy_env, use_ssl ? "HTTPS_PROXY" : "HTTP_PROXY");
1130 0 0 if (error)
1136 0 0 if (error == GIT_ENOTFOUND)
1139 0 0 if (error && error != GIT_ENOTFOUND)
0 0 if (error && error != GIT_ENOTFOUND)
1142 0 0 if (!git_net_url_matches_pattern_list(url, no_proxy_env.ptr))
1157 0 0 GIT_ASSERT_ARG(out);
1158 0 0 GIT_ASSERT_ARG(remote);
1167 0 0 if ((error = http_proxy_config(out, remote, url)) != GIT_ENOTFOUND ||
0 0 if ((error = http_proxy_config(out, remote, url)) != GIT_ENOTFOUND ||
1180 13 15 git_vector_foreach(refspecs, i, spec) {
1181 0 13 if (git_refspec__dwim_one(out, spec, refs) < 0)
1193 12 38 git_vector_foreach(vec, i, spec) {
1214 0 0 if (git_remote_ls((const git_remote_head ***)&heads, &heads_len, remote) < 0)
1217 0 0 if (git_vector_init(out, heads_len, remote_head_cmp) < 0)
1220 0 0 for (i = 0; i < heads_len; i++) {
1221 0 0 if (git_vector_insert(out, heads[i]) < 0)
1242 0 0 copy_opts(&tmp, fetch_opts);
1251 2 0 if (!git_remote_connected(remote)) {
1268 0 0 if (ls_to_vector(&refs, remote) < 0)
1271 0 0 if ((error = git_vector_init(&specs, 0, NULL)) < 0)
1275 0 0 if (!refspecs || !refspecs->count) {
0 0 if (!refspecs || !refspecs->count) {
1278 0 0 for (i = 0; i < refspecs->count; i++) {
1279 0 0 if ((error = add_refspec_to(&specs, refspecs->strings[i], true)) < 0)
1288 0 0 if ((error = dwim_refspecs(&remote->passive_refspecs, &remote->refspecs, &refs)) < 0)
1298 0 0 if (error < 0)
1301 0 0 if (remote->push) {
1306 0 0 if ((error = git_fetch_negotiate(remote, opts)) < 0)
1326 0 0 GIT_ASSERT_ARG(remote);
1328 0 0 if (!remote->repo) {
1333 0 0 if (connect_opts_from_fetch_opts(&connect_opts, remote, opts) < 0)
1336 0 0 if ((error = connect_or_reset_options(remote, GIT_DIRECTION_FETCH, &connect_opts)) < 0)
1354 0 0 GIT_ASSERT_ARG(remote);
1356 0 0 if (!remote->repo) {
1361 0 0 if (connect_opts_from_fetch_opts(&connect_opts, remote, opts) < 0)
1364 0 0 if ((error = connect_or_reset_options(remote, GIT_DIRECTION_FETCH, &connect_opts)) < 0)
1367 0 0 if (opts) {
1379 0 0 if (error != 0)
1383 0 0 if (reflog_message)
1386 0 0 git_str_printf(&reflog_msg_buf, "fetch %s",
1393 0 0 if (error < 0)
1396 0 0 if (opts && opts->prune == GIT_FETCH_PRUNE)
0 0 if (opts && opts->prune == GIT_FETCH_PRUNE)
1398 0 0 else if (opts && opts->prune == GIT_FETCH_PRUNE_UNSPECIFIED && remote->prune_refs)
0 0 else if (opts && opts->prune == GIT_FETCH_PRUNE_UNSPECIFIED && remote->prune_refs)
0 0 else if (opts && opts->prune == GIT_FETCH_PRUNE_UNSPECIFIED && remote->prune_refs)
1400 0 0 else if (opts && opts->prune == GIT_FETCH_NO_PRUNE)
0 0 else if (opts && opts->prune == GIT_FETCH_NO_PRUNE)
1405 0 0 if (prune)
1418 0 0 GIT_ASSERT_ARG(update_heads);
1419 0 0 GIT_ASSERT_ARG(fetchspec_src);
1423 0 0 git_vector_foreach(update_heads, i, remote_ref) {
1424 0 0 if (strcmp(remote_ref->name, fetchspec_src) == 0) {
1443 0 0 !git_remote_name(remote) ||
1444 0 0 (error = git_branch__upstream_remote(&upstream_remote, repo, ref_name) < 0) ||
1445 0 0 git__strcmp(git_remote_name(remote), git_str_cstr(&upstream_remote)) ||
1446 0 0 (error = git_branch__upstream_name(&upstream_name, repo, ref_name)) < 0 ||
1447 0 0 !git_refspec_dst_matches(spec, git_str_cstr(&upstream_name)) ||
1450 0 0 if (error == GIT_ENOTFOUND) {
1473 0 0 GIT_ASSERT_ARG(out);
1474 0 0 GIT_ASSERT_ARG(spec);
1475 0 0 GIT_ASSERT_ARG(ref);
1482 0 0 if (error == GIT_ENOTFOUND && git_reference_type(ref) == GIT_REFERENCE_SYMBOLIC) {
0 0 if (error == GIT_ENOTFOUND && git_reference_type(ref) == GIT_REFERENCE_SYMBOLIC) {
1494 0 0 if (!ref_name) {
1499 0 0 if ((error = ref_to_update(&update, &remote_name, remote, spec, ref_name)) < 0)
1502 0 0 if (update)
1522 0 0 GIT_ASSERT_ARG(remote);
1525 0 0 if (update_heads->length == 0)
1528 0 0 if (git_vector_init(&fetchhead_refs, update_heads->length, git_fetchhead_ref_cmp) < 0)
1535 0 0 if (git_refspec_is_wildcard(spec)) {
1536 0 0 if ((error = git_reference_lookup(&head_ref, remote->repo, GIT_HEAD_FILE)) < 0 ||
0 0 if ((error = git_reference_lookup(&head_ref, remote->repo, GIT_HEAD_FILE)) < 0 ||
1541 0 0 if ((error = remote_head_for_fetchspec_src(&merge_remote_ref, update_heads, git_refspec_src(spec))) < 0)
1546 0 0 git_vector_foreach(update_heads, i, remote_ref) {
1550 0 0 !git_refspec_src_matches(spec, remote_ref->name) &&
1554 0 0 if (git_fetchhead_ref_create(&fetchhead_ref,
1561 0 0 if (git_vector_insert(&fetchhead_refs, fetchhead_ref) < 0)
1568 0 0 for (i = 0; i < fetchhead_refs.length; ++i)
1587 0 0 if ((error = git_reference_list(&arr, remote->repo)) < 0)
1590 0 0 for (i = 0; i < arr.count; i++) {
1594 0 0 if (!git_remote__matching_dst_refspec(remote, refname))
1598 0 0 GIT_ERROR_CHECK_ALLOC(refname_dup);
1600 0 0 if ((error = git_vector_insert(candidates, refname_dup)) < 0)
1627 0 0 if (callbacks)
1628 0 0 GIT_ERROR_CHECK_VERSION(callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks");
1630 0 0 if ((error = ls_to_vector(&remote_refs, remote)) < 0)
1635 0 0 if ((error = prune_candidates(&candidates, remote)) < 0)
1642 0 0 git_vector_foreach(&candidates, i, refname) {
1643 0 0 git_vector_foreach(&remote->active_refspecs, j, spec) {
1649 0 0 if (!git_refspec_dst_matches(spec, refname))
1652 0 0 if ((error = git_refspec__rtransform(&buf, spec, refname)) < 0)
1659 0 0 if (error < 0 && error != GIT_ENOTFOUND)
0 0 if (error < 0 && error != GIT_ENOTFOUND)
1662 0 0 if (error == GIT_ENOTFOUND)
1666 0 0 if ((error = git_vector_set((void **) &src_name, &candidates, i, NULL)) < 0)
1680 0 0 git_vector_foreach(&candidates, i, refname) {
1684 0 0 if (refname == NULL)
1689 0 0 if (error == GIT_ENOTFOUND)
1692 0 0 if (error < 0)
1695 0 0 if (git_reference_type(ref) == GIT_REFERENCE_SYMBOLIC) {
1703 0 0 if (error < 0)
1706 0 0 if (callbacks && callbacks->update_tips)
0 0 if (callbacks && callbacks->update_tips)
1709 0 0 if (error < 0)
1732 0 0 if (error < 0 && error != GIT_ENOTFOUND)
0 0 if (error < 0 && error != GIT_ENOTFOUND)
1734 0 0 else if (error == 0 && git_oid_equal(&old_id, id))
0 0 else if (error == 0 && git_oid_equal(&old_id, id))
1738 0 0 if (error)
1745 0 0 if (error < 0)
1748 0 0 if (callbacks && callbacks->update_tips &&
0 0 if (callbacks && callbacks->update_tips &&
0 0 if (callbacks && callbacks->update_tips &&
1773 0 0 if ((error = git_repository_odb__weakptr(&odb, remote->repo)) < 0)
1777 0 0 if ((error = git_reference_name_is_valid(&valid, head->name)) < 0)
1780 0 0 if (!valid)
1784 0 0 if (git_refspec_src_matches(tagspec, head->name)) {
1785 0 0 if (tagopt == GIT_REMOTE_DOWNLOAD_TAGS_AUTO)
1788 0 0 if (tagopt != GIT_REMOTE_DOWNLOAD_TAGS_NONE) {
1789 0 0 if (git_str_puts(&refname, head->name) < 0)
1795 0 0 if (!autotag && git_refspec_src_matches(spec, head->name)) {
0 0 if (!autotag && git_refspec_src_matches(spec, head->name)) {
1796 0 0 if (spec->dst) {
1797 0 0 if ((error = git_refspec__transform(&refname, spec, head->name)) < 0)
1810 0 0 if (git_str_len(&refname) == 0)
1814 0 0 if (autotag && !git_odb_exists(odb, &head->oid))
0 0 if (autotag && !git_odb_exists(odb, &head->oid))
1817 0 0 if (!autotag && (error = git_vector_insert(update_heads, head)) < 0)
0 0 if (!autotag && (error = git_vector_insert(update_heads, head)) < 0)
1822 0 0 if (error < 0 && error != GIT_ENOTFOUND)
0 0 if (error < 0 && error != GIT_ENOTFOUND)
1825 0 0 if (!(error || error == GIT_ENOTFOUND) &&
0 0 if (!(error || error == GIT_ENOTFOUND) &&
0 0 if (!(error || error == GIT_ENOTFOUND) &&
1826 0 0 !spec->force &&
1832 0 0 if (error == GIT_ENOTFOUND) {
1836 0 0 if (autotag && (error = git_vector_insert(update_heads, head)) < 0)
0 0 if (autotag && (error = git_vector_insert(update_heads, head)) < 0)
1840 0 0 if (!git_oid__cmp(&old, &head->oid))
1847 0 0 if (error < 0) {
1848 0 0 if (error == GIT_EEXISTS)
1854 0 0 if (callbacks && callbacks->update_tips != NULL &&
0 0 if (callbacks && callbacks->update_tips != NULL &&
0 0 if (callbacks && callbacks->update_tips != NULL &&
1879 0 0 GIT_ASSERT_ARG(remote);
1881 0 0 if (git_refspec__parse(&tagspec, GIT_REFSPEC_TAGS, true) < 0)
1885 0 0 if (git_vector_init(&update_heads, 16, NULL) < 0)
1889 0 0 git_vector_foreach(refs, i, head) {
1890 0 0 if (update_one_tip(&update_heads, remote, spec, head, &tagspec, tagopt, log_message, callbacks) < 0)
1895 0 0 if (git_oid__is_hexstr(spec->src)) {
1898 0 0 if ((error = git_oid_fromstr(&id, spec->src)) < 0)
1901 0 0 if (spec->dst &&
0 0 if (spec->dst &&
1908 0 0 if ((error = git_vector_insert(&update_heads, &oid_head)) < 0)
1912 0 0 if (update_fetchhead &&
0 0 if (update_fetchhead &&
1951 0 0 for (; i < refs->length; i++) {
1954 0 0 if (git_reference_name_is_valid(&valid, head->name) < 0)
1957 0 0 if (!valid)
1960 0 0 for (; j < active->length; j++) {
1963 0 0 if (!git_refspec_src_matches(spec, head->name))
1966 0 0 for (; k < passive->length; k++) {
1969 0 0 if (!git_refspec_src_matches(passive_spec, head->name))
2003 0 0 while ((error = next_head(remote, refs, &spec, &head, &i, &j, &k)) == 0) {
2013 0 0 if ((error = git_refspec__transform(&refname, spec, head->name)) < 0 ||
0 0 if ((error = git_refspec__transform(&refname, spec, head->name)) < 0 ||
2018 0 0 if (error != GIT_ITEROVER)
2033 0 0 if ((error = git_str_joinpath(&path, gitdir, GIT_FETCH_HEAD_FILE)) < 0)
2056 0 0 if (remote->push) {
2060 0 0 if (git_refspec__parse(&tagspec, GIT_REFSPEC_TAGS, true) < 0)
2064 0 0 if ((error = ls_to_vector(&refs, remote)) < 0)
2067 0 0 if (download_tags == GIT_REMOTE_DOWNLOAD_TAGS_UNSPECIFIED)
2072 0 0 if ((error = truncate_fetch_head(git_repository_path(remote->repo))) < 0)
2075 0 0 if (tagopt == GIT_REMOTE_DOWNLOAD_TAGS_ALL) {
2076 0 0 if ((error = update_tips_for_spec(remote, callbacks, update_fetchhead, tagopt, &tagspec, &refs, reflog_message)) < 0)
2080 0 0 git_vector_foreach(&remote->active_refspecs, i, spec) {
2081 0 0 if (spec->push)
2084 0 0 if ((error = update_tips_for_spec(remote, callbacks, update_fetchhead, tagopt, spec, &refs, reflog_message)) < 0)
2089 0 0 if (remote->passed_refspecs)
2100 0 6 GIT_ASSERT_ARG(remote);
2102 4 2 if (!remote->transport || !remote->transport->is_connected)
0 4 if (!remote->transport || !remote->transport->is_connected)
2111 0 0 GIT_ASSERT_ARG(remote);
2113 0 0 if (remote->transport && remote->transport->cancel)
0 0 if (remote->transport && remote->transport->cancel)
2121 0 2 GIT_ASSERT_ARG(remote);
2123 2 0 if (git_remote_connected(remote))
2134 0 12 git_vector_foreach(heads, i, head) {
2142 4 12 if (remote == NULL)
2145 2 10 if (remote->transport != NULL) {
2182 7 3 if (!strcmp(&name[namelen - 4], ".url"))
2186 0 10 GIT_ERROR_CHECK_ALLOC(remote_name);
2197 0 3 if ((error = git_repository_config__weakptr(&cfg, repo)) < 0)
2200 0 3 if ((error = git_vector_init(&list, 4, git__strcmp_cb)) < 0)
2206 0 3 if (error < 0) {
2221 0 0 GIT_ASSERT_ARG_WITH_RETVAL(remote, NULL);
2236 0 0 GIT_ASSERT_ARG(repo && remote);
0 0 GIT_ASSERT_ARG(repo && remote);
2238 0 0 if ((error = ensure_remote_name_is_valid(remote)) < 0)
2241 0 0 if ((error = git_repository_config__weakptr(&config, repo)) < 0)
2244 0 0 if ((error = git_str_printf(&var, CONFIG_TAGOPT_FMT, remote)))
2256 0 0 if (error == GIT_ENOTFOUND)
2282 0 2 if (git_str_printf(&old_section_name, "remote.%s", old_name) < 0)
2289 1 1 error = git_config_rename_section(
2313 0 0 if (strcmp(entry->value, data->old_remote_name))
2328 0 1 if ((error = git_repository_config__weakptr(&data.config, repo)) < 0)
2351 0 0 if ((error = git_str_printf(&namespace, GIT_REFS_REMOTES_DIR "%s/", new_remote_name)) < 0)
2356 0 0 if ((error = git_str_puts(&new_name, git_reference_name(reference_in) + pfx_len)) < 0)
2359 0 0 if ((error = git_str_printf(&log_message,
2364 0 0 if ((error = git_reference_rename(&ref, reference_in, git_str_cstr(&new_name), 1,
2368 0 0 if (git_reference_type(ref) != GIT_REFERENCE_SYMBOLIC)
2373 0 0 if ((error = git_str_printf(&old_namespace, GIT_REFS_REMOTES_DIR "%s/", old_remote_name)) < 0)
2376 0 0 if (git__prefixcmp(target, old_namespace.ptr))
2381 0 0 if ((error = git_str_puts(&new_name, target + pfx_len)) < 0)
2409 0 1 if ((error = git_str_printf(&buf, GIT_REFS_REMOTES_DIR "%s/*", old_name)) < 0)
2415 0 1 if (error < 0)
2418 0 1 while ((error = git_reference_next(&ref, iter)) == 0) {
2419 0 0 if ((error = rename_one_remote_reference(ref, old_name, new_name)) < 0)
2425 0 1 return (error == GIT_ITEROVER) ? 0 : error;
2436 0 1 if ((error = git_repository_config__weakptr(&config, remote->repo)) < 0)
2439 0 1 if ((error = git_vector_init(problems, 1, NULL)) < 0)
2442 0 1 if ((error = default_fetchspec_for_name(&base, remote->name)) < 0)
2445 1 1 git_vector_foreach(&remote->refspecs, i, spec) {
2446 0 1 if (spec->push)
2450 0 1 if (strcmp(git_str_cstr(&base), spec->string)) {
2454 0 0 GIT_ERROR_CHECK_ALLOC(dup);
2456 0 0 if ((error = git_vector_insert(problems, dup)) < 0)
2474 0 1 if ((error = git_config_set_string(
2483 0 1 if (error < 0) {
2485 0 0 git_vector_foreach(problems, i, str)
2500 1 0 GIT_ASSERT_ARG(out && repo && name && new_name);
1 0 GIT_ASSERT_ARG(out && repo && name && new_name);
1 0 GIT_ASSERT_ARG(out && repo && name && new_name);
0 1 GIT_ASSERT_ARG(out && repo && name && new_name);
2502 0 1 if ((error = git_remote_lookup(&remote, repo, name)) < 0)
2505 0 1 if ((error = ensure_remote_name_is_valid(new_name)) < 0)
2508 0 1 if ((error = ensure_remote_doesnot_exist(repo, new_name)) < 0)
2511 0 1 if ((error = rename_remote_config_section(repo, name, new_name)) < 0)
2514 0 1 if ((error = update_branch_remote_config_entry(repo, name, new_name)) < 0)
2517 0 1 if ((error = rename_remote_references(repo, name, new_name)) < 0)
2520 0 1 if ((error = rename_fetch_refspecs(&problem_refspecs, remote, new_name)) < 0)
2527 0 1 if (error < 0)
2540 0 26 GIT_ASSERT(valid);
2544 26 0 if (!remote_name || *remote_name == '\0')
0 26 if (!remote_name || *remote_name == '\0')
2547 0 26 if ((error = git_str_printf(&buf, "refs/heads/test:refs/remotes/%s/test", remote_name)) < 0)
2552 26 0 if (!error)
2554 0 0 else if (error == GIT_EINVALIDSPEC)
2569 0 0 git_vector_foreach(&remote->active_refspecs, i, spec) {
2570 0 0 if (spec->push)
2573 0 0 if (git_refspec_src_matches(spec, refname))
2585 0 0 git_vector_foreach(&remote->active_refspecs, i, spec) {
2586 0 0 if (spec->push)
2589 0 0 if (git_refspec_dst_matches(spec, refname))
2613 0 0 if (git_vector_init(&refspecs, remote->refspecs.length, NULL) < 0)
2616 0 0 git_vector_foreach(&remote->refspecs, i, spec) {
2617 0 0 if (spec->push != push)
2620 0 0 if ((dup = git__strdup(spec->string)) == NULL)
2623 0 0 if (git_vector_insert(&refspecs, dup) < 0) {
2662 0 0 GIT_INIT_STRUCTURE_FROM_TEMPLATE(
2676 0 0 GIT_ASSERT_ARG_WITH_RETVAL(dot, NULL);
2692 0 1 if ((error = git_repository_config__weakptr(&config, repo)) < 0)
2695 0 1 if ((error = git_config_iterator_glob_new(&iter, config, "branch\\..+\\.remote")) < 0)
2699 0 1 while ((error = git_config_next(&entry, iter)) == 0) {
2703 0 0 if (strcmp(remote_name, entry->value))
2706 0 0 if ((branch = name_offset(&branch_len, entry->name)) == NULL) {
2712 0 0 if ((error = git_str_printf(&buf, "branch.%.*s.merge", (int)branch_len, branch)) < 0)
2715 0 0 if ((error = git_config_delete_entry(config, git_str_cstr(&buf))) < 0) {
2716 0 0 if (error != GIT_ENOTFOUND)
2722 0 0 if ((error = git_str_printf(&buf, "branch.%.*s.remote", (int)branch_len, branch)) < 0)
2725 0 0 if ((error = git_config_delete_entry(config, git_str_cstr(&buf))) < 0) {
2726 0 0 if (error != GIT_ENOTFOUND)
2732 1 0 if (error == GIT_ITEROVER)
2749 0 1 if ((error = git_vector_init(&refs, 8, NULL)) < 0)
2752 0 1 if ((error = git_reference_iterator_new(&iter, repo)) < 0)
2755 2 1 while ((error = git_reference_next_name(&name, iter)) == 0) {
2756 2 0 if (!git_refspec_dst_matches(spec, name))
2760 0 0 if (!dup) {
2765 0 0 if ((error = git_vector_insert(&refs, dup)) < 0)
2768 1 0 if (error == GIT_ITEROVER)
2770 0 1 if (error < 0)
2773 0 1 git_vector_foreach(&refs, i, name) {
2774 0 0 if ((error = git_reference_remove(repo, name)) < 0)
2780 0 1 git_vector_foreach(&refs, i, dup) {
2794 0 1 if ((error = git_remote_lookup(&remote, repo, remote_name)) < 0)
2798 1 1 for (i = 0; i < count; i++) {
2802 0 1 if (refspec == NULL)
2805 0 1 if ((error = remove_refs(repo, refspec)) < 0)
2817 0 1 GIT_ASSERT_ARG(repo);
2818 0 1 GIT_ASSERT_ARG(name);
2820 1 0 if ((error = remove_branch_config_related_entries(repo, name)) < 0 ||
1 0 if ((error = remove_branch_config_related_entries(repo, name)) < 0 ||
2821 0 1 (error = remove_remote_tracking(repo, name)) < 0 ||
2830 0 0 GIT_BUF_WRAP_PRIVATE(out, git_remote__default_branch, remote);
0 0 GIT_BUF_WRAP_PRIVATE(out, git_remote__default_branch, remote);
2842 0 0 GIT_ASSERT_ARG(out);
2844 0 0 if ((error = git_remote_ls(&heads, &heads_len, remote)) < 0)
2847 0 0 if (heads_len == 0 || strcmp(heads[0]->name, GIT_HEAD_FILE)) {
0 0 if (heads_len == 0 || strcmp(heads[0]->name, GIT_HEAD_FILE)) {
2853 0 0 if (heads[0]->symref_target) {
2864 0 0 if ((error = git_repository_initialbranch(&local_default, remote->repo)) < 0)
2869 0 0 for (i = 1; i < heads_len; i++) {
2870 0 0 if (git_oid_cmp(head_id, &heads[i]->oid))
2873 0 0 if (git__prefixcmp(heads[i]->name, GIT_REFS_HEADS_DIR))
2876 0 0 if (!guess) {
2881 0 0 if (!git__strcmp(local_default.ptr, heads[i]->name)) {
2887 0 0 if (!guess) {
2905 2 0 copy_opts(&tmp, push_opts);
2920 0 2 GIT_ASSERT_ARG(remote);
2922 0 2 if (!remote->repo) {
2927 0 2 if ((error = connect_opts_from_push_opts(&connect_opts, remote, opts)) < 0)
2930 0 2 if ((error = connect_or_reset_options(remote, GIT_DIRECTION_PUSH, &connect_opts)) < 0)
2934 0 2 if ((error = dwim_refspecs(&remote->active_refspecs, &remote->refspecs, &remote->refs)) < 0)
2937 0 2 if (remote->push) {
2942 0 2 if ((error = git_push_new(&remote->push, remote, opts)) < 0)
2947 2 0 if (refspecs && refspecs->count > 0) {
2 0 if (refspecs && refspecs->count > 0) {
2948 2 2 for (i = 0; i < refspecs->count; i++) {
2949 0 2 if ((error = git_push_add_refspec(push, refspecs->strings[i])) < 0)
2953 0 0 git_vector_foreach(&remote->refspecs, i, spec) {
2954 0 0 if (!spec->push)
2956 0 0 if ((error = git_push_add_refspec(push, spec->string)) < 0)
2961 0 2 if ((error = git_push_finish(push)) < 0)
2964 1 1 if (connect_opts.callbacks.push_update_reference &&
0 1 if (connect_opts.callbacks.push_update_reference &&
2981 0 0 GIT_ASSERT_ARG(remote);
2983 0 0 if (!remote->repo) {
2988 0 0 if (connect_opts_from_push_opts(&connect_opts, remote, opts) < 0)
2991 0 0 if ((error = git_remote_upload(remote, refspecs, opts)) < 0)
3016 0 33 GIT_ASSERT_ARG(out);
3017 0 33 GIT_ASSERT_ARG(config);
3018 0 33 GIT_ASSERT_ARG(url);
3019 15 18 GIT_ASSERT_ARG(direction == GIT_DIRECTION_FETCH || direction == GIT_DIRECTION_PUSH);
0 15 GIT_ASSERT_ARG(direction == GIT_DIRECTION_FETCH || direction == GIT_DIRECTION_PUSH);
3023 18 15 if (direction == GIT_DIRECTION_FETCH) {
3031 0 33 if (git_config_iterator_glob_new(&iter, config, regexp) < 0)
3035 0 33 while (git_config_next(&entry, iter) == 0) {
3039 0 0 if (git__prefixcmp(url, entry->value))
3044 0 0 if ((n = strlen(entry->value)) <= match_length)
3059 33 0 if (match_length == 0 && use_default_if_empty) {
18 15 if (match_length == 0 && use_default_if_empty) {
3061 18 0 return *out ? 0 : -1;
3062 15 0 } else if (match_length == 0) {