Branch Coverage

deps/libgit2/src/libgit2/commit.c
Criterion Covered Total %
branch 130 364 35.7


line true false branch
56 0 57 GIT_ASSERT_ARG(out);
57 0 57 GIT_ASSERT_ARG(tree);
61 54 57 for (i = 0; i < git_array_size(*parents); i++) {
62 54 0 parent = git_array_get(*parents, i);
69 0 57 if (message_encoding != NULL)
74 0 57 if (git_str_puts(out, message) < 0)
93 0 57 if (validate && !git_object__is_valid(repo, tree, GIT_OBJECT_TREE))
0 0 if (validate && !git_object__is_valid(repo, tree, GIT_OBJECT_TREE))
97 54 57 while ((parent = parent_cb(i, parent_payload)) != NULL) {
98 0 54 if (validate && !git_object__is_valid(repo, parent, GIT_OBJECT_COMMIT)) {
0 0 if (validate && !git_object__is_valid(repo, parent, GIT_OBJECT_COMMIT)) {
103 45 9 parent_cpy = git_array_alloc(*parents);
45 0 parent_cpy = git_array_alloc(*parents);
104 0 54 GIT_ERROR_CHECK_ALLOC(parent_cpy);
110 26 31 if (current_id && (parents->size == 0 || git_oid_cmp(current_id, git_array_get(*parents, 0)))) {
26 0 if (current_id && (parents->size == 0 || git_oid_cmp(current_id, git_array_get(*parents, 0)))) {
26 0 if (current_id && (parents->size == 0 || git_oid_cmp(current_id, git_array_get(*parents, 0)))) {
0 26 if (current_id && (parents->size == 0 || git_oid_cmp(current_id, git_array_get(*parents, 0)))) {
143 30 27 if (update_ref) {
145 4 26 if (error < 0 && error != GIT_ENOTFOUND)
0 4 if (error < 0 && error != GIT_ENOTFOUND)
150 26 31 if (ref)
153 0 57 if ((error = validate_tree_and_parents(&parents, repo, tree, parent_cb, parent_payload, current_id, validate)) < 0)
160 0 57 if (error < 0)
163 0 57 if (git_repository_odb__weakptr(&odb, repo) < 0)
166 0 57 if (git_odb__freshen(odb, tree) < 0)
169 0 57 if (git_odb_write(id, odb, buf.ptr, buf.size, GIT_OBJECT_COMMIT) < 0)
173 30 27 if (update_ref != NULL) {
212 0 0 if (curr >= data->total)
214 0 0 commit = va_arg(data->args, const git_commit *);
215 0 0 return commit ? git_commit_id(commit) : NULL;
233 0 0 GIT_ASSERT_ARG(tree);
234 0 0 GIT_ASSERT_ARG(git_tree_owner(tree) == repo);
256 0 0 return (curr < data->total) ? data->parents[curr] : NULL;
289 57 54 if (curr >= data->total)
292 0 54 if (git_commit_owner(commit) != data->repo)
311 0 57 GIT_ASSERT_ARG(tree);
312 0 57 GIT_ASSERT_ARG(git_tree_owner(tree) == repo);
323 0 0 if (curr >= git_array_size(commit_to_amend->parent_ids))
325 0 0 return git_array_get(commit_to_amend->parent_ids, curr);
343 0 0 GIT_ASSERT_ARG(id);
344 0 0 GIT_ASSERT_ARG(commit_to_amend);
348 0 0 if (!author)
350 0 0 if (!committer)
352 0 0 if (!message_encoding)
354 0 0 if (!message)
357 0 0 if (!tree) {
359 0 0 GIT_ERROR_CHECK_ERROR( git_commit_tree(&old_tree, commit_to_amend) );
363 0 0 GIT_ASSERT_ARG(git_tree_owner(tree) == repo);
367 0 0 if (update_ref) {
368 0 0 if ((error = git_reference_lookup_resolved(&ref, repo, update_ref, 5)) < 0)
371 0 0 if (git_oid_cmp(git_commit_id(commit_to_amend), git_reference_target(ref))) {
382 0 0 if (!error && update_ref) {
0 0 if (!error && update_ref) {
400 0 265 GIT_ASSERT_ARG(commit);
401 0 265 GIT_ASSERT_ARG(data);
407 0 265 GIT_ERROR_CHECK_ARRAY(commit->parent_ids);
410 87 178 if (!(flags & GIT_COMMIT_PARSE_QUICK)) {
411 0 87 if (git_oid__parse(&commit->tree_id, &buffer, buffer_end, "tree ") < 0)
415 0 178 if (buffer + tree_len > buffer_end)
424 224 265 while (git_oid__parse(&parent_id, &buffer, buffer_end, "parent ") == 0) {
425 28 196 git_oid *new_id = git_array_alloc(commit->parent_ids);
28 0 git_oid *new_id = git_array_alloc(commit->parent_ids);
426 0 224 GIT_ERROR_CHECK_ALLOC(new_id);
431 87 178 if (!(flags & GIT_COMMIT_PARSE_QUICK)) {
433 0 87 GIT_ERROR_CHECK_ALLOC(commit->author);
435 0 87 if ((error = git_signature__parse(commit->author, &buffer, buffer_end, "author ", '\n')) < 0)
440 178 265 while (!git__prefixncmp(buffer, buffer_end - buffer, "author ")) {
441 0 178 if ((error = git_signature__parse(&dummy_sig, &buffer, buffer_end, "author ", '\n')) < 0)
450 0 265 GIT_ERROR_CHECK_ALLOC(commit->committer);
452 0 265 if ((error = git_signature__parse(commit->committer, &buffer, buffer_end, "committer ", '\n')) < 0)
455 178 87 if (flags & GIT_COMMIT_PARSE_QUICK)
459 87 0 while (buffer < buffer_end) {
461 87 0 if (buffer[-1] == '\n' && buffer[0] == '\n')
87 0 if (buffer[-1] == '\n' && buffer[0] == '\n')
464 0 0 while (eoln < buffer_end && *eoln != '\n')
0 0 while (eoln < buffer_end && *eoln != '\n')
467 0 0 if (git__prefixncmp(buffer, buffer_end - buffer, "encoding ") == 0) {
471 0 0 GIT_ERROR_CHECK_ALLOC(commit->message_encoding);
474 0 0 if (eoln < buffer_end && *eoln == '\n')
0 0 if (eoln < buffer_end && *eoln == '\n')
481 0 87 GIT_ERROR_CHECK_ALLOC(commit->raw_header);
487 87 0 if (buffer <= buffer_end)
491 0 87 GIT_ERROR_CHECK_ALLOC(commit->raw_message);
522 0 33 GIT_COMMIT_GETTER(const git_signature *, author, commit->author, NULL)
523 0 60 GIT_COMMIT_GETTER(const git_signature *, committer, commit->committer, NULL)
524 0 0 GIT_COMMIT_GETTER(const char *, message_raw, commit->raw_message, NULL)
525 0 3 GIT_COMMIT_GETTER(const char *, message_encoding, commit->message_encoding, NULL)
526 0 0 GIT_COMMIT_GETTER(const char *, raw_header, commit->raw_header, NULL)
527 0 3 GIT_COMMIT_GETTER(git_time_t, time, commit->committer->when.time, INT64_MIN)
528 0 3 GIT_COMMIT_GETTER(int, time_offset, commit->committer->when.offset, -1)
529 0 86 GIT_COMMIT_GETTER(unsigned int, parentcount, (unsigned int)git_array_size(commit->parent_ids), 0)
530 0 13 GIT_COMMIT_GETTER(const git_oid *, tree_id, &commit->tree_id, NULL)
536 0 76 GIT_ASSERT_ARG_WITH_RETVAL(commit, NULL);
541 76 0 while (*message && *message == '\n')
0 76 while (*message && *message == '\n')
553 0 77 GIT_ASSERT_ARG_WITH_RETVAL(commit, NULL);
555 37 40 if (!commit->summary) {
556 582 1 for (msg = git_commit_message(commit), space = NULL; *msg; ++msg) {
559 36 546 if (next_character == '\n') {
560 29 7 if (!msg[1])
562 7 0 if (msg[1] == '\n')
566 0 0 while (*next && git__isspace_nonlf(*next)) {
0 0 while (*next && git__isspace_nonlf(*next)) {
569 0 0 if (!*next || *next == '\n')
0 0 if (!*next || *next == '\n')
573 51 495 if (git__isspace(next_character)) {
574 51 0 if(space == NULL) {
583 51 444 if (space) {
584 0 51 if(space_contains_newline)
596 0 37 if (!commit->summary)
607 0 4 GIT_ASSERT_ARG_WITH_RETVAL(commit, NULL);
609 4 0 if (!commit->body) {
611 55 0 for (msg = git_commit_message(commit); *msg; ++msg)
612 4 51 if (msg[0] == '\n' && (!msg[1] || msg[1] == '\n'))
1 3 if (msg[0] == '\n' && (!msg[1] || msg[1] == '\n'))
0 1 if (msg[0] == '\n' && (!msg[1] || msg[1] == '\n'))
616 7 3 for (; *msg; ++msg)
617 1 6 if (!git__isspace(*msg))
619 2 3 for (end = msg + strlen(msg) - 1; msg <= end; --end)
620 1 1 if (!git__isspace(*end))
623 1 3 if (*msg)
632 0 305 GIT_ASSERT_ARG(commit);
639 0 40 GIT_ASSERT_ARG_WITH_RETVAL(commit, NULL);
641 39 1 return git_array_get(commit->parent_ids, n);
648 0 40 GIT_ASSERT_ARG(commit);
651 1 39 if (parent_id == NULL) {
667 0 10 GIT_ASSERT_ARG(ancestor);
668 0 10 GIT_ASSERT_ARG(commit);
670 0 10 if (git_commit_dup(¤t, (git_commit *)commit) < 0)
673 2 8 if (n == 0) {
678 11 7 while (n--) {
683 1 10 if (error < 0)
698 0 0 GIT_BUF_WRAP_PRIVATE(out, git_commit__header_field, commit, field);
0 0 GIT_BUF_WRAP_PRIVATE(out, git_commit__header_field, commit, field);
710 0 0 while ((eol = strchr(buf, '\n'))) {
712 0 0 if (buf[0] == ' ') {
718 0 0 if (git__prefixcmp(buf, field)) {
725 0 0 if (buf[0] != ' ') {
733 0 0 if (git_str_oom(out))
737 0 0 while (eol[1] == ' ') {
741 0 0 if (!eol)
747 0 0 if (git_str_oom(out))
774 0 0 if ((error = git_buf_tostr(&signature, signature_out)) < 0 ||
0 0 if ((error = git_buf_tostr(&signature, signature_out)) < 0 ||
775 0 0 (error = git_buf_tostr(&signed_data, signed_data_out)) < 0 ||
776 0 0 (error = git_commit__extract_signature(&signature, &signed_data, repo, commit_id, field)) < 0 ||
803 0 0 if (!field)
806 0 0 if ((error = git_repository_odb__weakptr(&odb, repo)) < 0)
809 0 0 if ((error = git_odb_read(&obj, odb, commit_id)) < 0)
812 0 0 if (obj->cached.type != GIT_OBJECT_COMMIT) {
820 0 0 while ((h = strchr(buf, '\n')) && h[1] != '\0') {
0 0 while ((h = strchr(buf, '\n')) && h[1] != '\0') {
822 0 0 if (git__prefixcmp(buf, field)) {
823 0 0 if (git_str_put(signed_data, buf, h - buf) < 0)
833 0 0 if (h[0] != ' ') {
837 0 0 if (!eol)
843 0 0 if (git_str_oom(signature))
847 0 0 while (eol[1] == ' ') {
851 0 0 if (!eol)
857 0 0 if (git_str_oom(signature))
896 0 0 GIT_BUF_WRAP_PRIVATE(out, git_commit__create_buffer, repo,
0 0 GIT_BUF_WRAP_PRIVATE(out, git_commit__create_buffer, repo,
917 0 0 GIT_ASSERT_ARG(tree);
918 0 0 GIT_ASSERT_ARG(git_tree_owner(tree) == repo);
922 0 0 if ((error = validate_tree_and_parents(&parents_arr, repo, tree_id, commit_parent_from_array, &data, NULL, true)) < 0)
941 0 0 GIT_ASSERT_ARG(out);
942 0 0 GIT_ASSERT_ARG(field);
943 0 0 GIT_ASSERT_ARG(content);
948 0 0 while ((lf = strchr(content, '\n')) != NULL) {
957 0 0 return git_str_oom(out) ? -1 : 0;
964 0 0 return git_array_get(commit->parent_ids, n);
985 0 0 GIT_ERROR_CHECK_ALLOC(parsed);
986 0 0 if (commit_parse(parsed, commit_content, strlen(commit_content), 0) < 0) {
991 0 0 if ((error = validate_tree_and_parents(&parents, repo, &parsed->tree_id, commit_parent_from_commit, parsed, NULL, true)) < 0)
998 0 0 if (!header_end) {
1008 0 0 if (signature != NULL) {
1009 0 0 field = signature_field ? signature_field : "gpgsig";
1011 0 0 if ((error = format_header_field(&commit, field, signature)) < 0)
1017 0 0 if (git_str_oom(&commit))
1020 0 0 if ((error = git_repository_odb__weakptr(&odb, repo)) < 0)
1023 0 0 if ((error = git_odb_write(out, odb, commit.ptr, commit.size, GIT_OBJECT_COMMIT)) < 0)