Branch Coverage

deps/libgit2/src/refs.c
Criterion Covered Total %
branch 244 450 54.2


line true false branch
40 0 1270 if (!GIT_ADD_SIZET_OVERFLOW(&reflen, sizeof(git_reference), namelen) &&
1270 0 if (!GIT_ADD_SIZET_OVERFLOW(&reflen, sizeof(git_reference), namelen) &&
41 1270 0 !GIT_ADD_SIZET_OVERFLOW(&reflen, reflen, 1) &&
53 507 0 assert(name && target);
0 507 assert(name && target);
56 0 507 if (!ref)
61 0 507 if ((ref->target.symbolic = git__strdup(target)) == NULL) {
76 763 0 assert(name && oid);
0 763 assert(name && oid);
79 0 763 if (!ref)
85 0 763 if (peel != NULL)
97 1 0 assert(ptr_to_ref && name);
0 1 assert(ptr_to_ref && name);
101 0 1 if (!GIT_ADD_SIZET_OVERFLOW(&reflen, sizeof(git_reference), namelen) &&
1 0 if (!GIT_ADD_SIZET_OVERFLOW(&reflen, sizeof(git_reference), namelen) &&
102 1 0 !GIT_ADD_SIZET_OVERFLOW(&reflen, reflen, 1) &&
113 0 0 if (source->type == GIT_REFERENCE_SYMBOLIC)
118 0 0 GIT_ERROR_CHECK_ALLOC(*dest);
128 1547 1264 if (reference == NULL)
131 505 759 if (reference->type == GIT_REFERENCE_SYMBOLIC)
134 1155 109 if (reference->db)
135 1 1154 GIT_REFCOUNT_DEC(reference->db, git_refdb__free);
1 0 GIT_REFCOUNT_DEC(reference->db, git_refdb__free);
145 0 6 if (!strcmp(ref->name, "HEAD")) {
150 4 2 if (ref->type == GIT_REFERENCE_DIRECT)
163 0 0 if ((error = git_repository_refdb__weakptr(&db, repo)) < 0)
181 30 143 if ((error = git_reference_lookup_resolved(&ref, repo, name, -1)) < 0)
198 1114 0 if (!git_repository__configmap_lookup(&precompose, repo, GIT_CONFIGMAP_PRECOMPOSE) &&
0 1114 if (!git_repository__configmap_lookup(&precompose, repo, GIT_CONFIGMAP_PRECOMPOSE) &&
202 0 1114 if (!validate)
218 991 0 assert(ref_out && repo && name);
991 0 assert(ref_out && repo && name);
0 991 assert(ref_out && repo && name);
220 981 10 if ((error = reference_normalize_for_repo(normalized, repo, name, true)) < 0 ||
981 0 if ((error = reference_normalize_for_repo(normalized, repo, name, true)) < 0 ||
221 125 856 (error = git_repository_refdb__weakptr(&refdb, repo)) < 0 ||
231 434 422 if (max_nesting && git_reference_type(*ref_out) == GIT_REFERENCE_SYMBOLIC) {
3 431 if (max_nesting && git_reference_type(*ref_out) == GIT_REFERENCE_SYMBOLIC) {
257 28 1 if (*refname)
264 107 12 for (i = 0; formatters[i] && (fallbackmode || i == 0); i++) {
106 1 for (i = 0; formatters[i] && (fallbackmode || i == 0); i++) {
1 0 for (i = 0; formatters[i] && (fallbackmode || i == 0); i++) {
268 0 107 if ((error = git_buf_printf(&refnamebuf, formatters[i], git_buf_cstr(&name))) < 0)
271 16 91 if (!git_reference_is_valid_name(git_buf_cstr(&refnamebuf))) {
279 17 74 if (!error) {
285 0 74 if (error != GIT_ENOTFOUND)
290 12 17 if (error && !foundvalid) {
0 12 if (error && !foundvalid) {
296 12 17 if (error == GIT_ENOTFOUND)
309 0 992 assert(ref);
315 0 207 assert(ref);
321 0 338 assert(ref);
327 0 381 assert(ref);
329 0 381 if (ref->type != GIT_REFERENCE_DIRECT)
337 0 0 assert(ref);
339 0 0 if (ref->type != GIT_REFERENCE_DIRECT || git_oid_is_zero(&ref->peel))
0 0 if (ref->type != GIT_REFERENCE_DIRECT || git_oid_is_zero(&ref->peel))
347 0 424 assert(ref);
349 0 424 if (ref->type != GIT_REFERENCE_SYMBOLIC)
372 99 0 assert(repo && name);
0 99 assert(repo && name);
373 76 23 assert(symbolic || signature);
0 76 assert(symbolic || signature);
375 97 2 if (ref_out)
379 0 99 if (error < 0)
383 0 99 if (error < 0)
386 76 23 if (oid != NULL) {
387 0 76 assert(symbolic == NULL);
389 0 76 if (!git_object__is_valid(repo, oid, GIT_OBJECT_ANY)) {
402 0 23 if (error < 0)
408 0 99 GIT_ERROR_CHECK_ALLOC(ref);
410 2 97 if ((error = git_refdb_write(refdb, ref, force, signature, log_message, old_id, old_target)) < 0) {
415 2 95 if (ref_out == NULL)
425 0 69 if (repo->ident_name && repo->ident_email)
0 0 if (repo->ident_name && repo->ident_email)
437 69 0 if(((error = refs_configured_ident(&who, repo)) < 0) &&
7 62 if(((error = refs_configured_ident(&who, repo)) < 0) &&
438 0 7 ((error = git_signature_default(&who, repo)) < 0) &&
459 0 41 assert(id);
461 0 41 if ((error = git_reference__log_signature(&who, repo)) < 0)
494 0 23 assert(target);
496 0 23 if ((error = git_reference__log_signature(&who, repo)) < 0)
519 27 0 if (ref->type == GIT_REFERENCE_DIRECT)
535 1 0 assert(out && ref && id);
1 0 assert(out && ref && id);
0 1 assert(out && ref && id);
539 0 1 if ((error = ensure_is_an_updatable_direct_reference(ref)) < 0)
547 0 0 if (ref->type == GIT_REFERENCE_SYMBOLIC)
562 0 0 assert(out && ref && target);
0 0 assert(out && ref && target);
0 0 assert(out && ref && target);
564 0 0 if ((error = ensure_is_an_updatable_symbolic_reference(ref)) < 0)
582 0 1 if ((error = git_reference_lookup(&head, worktree, GIT_HEAD_FILE)) < 0)
590 0 0 if ((error = git_reference_symbolic_set_target(&updated, head, payload->new_name, NULL)) < 0) {
613 1 0 assert(out && ref);
0 1 assert(out && ref);
617 1 0 if ((error = git_reference__log_signature(&signature, repo)) < 0 ||
1 0 if ((error = git_reference__log_signature(&signature, repo)) < 0 ||
618 1 0 (error = reference_normalize_for_repo(payload.new_name, repo, new_name, true)) < 0 ||
625 0 1 if ((error = git_repository_foreach_worktree(repo, refs_update_head, &payload)) < 0)
657 0 0 if ((error = git_reference_iterator_new(&iter, repo)) < 0)
660 0 0 while (!(error = git_reference_next(&ref, iter))) {
661 0 0 if ((error = callback(ref, payload)) != 0) {
667 0 0 if (error == GIT_ITEROVER)
683 0 23 if ((error = git_reference_iterator_new(&iter, repo)) < 0)
686 115 22 while (!(error = git_reference_next_name(&refname, iter))) {
687 1 114 if ((error = callback(refname, payload)) != 0) {
693 22 1 if (error == GIT_ITEROVER)
710 0 0 if ((error = git_reference_iterator_glob_new(&iter, repo, glob)) < 0)
713 0 0 while (!(error = git_reference_next_name(&refname, iter))) {
714 0 0 if ((error = callback(refname, payload)) != 0) {
720 0 0 if (error == GIT_ITEROVER)
731 0 29 if (git_repository_refdb__weakptr(&refdb, repo) < 0)
742 0 3 if (git_repository_refdb__weakptr(&refdb, repo) < 0)
760 0 32 if (iter == NULL)
769 0 2 GIT_ERROR_CHECK_ALLOC(name);
779 4 0 assert(array && repo);
0 4 assert(array && repo);
784 0 4 if (git_vector_init(&ref_list, 8, NULL) < 0)
787 0 4 if (git_reference_foreach_name(
800 0 16889 if ((unsigned) ch <= ' ')
803 0 16889 switch (ch) {
823 0 2977 if (*current == '.')
827 18556 1310 if (*current == '\0' || *current == '/')
16889 1667 if (*current == '\0' || *current == '/')
830 0 16889 if (!is_valid_ref_char(*current))
833 36 16853 if (prev == '.' && *current == '.')
0 36 if (prev == '.' && *current == '.')
836 0 16889 if (prev == '@' && *current == '{')
0 0 if (prev == '@' && *current == '{')
839 26 16863 if (*current == '*') {
840 0 26 if (!may_contain_glob)
851 1406 1571 if (segment_len >= lock_len &&
0 1406 if (segment_len >= lock_len &&
863 1310 0 assert(name && len > 0);
0 1310 assert(name && len > 0);
865 2705 465 for (i = 0; i < len; i++)
868 2705 0 if ((c < 'A' || c > 'Z') && c != '_')
845 1860 if ((c < 'A' || c > 'Z') && c != '_')
845 0 if ((c < 'A' || c > 'Z') && c != '_')
872 465 0 if (*name == '_' || name[len - 1] == '_')
0 465 if (*name == '_' || name[len - 1] == '_')
894 0 1310 assert(name);
899 1310 0 if (validate && *current == '/')
0 1310 if (validate && *current == '/')
902 1115 195 if (normalize)
915 0 1310 if (!validate) {
918 0 0 error = git_buf_oom(buf) ? -1 : 0;
926 0 2977 if (segment_len < 0)
929 2977 0 if (segment_len > 0) {
934 26 2951 if (memchr(current, '*', segment_len))
937 2389 588 if (normalize) {
941 1274 1115 git_buf_truncate(buf,
944 0 2389 if (git_buf_oom(buf)) {
954 0 2977 if (segment_len == 0 && !normalize)
0 0 if (segment_len == 0 && !normalize)
957 1310 1667 if (current[segment_len] == '\0')
964 0 1310 if (segment_len == 0 && segments_count == 0)
0 0 if (segment_len == 0 && segments_count == 0)
968 0 1310 if (current[segment_len - 1] == '.')
972 0 1310 if (current[segment_len - 1] == '/')
975 491 819 if ((segments_count == 1 ) && !(flags & GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL))
0 491 if ((segments_count == 1 ) && !(flags & GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL))
978 491 819 if ((segments_count == 1 ) &&
491 0 if ((segments_count == 1 ) &&
979 26 465 !(flags & GIT_REFERENCE_FORMAT_REFSPEC_SHORTHAND) &&
980 0 26 !(is_all_caps_and_underscore(name, (size_t)segment_len) ||
981 0 0 ((flags & GIT_REFERENCE_FORMAT_REFSPEC_PATTERN) && !strcmp("*", name))))
984 819 465 if ((segments_count > 1)
985 0 819 && (is_all_caps_and_underscore(name, strchr(name, '/') - name)))
991 26 1284 if (error == GIT_EINVALIDSPEC)
996 26 1284 if (error && normalize)
10 16 if (error && normalize)
1015 10 1104 if ((error = git_reference__normalize_name(&buf, name, flags)) < 0)
1018 0 1104 if (git_buf_len(&buf) > buffer_size - 1) {
1042 0 0 assert(ref1 && ref2);
0 0 assert(ref1 && ref2);
1048 0 0 if (type1 != type2)
1049 0 0 return (type1 == GIT_REFERENCE_SYMBOLIC) ? -1 : 1;
1051 0 0 if (type1 == GIT_REFERENCE_SYMBOLIC)
1075 2 7 if (!sig && (error = git_reference__log_signature(&who, repo)) < 0)
0 2 if (!sig && (error = git_reference__log_signature(&who, repo)) < 0)
1078 7 2 to_use = sig ? sig : who;
1080 0 9 if ((error = git_repository_refdb__weakptr(&refdb, repo)) < 0)
1083 1 8 if ((error = git_refdb_resolve(&ref, refdb, ref_name, -1)) < 0) {
1084 1 0 if (error == GIT_ENOTFOUND) {
1093 3 5 if (git_reference_type(ref) == GIT_REFERENCE_SYMBOLIC) {
1112 1 32 if (count >= 2)
1114 4 28 else if (count == 0)
1133 33 0 if ((error = git_commit_lookup(&commit, repo, id)) < 0 ||
33 0 if ((error = git_commit_lookup(&commit, repo, id)) < 0 ||
1134 33 0 (error = git_buf_printf(&reflog_msg, "%s%s: %s",
1142 26 7 if (ref) {
1143 0 26 if ((error = ensure_is_an_updatable_direct_reference(ref)) < 0)
1165 0 0 assert(repo && refname);
0 0 assert(repo && refname);
1167 0 0 if ((error = git_repository_refdb__weakptr(&refdb, repo)) < 0)
1178 6 0 assert(repo && refname);
0 6 assert(repo && refname);
1180 0 6 if ((error = git_repository_refdb__weakptr(&refdb, repo)) < 0)
1193 0 64 assert(ref);
1204 0 7 assert(ref);
1215 0 7 assert(ref);
1226 0 7 assert(ref);
1248 0 210 assert(ref);
1250 200 10 if (ref->type == GIT_REFERENCE_DIRECT) {
1253 0 10 if ((error = git_reference_resolve(&allocated, ref)) < 0)
1265 210 0 if (target_type != GIT_OBJECT_TAG && !git_oid_is_zero(&resolved->peel)) {
0 210 if (target_type != GIT_OBJECT_TAG && !git_oid_is_zero(&resolved->peel)) {
1273 0 210 if (error < 0) {
1278 0 210 if (target_type == GIT_OBJECT_ANY && git_object_type(target) != GIT_OBJECT_TAG)
0 0 if (target_type == GIT_OBJECT_ANY && git_object_type(target) != GIT_OBJECT_TAG)
1292 16 179 if (git_reference__normalize_name(NULL, refname, flags) < 0) {
1307 41 1 if (!git__prefixcmp(name, GIT_REFS_HEADS_DIR))
1309 0 1 else if (!git__prefixcmp(name, GIT_REFS_TAGS_DIR))
1311 0 1 else if (!git__prefixcmp(name, GIT_REFS_REMOTES_DIR))
1313 1 0 else if (!git__prefixcmp(name, GIT_REFS_DIR))
1329 5 0 assert(unborn && ref && repo);
5 0 assert(unborn && ref && repo);
0 5 assert(unborn && ref && repo);
1331 0 5 if (ref->type == GIT_REFERENCE_DIRECT) {
1339 0 5 if (error != 0 && error != GIT_ENOTFOUND)
0 0 if (error != 0 && error != GIT_ENOTFOUND)
1341 0 5 else if (error == GIT_ENOTFOUND && git__strcmp(ref->name, GIT_HEAD_FILE) == 0)
0 0 else if (error == GIT_ENOTFOUND && git__strcmp(ref->name, GIT_HEAD_FILE) == 0)