Branch Coverage

deps/libgit2/src/revparse.c
Criterion Covered Total %
branch 89 306 29.0


line true false branch
21 1 8 if (git_oid_fromstrn(&oid, spec, speclen) < 0)
31 16 8 if (speclen != GIT_OID_HEXSZ)
48 0 0 if (*pattern == '\0') {
54 0 0 if (!error)
70 2 0 if (substr == NULL)
73 0 0 if (build_regex(®ex, ".+-[0-9]+-g[0-9a-fA-F]+") < 0)
79 0 0 if (error)
94 8 16 if ((error = maybe_sha(object_out, repo, spec)) != GIT_ENOTFOUND)
98 14 2 if (!error) {
103 14 0 if (!error)
109 0 2 if (error != GIT_ENOTFOUND)
112 1 1 if ((strlen(spec) < GIT_OID_HEXSZ) &&
0 1 if ((strlen(spec) < GIT_OID_HEXSZ) &&
116 0 2 if ((error = maybe_describe(object_out, repo, spec)) != GIT_ENOTFOUND)
128 0 2 if (git__strntol32(&content, curly_braces_content, strlen(curly_braces_content),
132 0 2 if (*end_ptr != '\0')
152 0 0 if (*identifier != '\0' || *base_ref != NULL)
0 0 if (*identifier != '\0' || *base_ref != NULL)
155 0 0 if (build_regex(&preg, "checkout: moving from (.*) to .*") < 0)
158 0 0 if (git_reference_lookup(&ref, repo, GIT_HEAD_FILE) < 0)
161 0 0 if (git_reflog_read(&reflog, repo, GIT_HEAD_FILE) < 0)
166 0 0 for (i = 0; i < numentries; i++) {
171 0 0 if (!msg)
174 0 0 if (git_regexp_search(&preg, msg, 2, regexmatches) < 0)
179 0 0 if (cur > 0)
182 0 0 if ((git_buf_put(&buf, msg+regexmatches[1].start, regexmatches[1].end - regexmatches[1].start)) < 0)
185 0 0 if ((error = git_reference_dwim(base_ref, repo, git_buf_cstr(&buf))) == 0)
188 0 0 if (error < 0 && error != GIT_ENOTFOUND)
0 0 if (error < 0 && error != GIT_ENOTFOUND)
213 0 2 if (git_reflog_read(&reflog, git_reference_owner(ref), git_reference_name(ref)) < 0)
218 2 0 if (search_by_pos) {
219 0 2 if (numentries < identifier + 1)
228 0 0 for (i = 0; i < numentries; i++) {
232 0 0 if (commit_time.time > (git_time_t)identifier)
239 0 0 if (i == numentries)
262 2 0 if (*base_ref == NULL) {
263 0 2 if ((error = git_reference_dwim(&ref, repo, identifier)) < 0)
270 0 2 if (position == 0) {
275 0 2 if ((error = retrieve_oid_from_reflog(&oid, ref, position)) < 0)
290 0 0 if (*base_ref == NULL) {
291 0 0 if ((error = git_reference_dwim(&ref, repo, identifier)) < 0)
298 0 0 if (!git_reference_is_branch(ref)) {
303 0 0 if ((error = git_branch_upstream(&tracking, ref)) < 0)
320 0 2 assert(*out == NULL);
322 0 2 if (git_buf_put(&identifier, spec, identifier_len) < 0)
327 0 2 if (*curly_braces_content == '-' && (!is_numeric || parsed == 0)) {
0 0 if (*curly_braces_content == '-' && (!is_numeric || parsed == 0)) {
0 0 if (*curly_braces_content == '-' && (!is_numeric || parsed == 0)) {
332 2 0 if (is_numeric) {
333 0 2 if (parsed < 0)
341 0 0 if (!strcmp(curly_braces_content, "u") || !strcmp(curly_braces_content, "upstream")) {
0 0 if (!strcmp(curly_braces_content, "u") || !strcmp(curly_braces_content, "upstream")) {
347 0 0 if (git__date_parse(×tamp, curly_braces_content) < 0)
359 0 0 if (!strcmp(str, "commit"))
362 0 0 if (!strcmp(str, "tree"))
365 0 0 if (!strcmp(str, "blob"))
368 0 0 if (!strcmp(str, "tag"))
376 0 0 if (git_object_type(obj) == GIT_OBJECT_TAG)
387 0 0 if ((error = git_object_peel(&temp_commit, obj, GIT_OBJECT_COMMIT)) < 0)
388 0 0 return (error == GIT_EAMBIGUOUS || error == GIT_ENOTFOUND) ?
389 0 0 GIT_EINVALIDSPEC : error;
391 0 0 if (n == 0) {
407 0 4 if ((error = git_object_peel(&temp_commit, obj, GIT_OBJECT_COMMIT)) < 0)
408 0 0 return (error == GIT_EAMBIGUOUS || error == GIT_ENOTFOUND) ?
409 0 0 GIT_EINVALIDSPEC : error;
426 0 0 if ((error = git_object_peel(&tree, obj, GIT_OBJECT_TREE)) < 0)
427 0 0 return error == GIT_ENOTFOUND ? GIT_EINVALIDSPEC : error;
429 0 0 if (*path == '\0') {
438 0 0 if ((error = git_tree_entry_bypath(&entry, (git_tree *)tree, path)) < 0)
456 0 0 while (!(error = git_revwalk_next(&oid, walk))) {
459 0 0 if ((error < 0) && (error != GIT_ENOTFOUND))
0 0 if ((error < 0) && (error != GIT_ENOTFOUND))
462 0 0 if (!git_regexp_match(regex, git_commit_message((git_commit*)obj))) {
470 0 0 if (error < 0 && error == GIT_ITEROVER)
0 0 if (error < 0 && error == GIT_ITEROVER)
482 0 0 if ((error = build_regex(&preg, pattern)) < 0)
485 0 0 if ((error = git_revwalk_new(&walk, repo)) < 0)
490 0 0 if (spec_oid == NULL) {
491 0 0 if ((error = git_revwalk_push_glob(walk, "refs/*")) < 0)
493 0 0 } else if ((error = git_revwalk_push(walk, spec_oid)) < 0)
509 0 0 if (*curly_braces_content == '\0')
512 0 0 if (*curly_braces_content == '/')
517 0 0 if (expected_type == GIT_OBJECT_INVALID)
527 2 0 assert(spec[*pos] == '^' || spec[*pos] == '@');
0 2 assert(spec[*pos] == '^' || spec[*pos] == '@');
531 2 0 if (spec[*pos] == '\0' || spec[*pos] != '{')
0 2 if (spec[*pos] == '\0' || spec[*pos] != '{')
536 2 2 while (spec[*pos] != '}') {
537 0 2 if (spec[*pos] == '\0')
540 0 2 if (git_buf_putc(buf, spec[(*pos)++]) < 0)
553 0 0 assert(spec[*pos] == ':');
557 0 0 if (git_buf_puts(buf, spec + *pos) < 0)
571 4 0 assert(spec[*pos] == '^' || spec[*pos] == '~');
0 4 assert(spec[*pos] == '^' || spec[*pos] == '~');
579 0 4 } while (spec[(*pos)] == kind && kind == '~');
0 0 } while (spec[(*pos)] == kind && kind == '~');
581 0 4 if (git__isdigit(spec[*pos])) {
582 0 0 if (git__strntol32(&parsed, spec + *pos, strlen(spec + *pos), &end_ptr, 10) < 0)
589 0 4 } while (spec[(*pos)] == kind && kind == '~');
0 0 } while (spec[(*pos)] == kind && kind == '~');
601 0 0 if (git_reference_resolve(&resolved, reference) < 0)
615 6 24 if (*object != NULL)
618 0 24 if (*reference != NULL)
621 24 0 if (!allow_empty_identifier && identifier_len == 0)
0 24 if (!allow_empty_identifier && identifier_len == 0)
624 0 24 if (git_buf_put(&identifier, spec, identifier_len) < 0)
635 510 0 if (object == NULL)
643 0 0 if (object != NULL)
646 0 0 if (reference != NULL)
649 0 0 if (identifier_len > 0)
657 508 0 if (!ensure_base_rev_is_not_known_yet(object) && reference == NULL)
508 0 if (!ensure_base_rev_is_not_known_yet(object) && reference == NULL)
679 26 0 assert(object_out && reference_out && repo && spec);
26 0 assert(object_out && reference_out && repo && spec);
26 0 assert(object_out && reference_out && repo && spec);
0 26 assert(object_out && reference_out && repo && spec);
684 514 26 while (spec[pos]) {
689 0 0 if ((error = ensure_base_rev_loaded(&base_rev, &reference, spec, identifier_len, repo, false)) < 0)
692 0 0 if (spec[pos+1] == '{') {
695 0 0 if ((error = extract_curly_braces_content(&buf, spec, &pos)) < 0)
698 0 0 if ((error = handle_caret_curly_syntax(&temp_object, base_rev, git_buf_cstr(&buf))) < 0)
706 0 0 if ((error = extract_how_many(&n, spec, &pos)) < 0)
709 0 0 if ((error = handle_caret_parent_syntax(&temp_object, base_rev, n)) < 0)
723 0 4 if ((error = extract_how_many(&n, spec, &pos)) < 0)
726 0 4 if ((error = ensure_base_rev_loaded(&base_rev, &reference, spec, identifier_len, repo, false)) < 0)
729 0 4 if ((error = handle_linear_syntax(&temp_object, base_rev, n)) < 0)
743 0 0 if ((error = extract_path(&buf, spec, &pos)) < 0)
746 0 0 if (any_left_hand_identifier(base_rev, reference, identifier_len)) {
747 0 0 if ((error = ensure_base_rev_loaded(&base_rev, &reference, spec, identifier_len, repo, true)) < 0)
750 0 0 if ((error = handle_colon_syntax(&temp_object, base_rev, git_buf_cstr(&buf))) < 0)
753 0 0 if (*git_buf_cstr(&buf) == '/') {
754 0 0 if ((error = handle_grep_syntax(&temp_object, repo, NULL, git_buf_cstr(&buf) + 1)) < 0)
774 2 0 if (spec[pos+1] == '{') {
777 0 2 if ((error = extract_curly_braces_content(&buf, spec, &pos)) < 0)
780 0 2 if ((error = ensure_base_rev_is_not_known_yet(base_rev)) < 0)
783 0 2 if ((error = handle_at_syntax(&temp_object, &reference, spec, identifier_len, repo, git_buf_cstr(&buf))) < 0)
786 2 0 if (temp_object != NULL)
793 0 508 if ((error = ensure_left_hand_identifier_is_not_known_yet(base_rev, reference)) < 0)
801 2 24 if ((error = ensure_base_rev_loaded(&base_rev, &reference, spec, identifier_len, repo, false)) < 0)
804 4 20 if (!should_return_reference) {
815 2 24 if (error) {
816 0 2 if (error == GIT_EINVALIDSPEC)
839 2 24 if ((error = revparse(&obj, &ref, &identifier_len, repo, spec)) < 0)
862 2 24 if ((error = git_revparse_ext(&obj, &ref, repo, spec)) < 0)
885 16 0 assert(revspec && repo && spec);
16 0 assert(revspec && repo && spec);
0 16 assert(revspec && repo && spec);
889 8 8 if ((dotdot = strstr(spec, "..")) != NULL) {
900 0 8 if (!git__strcmp(spec, "..")) {
907 2 6 if (dotdot[2] == '.') {
912 8 0 error = git_revparse_single(
917 8 0 if (!error) {
918 8 0 error = git_revparse_single(