Branch Coverage

deps/libgit2/src/libgit2/stash.c
Criterion Covered Total %
branch 157 322 48.7


line true false branch
39 0 7 if (error == GIT_EUNBORNBRANCH)
50 0 7 GIT_ERROR_CHECK_ALLOC(formatted_oid);
55 0 7 return git_str_oom(out) ? -1 : 0;
61 0 7 GIT_ERROR_CHECK_ALLOC(summary);
63 0 7 if (append_abbreviated_oid(out, git_commit_id(commit)) < 0)
70 0 7 return git_str_oom(out) ? -1 : 0;
81 0 7 if ((error = retrieve_head(&head, repo)) < 0)
84 0 7 if (strcmp("HEAD", git_reference_name(head)) == 0)
91 0 7 if (error < 0)
94 0 7 if ((error = git_commit_lookup(
98 0 7 if ((error = append_commit_description(stash_message, *b_commit)) < 0)
114 0 14 if ((error = git_index_write_tree_to(&i_tree_oid, index, repo)) < 0)
133 0 6 if ((error = build_tree_from_index(&i_tree, repo, index)) < 0)
136 0 6 if ((error = git_str_printf(&msg, "index on %s\n", message)) < 0)
139 0 6 if ((error = git_commit_create(
180 12 0 if (!git_repository_is_bare(repo) &&
0 12 if (!git_repository_is_bare(repo) &&
184 0 12 if ((error = git_blob__create_from_paths(
189 12 0 (repo_index == NULL || !repo_index->distrust_filemode));
12 0 (repo_index == NULL || !repo_index->distrust_filemode));
205 44 0 for (d = 0; !error && d < max_d; ++d) {
36 8 for (d = 0; !error && d < max_d; ++d) {
211 1 0 if (data->include_ignored)
216 6 24 if (data->include_untracked &&
6 0 if (data->include_untracked &&
223 5 0 if (data->include_changed)
242 12 24 if (add_path != NULL)
262 0 2 if ((error = git_index_new(&i_index)) < 0)
265 1 1 if (flags & GIT_STASH_INCLUDE_UNTRACKED) {
271 1 1 if (flags & GIT_STASH_INCLUDE_IGNORED) {
277 0 2 if ((error = git_commit_tree(&i_tree, i_commit)) < 0)
280 0 2 if ((error = git_diff_tree_to_workdir(&diff, repo, i_tree, &opts)) < 0)
283 0 2 if ((error = stash_update_index_from_diff(repo, i_index, diff, &data)) < 0)
308 0 2 if ((error = build_untracked_tree(&u_tree, repo, i_commit, flags)) < 0)
311 0 2 if ((error = git_str_printf(&msg, "untracked files on %s\n", message)) < 0)
314 0 2 if ((error = git_commit_create(
343 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) {
346 0 0 if (dup)
368 0 6 if ((error = git_commit_tree(&b_tree, b_commit)) < 0)
371 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 ||
372 6 0 (error = git_diff_index_to_workdir(&idx_to_wd, repo, i_index, &opts)) < 0 ||
378 0 6 if ((error = stash_update_index_from_diff(repo, i_index, diff, &data)) < 0)
409 6 0 if ((error = git_repository_index(&r_index, repo) < 0) ||
6 0 if ((error = git_repository_index(&r_index, repo) < 0) ||
410 6 0 (error = git_index_new(&i_index)) < 0 ||
411 6 0 (error = git_index__fill(i_index, &r_index->entries) < 0) ||
417 0 6 if ((error = build_workdir_tree(&w_tree, repo, i_index, b_commit)) < 0)
420 2 4 error = git_commit_create(
444 0 6 if (!user_message) {
449 0 6 if ((colon = strchr(git_str_cstr(out), ':')) == NULL)
457 0 6 if (git_str_oom(&buf)) {
477 0 6 if ((error = git_reference_ensure_log(repo, GIT_REFS_STASH_FILE)) < 0)
504 1 6 if (flags & GIT_STASH_INCLUDE_UNTRACKED)
508 1 6 if (flags & GIT_STASH_INCLUDE_IGNORED)
514 6 1 if (error == GIT_PASSTHROUGH)
517 1 0 if (!error)
528 1 5 if (flags & GIT_STASH_INCLUDE_UNTRACKED)
530 1 5 if (flags & GIT_STASH_INCLUDE_IGNORED)
548 0 7 GIT_ASSERT_ARG(out);
549 0 7 GIT_ASSERT_ARG(repo);
550 0 7 GIT_ASSERT_ARG(stasher);
552 0 7 if ((error = git_repository__ensure_not_bare(repo, "stash save")) < 0)
555 0 7 if ((error = retrieve_base_commit_and_message(&b_commit, &msg, repo)) < 0)
558 1 6 if ((error = ensure_there_are_changes_to_stash(repo, flags)) < 0)
561 0 6 if ((error = git_repository_index(&index, repo)) < 0)
564 0 6 if ((error = commit_index(&i_commit, repo, index, stasher,
568 2 4 if ((flags & (GIT_STASH_INCLUDE_UNTRACKED | GIT_STASH_INCLUDE_IGNORED)) &&
0 2 if ((flags & (GIT_STASH_INCLUDE_UNTRACKED | GIT_STASH_INCLUDE_IGNORED)) &&
573 0 6 if ((error = prepare_worktree_commit_message(&msg, message)) < 0)
576 0 6 if ((error = commit_worktree(out, repo, stasher, git_str_cstr(&msg),
582 0 6 if ((error = update_reflog(out, repo, git_str_cstr(&msg))) < 0)
585 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,
611 0 2 if ((error = git_reference_lookup(&stash, repo, GIT_REFS_STASH_FILE)) < 0)
614 0 2 if ((error = git_reflog_read(&reflog, repo, GIT_REFS_STASH_FILE)) < 0)
618 2 0 if (!max || index > max - 1) {
0 2 if (!max || index > max - 1) {
625 0 2 if ((error = git_commit_lookup(commit, repo, git_reflog_entry_id_new(entry))) < 0)
653 0 2 if ((error = git_commit_tree(&stash_tree, stash_commit)) < 0)
656 0 2 if ((error = git_commit_parent(&base_commit, stash_commit, 0)) < 0)
658 0 2 if ((error = git_commit_tree(&base_tree, base_commit)) < 0)
661 0 2 if ((error = git_commit_parent(&index_commit, stash_commit, 1)) < 0)
663 0 2 if ((error = git_commit_tree(&index_tree, index_commit)) < 0)
666 0 2 if ((error = git_commit_parent(&index_parent_commit, index_commit, 0)) < 0)
668 0 2 if ((error = git_commit_tree(&index_parent_tree, index_parent_commit)) < 0)
671 0 2 if (git_commit_parentcount(stash_commit) == 3) {
672 0 0 if ((error = git_commit_parent(&untracked_commit, stash_commit, 2)) < 0)
674 0 0 if ((error = git_commit_tree(&untracked_tree, untracked_commit)) < 0)
689 0 2 if (error < 0) {
712 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 ||
713 0 0 (error = git_iterator_for_index(&ours, repo, ours_index, &iter_opts)) < 0 ||
739 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 ||
740 4 0 (error = git_iterator_for_index(&ours, repo, ours_index, &iter_opts)) < 0 ||
757 2 0 if (given_apply_opts != NULL) {
766 2 0 if (!opts->checkout_options.our_label)
769 2 0 if (!opts->checkout_options.their_label)
775 0 0 GIT_INIT_STRUCTURE_FROM_TEMPLATE(
802 2 0 if ((error = git_repository_head_tree(&head_tree, repo)) < 0 ||
2 0 if ((error = git_repository_head_tree(&head_tree, repo)) < 0 ||
807 0 2 if (git_diff_num_deltas(index_diff) > 0) {
823 0 0 if(entries[0] == NULL)
839 0 0 if ((error = git_index_new(&index)) < 0 ||
0 0 if ((error = git_index_new(&index)) < 0 ||
841 0 0 &iterators[0], parent_tree, &iterator_options)) < 0 ||
849 0 0 if (error < 0)
880 0 2 GIT_ERROR_CHECK_VERSION(given_opts, GIT_STASH_APPLY_OPTIONS_VERSION, "git_stash_apply_options");
885 2 0 NOTIFY_PROGRESS(opts, GIT_STASH_APPLY_PROGRESS_LOADING_STASH);
0 2 NOTIFY_PROGRESS(opts, GIT_STASH_APPLY_PROGRESS_LOADING_STASH);
888 0 2 if ((error = retrieve_stash_commit(&stash_commit, repo, index)) < 0)
892 0 2 if ((error = retrieve_stash_trees(
898 0 2 if ((error = git_repository_index(&repo_index, repo)) < 0)
901 2 0 NOTIFY_PROGRESS(opts, GIT_STASH_APPLY_PROGRESS_ANALYZE_INDEX);
0 2 NOTIFY_PROGRESS(opts, GIT_STASH_APPLY_PROGRESS_ANALYZE_INDEX);
903 0 2 if ((error = ensure_clean_index(repo, repo_index)) < 0)
910 0 2 if ((error = merge_index_and_tree(
914 0 2 if (git_index_has_conflicts(unstashed_index)) {
922 0 0 } else if ((opts.flags & GIT_STASH_APPLY_REINSTATE_INDEX) == 0) {
923 0 0 if ((error = stage_new_files(
924 0 0 &stash_adds, stash_parent_tree, stash_tree)) < 0 ||
930 2 0 NOTIFY_PROGRESS(opts, GIT_STASH_APPLY_PROGRESS_ANALYZE_MODIFIED);
0 2 NOTIFY_PROGRESS(opts, GIT_STASH_APPLY_PROGRESS_ANALYZE_MODIFIED);
933 0 2 if ((error = merge_index_and_tree(
938 0 2 if (untracked_tree) {
939 0 0 NOTIFY_PROGRESS(opts, GIT_STASH_APPLY_PROGRESS_ANALYZE_UNTRACKED);
0 0 NOTIFY_PROGRESS(opts, GIT_STASH_APPLY_PROGRESS_ANALYZE_UNTRACKED);
941 0 0 if ((error = merge_index_and_tree(&untracked_index, repo, NULL, repo_index, untracked_tree)) < 0)
945 0 2 if (untracked_index) {
948 0 0 NOTIFY_PROGRESS(opts, GIT_STASH_APPLY_PROGRESS_CHECKOUT_UNTRACKED);
0 0 NOTIFY_PROGRESS(opts, GIT_STASH_APPLY_PROGRESS_CHECKOUT_UNTRACKED);
950 0 0 if ((error = git_checkout_index(repo, untracked_index, &opts.checkout_options)) < 0)
962 2 0 if (!git_index_has_conflicts(modified_index))
971 2 0 NOTIFY_PROGRESS(opts, GIT_STASH_APPLY_PROGRESS_CHECKOUT_MODIFIED);
0 2 NOTIFY_PROGRESS(opts, GIT_STASH_APPLY_PROGRESS_CHECKOUT_MODIFIED);
973 0 2 if ((error = git_checkout_index(repo, modified_index, &opts.checkout_options)) < 0)
976 2 0 if (unstashed_index && !git_index_has_conflicts(modified_index)) {
2 0 if (unstashed_index && !git_index_has_conflicts(modified_index)) {
977 0 2 if ((error = git_index_read_index(repo_index, unstashed_index)) < 0)
981 2 0 NOTIFY_PROGRESS(opts, GIT_STASH_APPLY_PROGRESS_DONE);
0 2 NOTIFY_PROGRESS(opts, GIT_STASH_APPLY_PROGRESS_DONE);
1012 1 8 if (error == GIT_ENOTFOUND) {
1016 0 8 if (error < 0)
1019 0 8 if ((error = git_reflog_read(&reflog, repo, GIT_REFS_STASH_FILE)) < 0)
1023 12 4 for (i = 0; i < max; i++) {
1031 4 8 if (error) {
1053 0 3 if ((error = git_transaction_new(&tx, repo)) < 0)
1056 0 3 if ((error = git_transaction_lock_ref(tx, GIT_REFS_STASH_FILE)) < 0)
1059 0 3 if ((error = git_reference_lookup(&stash, repo, GIT_REFS_STASH_FILE)) < 0)
1062 0 3 if ((error = git_reflog_read(&reflog, repo, GIT_REFS_STASH_FILE)) < 0)
1067 3 0 if (!max || index > max - 1) {
0 3 if (!max || index > max - 1) {
1073 0 3 if ((error = git_reflog_drop(reflog, index, true)) < 0)
1076 0 3 if ((error = git_transaction_set_reflog(tx, GIT_REFS_STASH_FILE, reflog)) < 0)
1079 1 2 if (max == 1) {
1080 0 1 if ((error = git_transaction_remove(tx, GIT_REFS_STASH_FILE)) < 0)
1082 2 0 } else if (index == 0) {
1086 0 2 if ((error = git_transaction_set_target(tx, GIT_REFS_STASH_FILE, &entry->oid_cur, NULL, NULL)) < 0)
1106 0 1 if ((error = git_stash_apply(repo, index, options)) < 0)