Branch Coverage

deps/libgit2/src/stash.c
Criterion Covered Total %
branch 156 322 48.4


line true false branch
40 0 7 if (error == GIT_EUNBORNBRANCH)
51 0 7 GIT_ERROR_CHECK_ALLOC(formatted_oid);
56 0 7 return git_buf_oom(out) ? -1 : 0;
62 0 7 GIT_ERROR_CHECK_ALLOC(summary);
64 0 7 if (append_abbreviated_oid(out, git_commit_id(commit)) < 0)
71 0 7 return git_buf_oom(out) ? -1 : 0;
82 0 7 if ((error = retrieve_head(&head, repo)) < 0)
85 0 7 if (strcmp("HEAD", git_reference_name(head)) == 0)
92 0 7 if (error < 0)
95 0 7 if ((error = git_commit_lookup(
99 0 7 if ((error = append_commit_description(stash_message, *b_commit)) < 0)
115 0 14 if ((error = git_index_write_tree_to(&i_tree_oid, index, repo)) < 0)
134 0 6 if ((error = build_tree_from_index(&i_tree, repo, index)) < 0)
137 0 6 if ((error = git_buf_printf(&msg, "index on %s\n", message)) < 0)
140 0 6 if ((error = git_commit_create(
181 12 0 if (!git_repository_is_bare(repo) &&
0 12 if (!git_repository_is_bare(repo) &&
185 0 12 if ((error = git_blob__create_from_paths(
190 0 12 (repo_index != NULL || !repo_index->distrust_filemode));
0 0 (repo_index != NULL || !repo_index->distrust_filemode));
206 44 0 for (d = 0; !error && d < max_d; ++d) {
36 8 for (d = 0; !error && d < max_d; ++d) {
212 1 0 if (data->include_ignored)
217 6 24 if (data->include_untracked &&
6 0 if (data->include_untracked &&
224 5 0 if (data->include_changed)
243 12 24 if (add_path != NULL)
263 0 2 if ((error = git_index_new(&i_index)) < 0)
266 1 1 if (flags & GIT_STASH_INCLUDE_UNTRACKED) {
272 1 1 if (flags & GIT_STASH_INCLUDE_IGNORED) {
278 0 2 if ((error = git_commit_tree(&i_tree, i_commit)) < 0)
281 0 2 if ((error = git_diff_tree_to_workdir(&diff, repo, i_tree, &opts)) < 0)
284 0 2 if ((error = stash_update_index_from_diff(repo, i_index, diff, &data)) < 0)
309 0 2 if ((error = build_untracked_tree(&u_tree, repo, i_commit, flags)) < 0)
312 0 2 if ((error = git_buf_printf(&msg, "untracked files on %s\n", message)) < 0)
315 0 2 if ((error = git_commit_create(
344 0 3 if (a->status == GIT_DELTA_DELETED && b->status == GIT_DELTA_UNTRACKED) {
0 0 if (a->status == GIT_DELTA_DELETED && b->status == GIT_DELTA_UNTRACKED) {
347 0 0 if (dup)
369 0 6 if ((error = git_commit_tree(&b_tree, b_commit)) < 0)
372 6 0 if ((error = git_diff_tree_to_index(&diff, repo, b_tree, i_index, &opts)) < 0 ||
6 0 if ((error = git_diff_tree_to_index(&diff, repo, b_tree, i_index, &opts)) < 0 ||
373 6 0 (error = git_diff_index_to_workdir(&idx_to_wd, repo, i_index, &opts)) < 0 ||
379 0 6 if ((error = stash_update_index_from_diff(repo, i_index, diff, &data)) < 0)
410 6 0 if ((error = git_repository_index(&r_index, repo) < 0) ||
6 0 if ((error = git_repository_index(&r_index, repo) < 0) ||
411 6 0 (error = git_index_new(&i_index)) < 0 ||
412 6 0 (error = git_index__fill(i_index, &r_index->entries) < 0) ||
418 0 6 if ((error = build_workdir_tree(&w_tree, repo, i_index, b_commit)) < 0)
421 2 4 error = git_commit_create(
445 0 6 if (!user_message) {
450 0 6 if ((colon = strchr(git_buf_cstr(out), ':')) == NULL)
458 0 6 if (git_buf_oom(&buf)) {
478 0 6 if ((error = git_reference_ensure_log(repo, GIT_REFS_STASH_FILE)) < 0)
505 1 6 if (flags & GIT_STASH_INCLUDE_UNTRACKED)
509 1 6 if (flags & GIT_STASH_INCLUDE_IGNORED)
515 6 1 if (error == GIT_PASSTHROUGH)
518 1 0 if (!error)
529 1 5 if (flags & GIT_STASH_INCLUDE_UNTRACKED)
531 1 5 if (flags & GIT_STASH_INCLUDE_IGNORED)
549 7 0 assert(out && repo && stasher);
7 0 assert(out && repo && stasher);
0 7 assert(out && repo && stasher);
551 0 7 if ((error = git_repository__ensure_not_bare(repo, "stash save")) < 0)
554 0 7 if ((error = retrieve_base_commit_and_message(&b_commit, &msg, repo)) < 0)
557 1 6 if ((error = ensure_there_are_changes_to_stash(repo, flags)) < 0)
560 0 6 if ((error = git_repository_index(&index, repo)) < 0)
563 0 6 if ((error = commit_index(&i_commit, repo, index, stasher,
567 2 4 if ((flags & (GIT_STASH_INCLUDE_UNTRACKED | GIT_STASH_INCLUDE_IGNORED)) &&
0 2 if ((flags & (GIT_STASH_INCLUDE_UNTRACKED | GIT_STASH_INCLUDE_IGNORED)) &&
572 0 6 if ((error = prepare_worktree_commit_message(&msg, message)) < 0)
575 0 6 if ((error = commit_worktree(out, repo, stasher, git_buf_cstr(&msg),
581 0 6 if ((error = update_reflog(out, repo, git_buf_cstr(&msg))) < 0)
584 1 5 if ((error = reset_index_and_workdir(repo, (flags & GIT_STASH_KEEP_INDEX) ? i_commit : b_commit,
0 6 if ((error = reset_index_and_workdir(repo, (flags & GIT_STASH_KEEP_INDEX) ? i_commit : b_commit,
610 0 2 if ((error = git_reference_lookup(&stash, repo, GIT_REFS_STASH_FILE)) < 0)
613 0 2 if ((error = git_reflog_read(&reflog, repo, GIT_REFS_STASH_FILE)) < 0)
617 2 0 if (!max || index > max - 1) {
0 2 if (!max || index > max - 1) {
624 0 2 if ((error = git_commit_lookup(commit, repo, git_reflog_entry_id_new(entry))) < 0)
652 0 2 if ((error = git_commit_tree(&stash_tree, stash_commit)) < 0)
655 0 2 if ((error = git_commit_parent(&base_commit, stash_commit, 0)) < 0)
657 0 2 if ((error = git_commit_tree(&base_tree, base_commit)) < 0)
660 0 2 if ((error = git_commit_parent(&index_commit, stash_commit, 1)) < 0)
662 0 2 if ((error = git_commit_tree(&index_tree, index_commit)) < 0)
665 0 2 if ((error = git_commit_parent(&index_parent_commit, index_commit, 0)) < 0)
667 0 2 if ((error = git_commit_tree(&index_parent_tree, index_parent_commit)) < 0)
670 0 2 if (git_commit_parentcount(stash_commit) == 3) {
671 0 0 if ((error = git_commit_parent(&untracked_commit, stash_commit, 2)) < 0)
673 0 0 if ((error = git_commit_tree(&untracked_tree, untracked_commit)) < 0)
688 0 2 if (error < 0) {
711 0 0 if ((error = git_iterator_for_tree(&ancestor, ancestor_tree, &iter_opts)) < 0 ||
0 0 if ((error = git_iterator_for_tree(&ancestor, ancestor_tree, &iter_opts)) < 0 ||
712 0 0 (error = git_iterator_for_index(&ours, repo, ours_index, &iter_opts)) < 0 ||
738 4 0 if ((error = git_iterator_for_tree(&ancestor, ancestor_tree, &iter_opts)) < 0 ||
4 0 if ((error = git_iterator_for_tree(&ancestor, ancestor_tree, &iter_opts)) < 0 ||
739 4 0 (error = git_iterator_for_index(&ours, repo, ours_index, &iter_opts)) < 0 ||
756 2 0 if (given_apply_opts != NULL) {
765 2 0 if (!opts->checkout_options.our_label)
768 2 0 if (!opts->checkout_options.their_label)
774 0 0 GIT_INIT_STRUCTURE_FROM_TEMPLATE(
799 2 0 if ((error = git_repository_head_tree(&head_tree, repo)) < 0 ||
2 0 if ((error = git_repository_head_tree(&head_tree, repo)) < 0 ||
804 0 2 if (git_diff_num_deltas(index_diff) > 0) {
820 0 0 if(entries[0] == NULL)
836 0 0 if ((error = git_index_new(&index)) < 0 ||
0 0 if ((error = git_index_new(&index)) < 0 ||
838 0 0 &iterators[0], parent_tree, &iterator_options)) < 0 ||
846 0 0 if (error < 0)
877 0 2 GIT_ERROR_CHECK_VERSION(given_opts, GIT_STASH_APPLY_OPTIONS_VERSION, "git_stash_apply_options");
882 2 0 NOTIFY_PROGRESS(opts, GIT_STASH_APPLY_PROGRESS_LOADING_STASH);
0 2 NOTIFY_PROGRESS(opts, GIT_STASH_APPLY_PROGRESS_LOADING_STASH);
885 0 2 if ((error = retrieve_stash_commit(&stash_commit, repo, index)) < 0)
889 0 2 if ((error = retrieve_stash_trees(
895 0 2 if ((error = git_repository_index(&repo_index, repo)) < 0)
898 2 0 NOTIFY_PROGRESS(opts, GIT_STASH_APPLY_PROGRESS_ANALYZE_INDEX);
0 2 NOTIFY_PROGRESS(opts, GIT_STASH_APPLY_PROGRESS_ANALYZE_INDEX);
900 0 2 if ((error = ensure_clean_index(repo, repo_index)) < 0)
907 0 2 if ((error = merge_index_and_tree(
911 0 2 if (git_index_has_conflicts(unstashed_index)) {
919 0 0 } else if ((opts.flags & GIT_STASH_APPLY_REINSTATE_INDEX) == 0) {
920 0 0 if ((error = stage_new_files(
921 0 0 &stash_adds, stash_parent_tree, stash_tree)) < 0 ||
927 2 0 NOTIFY_PROGRESS(opts, GIT_STASH_APPLY_PROGRESS_ANALYZE_MODIFIED);
0 2 NOTIFY_PROGRESS(opts, GIT_STASH_APPLY_PROGRESS_ANALYZE_MODIFIED);
930 0 2 if ((error = merge_index_and_tree(
935 0 2 if (untracked_tree) {
936 0 0 NOTIFY_PROGRESS(opts, GIT_STASH_APPLY_PROGRESS_ANALYZE_UNTRACKED);
0 0 NOTIFY_PROGRESS(opts, GIT_STASH_APPLY_PROGRESS_ANALYZE_UNTRACKED);
938 0 0 if ((error = merge_index_and_tree(&untracked_index, repo, NULL, repo_index, untracked_tree)) < 0)
942 0 2 if (untracked_index) {
945 0 0 NOTIFY_PROGRESS(opts, GIT_STASH_APPLY_PROGRESS_CHECKOUT_UNTRACKED);
0 0 NOTIFY_PROGRESS(opts, GIT_STASH_APPLY_PROGRESS_CHECKOUT_UNTRACKED);
947 0 0 if ((error = git_checkout_index(repo, untracked_index, &opts.checkout_options)) < 0)
959 2 0 if (!git_index_has_conflicts(modified_index))
968 2 0 NOTIFY_PROGRESS(opts, GIT_STASH_APPLY_PROGRESS_CHECKOUT_MODIFIED);
0 2 NOTIFY_PROGRESS(opts, GIT_STASH_APPLY_PROGRESS_CHECKOUT_MODIFIED);
970 0 2 if ((error = git_checkout_index(repo, modified_index, &opts.checkout_options)) < 0)
973 2 0 if (unstashed_index && !git_index_has_conflicts(modified_index)) {
2 0 if (unstashed_index && !git_index_has_conflicts(modified_index)) {
974 0 2 if ((error = git_index_read_index(repo_index, unstashed_index)) < 0)
978 2 0 NOTIFY_PROGRESS(opts, GIT_STASH_APPLY_PROGRESS_DONE);
0 2 NOTIFY_PROGRESS(opts, GIT_STASH_APPLY_PROGRESS_DONE);
1009 1 8 if (error == GIT_ENOTFOUND) {
1013 0 8 if (error < 0)
1016 0 8 if ((error = git_reflog_read(&reflog, repo, GIT_REFS_STASH_FILE)) < 0)
1020 12 4 for (i = 0; i < max; i++) {
1028 4 8 if (error) {
1050 0 3 if ((error = git_transaction_new(&tx, repo)) < 0)
1053 0 3 if ((error = git_transaction_lock_ref(tx, GIT_REFS_STASH_FILE)) < 0)
1056 0 3 if ((error = git_reference_lookup(&stash, repo, GIT_REFS_STASH_FILE)) < 0)
1059 0 3 if ((error = git_reflog_read(&reflog, repo, GIT_REFS_STASH_FILE)) < 0)
1064 3 0 if (!max || index > max - 1) {
0 3 if (!max || index > max - 1) {
1070 0 3 if ((error = git_reflog_drop(reflog, index, true)) < 0)
1073 0 3 if ((error = git_transaction_set_reflog(tx, GIT_REFS_STASH_FILE, reflog)) < 0)
1076 1 2 if (max == 1) {
1077 0 1 if ((error = git_transaction_remove(tx, GIT_REFS_STASH_FILE)) < 0)
1079 2 0 } else if (index == 0) {
1083 0 2 if ((error = git_transaction_set_target(tx, GIT_REFS_STASH_FILE, &entry->oid_cur, NULL, NULL)) < 0)
1103 0 1 if ((error = git_stash_apply(repo, index, options)) < 0)