Branch Coverage

deps/libgit2/src/checkout.c
Criterion Covered Total %
branch 408 1080 37.7


line true false branch
101 2 188 if (!data->opts.notify_cb ||
0 2 if (!data->opts.notify_cb ||
105 2 0 if (wditem) {
119 1 1 if (delta) {
163 0 165 if (!respect_filemode) {
164 0 0 if (a == S_IFLNK)
166 0 0 if (b == S_IFLNK)
186 0 107 if (wditem->mode == GIT_FILEMODE_COMMIT) {
192 0 0 if (git_submodule_lookup(&sm, data->repo, wditem->path) < 0) {
197 0 0 if (git_submodule_status(&sm_status, data->repo, wditem->path, GIT_SUBMODULE_IGNORE_UNSPECIFIED) < 0 ||
0 0 if (git_submodule_status(&sm_status, data->repo, wditem->path, GIT_SUBMODULE_IGNORE_UNSPECIFIED) < 0 ||
200 0 0 else if ((sm_oid = git_submodule_wd_id(sm)) == NULL)
219 59 2 !git_index_entry_newer_than_index(ie, data->index) &&
220 59 0 git_index_time_eq(&wditem->mtime, &ie->mtime) &&
221 59 0 wditem->file_size == ie->file_size &&
232 2 46 if (baseitem->size && wditem->file_size != baseitem->size)
0 2 if (baseitem->size && wditem->file_size != baseitem->size)
236 0 48 if (S_ISDIR(wditem->mode))
239 0 48 if (is_filemode_changed(baseitem->mode, wditem->mode, data->respect_filemode))
242 0 48 if (git_diff__oid_for_entry(&oid, data->diff, wditem, wditem->mode, NULL) < 0)
262 0 115 if ((data->strategy & GIT_CHECKOUT_UPDATE_ONLY) != 0)
265 31 84 if ((*action & CHECKOUT_ACTION__UPDATE_BLOB) != 0) {
266 0 31 if (S_ISGITLINK(delta->new_file.mode))
271 0 31 if (delta->new_file.mode == GIT_FILEMODE_LINK && wd != NULL)
0 0 if (delta->new_file.mode == GIT_FILEMODE_LINK && wd != NULL)
275 25 6 if (wd &&
0 25 if (wd &&
282 0 115 if ((*action & CHECKOUT_ACTION__CONFLICT) != 0)
300 0 1 if (error)
302 0 1 *action = CHECKOUT_ACTION_IF(RECREATE_MISSING, UPDATE_BLOB, NONE);
305 6 0 *action = CHECKOUT_ACTION_IF(SAFE, UPDATE_BLOB, NONE);
308 0 0 *action = CHECKOUT_ACTION_IF(RECREATE_MISSING, UPDATE_BLOB, CONFLICT);
311 0 0 if (delta->new_file.mode == GIT_FILEMODE_TREE)
312 0 0 *action = CHECKOUT_ACTION_IF(SAFE, UPDATE_BLOB, NONE);
329 38 13 if (path && git_buf_puts(&data->target_path, path) < 0)
0 38 if (path && git_buf_puts(&data->target_path, path) < 0)
342 53 7 if (wd->mode != GIT_FILEMODE_TREE)
345 0 7 if (checkout_target_fullpath(&full, data, wd->path) < 0)
348 7 0 return !full || !git_path_contains(full, DOT_GIT);
7 0 return !full || !git_path_contains(full, DOT_GIT);
354 0 12 GIT_ERROR_CHECK_ALLOC(copy);
370 2 60 if (!git_pathspec__match(
375 0 2 if (wd->mode == GIT_FILEMODE_TREE)
382 60 0 if (data->index != NULL) {
388 53 7 if (wd->mode != GIT_FILEMODE_TREE) {
389 4 49 if (!error) { /* found by git_index__find_pos call */
392 0 49 } else if (error != GIT_ENOTFOUND)
402 7 0 if (e != NULL && data->diff->pfxcomp(e->path, wd->path) == 0)
0 7 if (e != NULL && data->diff->pfxcomp(e->path, wd->path) == 0)
407 4 56 if (notify != GIT_CHECKOUT_NOTIFY_NONE) {
409 0 4 if ((error = checkout_notify(data, notify, NULL, wd)) != 0)
412 4 0 if (remove && wd_item_is_removable(data, wd))
4 0 if (remove && wd_item_is_removable(data, wd))
415 4 0 if (!error)
429 8 48 if (error == GIT_ITEROVER)
431 0 48 else if (error < 0)
434 1 55 if (untracked_state == GIT_ITERATOR_STATUS_IGNORED) {
442 0 56 if ((error = checkout_notify(data, notify, NULL, &saved_wd)) != 0)
445 8 48 if (remove && removable)
8 0 if (remove && removable)
448 56 0 if (!error && over) /* restore ITEROVER if needed */
8 48 if (!error && over) /* restore ITEROVER if needed */
463 0 0 if (git_submodule_lookup(&sm, data->repo, path) < 0)
466 0 0 if (git_submodule_location(&sm_loc, sm) < 0 ||
0 0 if (git_submodule_location(&sm_loc, sm) < 0 ||
479 0 0 if (checkout_target_fullpath(&fullpath, data, path) < 0)
496 14 73 if (checkout_is_workdir_modified(data, &delta->old_file, &delta->new_file, wd)) {
497 0 14 GIT_ERROR_CHECK_ERROR(
503 0 1 if (git_iterator_current_is_ignored(workdir))
504 0 0 *action = CHECKOUT_ACTION_IF(DONT_OVERWRITE_IGNORED, CONFLICT, UPDATE_BLOB);
506 1 0 *action = CHECKOUT_ACTION_IF(FORCE, UPDATE_BLOB, CONFLICT);
509 0 8 if (checkout_is_workdir_modified(data, &delta->old_file, &delta->new_file, wd))
510 0 0 *action = CHECKOUT_ACTION_IF(FORCE, REMOVE, CONFLICT);
517 1 0 *action = CHECKOUT_ACTION_IF(FORCE, UPDATE_BLOB, CONFLICT);
519 11 0 *action = CHECKOUT_ACTION_IF(SAFE, UPDATE_BLOB, NONE);
522 0 0 if (delta->old_file.mode == GIT_FILEMODE_TREE) {
523 0 0 if (wd->mode == GIT_FILEMODE_TREE)
527 0 0 *action = CHECKOUT_ACTION_IF(SAFE, UPDATE_BLOB, NONE);
528 0 0 else if (wd->mode == GIT_FILEMODE_COMMIT) {
532 0 0 if (submodule_is_config_only(data, wd->path))
533 0 0 *action = CHECKOUT_ACTION_IF(SAFE, UPDATE_BLOB, NONE);
535 0 0 *action = CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, CONFLICT);
537 0 0 *action = CHECKOUT_ACTION_IF(FORCE, REMOVE, CONFLICT);
539 0 0 else if (checkout_is_workdir_modified(data, &delta->old_file, &delta->new_file, wd))
540 0 0 *action = CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, CONFLICT);
542 0 0 *action = CHECKOUT_ACTION_IF(SAFE, REMOVE_AND_UPDATE, NONE);
545 0 0 if (delta->new_file.mode == GIT_FILEMODE_TREE)
566 0 0 GIT_ERROR_CHECK_ERROR(
568 0 0 *action = CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, NONE);
572 0 0 *action = CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, CONFLICT);
575 0 0 *action = CHECKOUT_ACTION_IF(FORCE, REMOVE, CONFLICT);
579 0 0 *action = CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, CONFLICT);
599 0 0 GIT_ERROR_CHECK_ERROR(
601 0 0 GIT_ERROR_CHECK_ERROR(
603 0 0 *action = CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, NONE);
607 0 0 if (delta->old_file.mode == GIT_FILEMODE_COMMIT)
609 0 0 else if (delta->new_file.mode != GIT_FILEMODE_TREE)
611 0 0 CHECKOUT_ACTION_IF(DONT_OVERWRITE_IGNORED, CONFLICT, REMOVE_AND_UPDATE) :
0 0 CHECKOUT_ACTION_IF(DONT_OVERWRITE_IGNORED, CONFLICT, REMOVE_AND_UPDATE) :
612 0 0 CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, CONFLICT);
615 0 0 if (delta->old_file.mode != GIT_FILEMODE_TREE)
616 0 0 GIT_ERROR_CHECK_ERROR(
620 0 0 if (delta->old_file.mode == GIT_FILEMODE_TREE) {
627 0 0 *action = CHECKOUT_ACTION_IF(SAFE, UPDATE_BLOB, NONE);
629 0 0 else if (delta->new_file.mode != GIT_FILEMODE_TREE)
631 0 0 *action = CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, CONFLICT);
648 0 0 if (error == 0 && *action != CHECKOUT_ACTION__NONE)
0 0 if (error == 0 && *action != CHECKOUT_ACTION__NONE)
672 6 205 if (!wd)
685 96 109 if (cmp < 0) {
688 45 51 if (cmp == 0) {
689 44 1 if (wd->mode == GIT_FILEMODE_TREE) {
692 0 44 if (error < 0 && error != GIT_ITEROVER)
0 0 if (error < 0 && error != GIT_ITEROVER)
698 0 1 if (delta->old_file.path[strlen(wd->path)] == '/') {
708 0 52 if (error && error != GIT_ITEROVER)
0 0 if (error && error != GIT_ITEROVER)
713 108 1 if (cmp == 0) {
722 0 1 if (cmp == 0) { /* case 5 */
723 0 0 if (wd->path[strlen(delta->old_file.path)] != '/')
726 0 0 if (delta->status == GIT_DELTA_TYPECHANGE) {
727 0 0 if (delta->old_file.mode == GIT_FILEMODE_TREE) {
733 0 0 if (delta->new_file.mode == GIT_FILEMODE_TREE ||
0 0 if (delta->new_file.mode == GIT_FILEMODE_TREE ||
734 0 0 delta->new_file.mode == GIT_FILEMODE_COMMIT ||
744 0 0 checkout_action_with_wd_dir_empty(action, data, delta) :
753 108 0 if (!error && advance != NULL &&
108 0 if (!error && advance != NULL &&
41 67 if (!error && advance != NULL &&
756 41 0 if (error == GIT_ITEROVER)
771 10 53 while (wd && !error)
10 0 while (wd && !error)
774 10 43 if (error == GIT_ITEROVER)
784 0 0 if (!a && !b)
0 0 if (!a && !b)
786 0 0 else if (!a && b)
0 0 else if (!a && b)
788 0 0 else if(a && !b)
0 0 else if(a && !b)
800 0 0 if ((diff = checkout_idxentry_cmp(ca->ancestor, cb->ancestor)) == 0 &&
0 0 if ((diff = checkout_idxentry_cmp(ca->ancestor, cb->ancestor)) == 0 &&
814 0 3 if ((conflict = git_vector_get(conflicts, idx)) == NULL)
817 0 3 if (conflict->ancestor || conflict->ours || conflict->theirs)
0 0 if (conflict->ancestor || conflict->ours || conflict->theirs)
0 0 if (conflict->ancestor || conflict->ours || conflict->theirs)
833 3 0 if (ours && git_pathspec__match(pathspec, ours->path,
3 0 if (ours && git_pathspec__match(pathspec, ours->path,
838 0 0 if (theirs && git_pathspec__match(pathspec, theirs->path,
0 0 if (theirs && git_pathspec__match(pathspec, theirs->path,
843 0 0 if (ancestor && git_pathspec__match(pathspec, ancestor->path,
0 0 if (ancestor && git_pathspec__match(pathspec, ancestor->path,
853 3 0 conflict->submodule = ((conflict->ancestor && S_ISGITLINK(conflict->ancestor->mode)) ||
3 0 conflict->submodule = ((conflict->ancestor && S_ISGITLINK(conflict->ancestor->mode)) ||
854 3 0 (conflict->ours && S_ISGITLINK(conflict->ours->mode)) ||
3 0 (conflict->ours && S_ISGITLINK(conflict->ours->mode)) ||
3 0 (conflict->ours && S_ISGITLINK(conflict->ours->mode)) ||
855 0 3 (conflict->theirs && S_ISGITLINK(conflict->theirs->mode)));
864 0 3 if (conflict->submodule)
867 3 0 if (conflict->ancestor) {
868 0 3 if ((error = git_blob_lookup(&ancestor_blob, repo, &conflict->ancestor->id)) < 0)
874 3 0 if (!conflict->binary && conflict->ours) {
3 0 if (!conflict->binary && conflict->ours) {
875 0 3 if ((error = git_blob_lookup(&our_blob, repo, &conflict->ours->id)) < 0)
881 3 0 if (!conflict->binary && conflict->theirs) {
3 0 if (!conflict->binary && conflict->theirs) {
882 0 3 if ((error = git_blob_lookup(&their_blob, repo, &conflict->theirs->id)) < 0)
907 0 3 GIT_ERROR_CHECK_ALLOC(conflict);
913 3 0 if ((error = checkout_conflict_detect_submodule(conflict)) < 0 ||
0 3 if ((error = checkout_conflict_detect_submodule(conflict)) < 0 ||
920 0 3 if (git_vector_insert(&data->update_conflicts, conflict))
938 0 68 if ((error = git_index_conflict_iterator_new(&iterator, index)) < 0)
942 3 68 while ((error = git_index_conflict_next(&ancestor, &ours, &theirs, iterator)) == 0) {
943 0 3 if (!conflict_pathspec_match(data, workdir, pathspec, ancestor, ours, theirs))
946 0 3 if ((error = cb(ancestor, ours, theirs, payload)) < 0)
950 68 0 if (error == GIT_ITEROVER)
964 36 17 if ((index = git_iterator_index(data->target)) == NULL)
969 0 17 if (checkout_conflicts_foreach(data, index, workdir, pathspec, checkout_conflict_append_update, data) < 0)
991 0 0 if (!conflict->ancestor)
1003 0 0 if (git_vector_bsearch2(&pos, &data->update_conflicts, checkout_conflicts_cmp_ancestor, path) < 0)
1016 0 0 git_vector_foreach(&data->update_conflicts, i, conflict) {
1019 0 0 if (conflict->ancestor)
1022 0 0 if (conflict->ours)
1024 0 0 else if (conflict->theirs)
1027 0 0 if (cmp == 0)
1048 0 0 if (!name_entry->ancestor) {
1054 0 0 if (!name_entry->ours && !name_entry->theirs) {
0 0 if (!name_entry->ours && !name_entry->theirs) {
1060 0 0 if ((ancestor = checkout_conflicts_search_ancestor(data,
1069 0 0 if (name_entry->ours) {
1070 0 0 if (strcmp(name_entry->ancestor, name_entry->ours) == 0)
1072 0 0 else if ((ours = checkout_conflicts_search_branch(data, name_entry->ours)) == NULL ||
0 0 else if ((ours = checkout_conflicts_search_branch(data, name_entry->ours)) == NULL ||
1082 0 0 if (name_entry->theirs) {
1083 0 0 if (strcmp(name_entry->ancestor, name_entry->theirs) == 0)
1085 0 0 else if (name_entry->ours && strcmp(name_entry->ours, name_entry->theirs) == 0)
0 0 else if (name_entry->ours && strcmp(name_entry->ours, name_entry->theirs) == 0)
1087 0 0 else if ((theirs = checkout_conflicts_search_branch(data, name_entry->theirs)) == NULL ||
0 0 else if ((theirs = checkout_conflicts_search_branch(data, name_entry->theirs)) == NULL ||
1114 36 17 if ((index = git_iterator_index(data->target)) == NULL)
1120 0 17 for (i = 0; i < names; i++) {
1123 0 0 if ((error = checkout_conflicts_load_byname_entry(
1128 0 0 if (our_conflict && our_conflict != ancestor_conflict) {
0 0 if (our_conflict && our_conflict != ancestor_conflict) {
1132 0 0 if (our_conflict->theirs)
1135 0 0 if (our_conflict->name_collision)
1139 0 0 if (their_conflict && their_conflict != ancestor_conflict) {
0 0 if (their_conflict && their_conflict != ancestor_conflict) {
1143 0 0 if (their_conflict->ours)
1146 0 0 if (their_conflict->name_collision)
1150 0 0 if (our_conflict && our_conflict != ancestor_conflict &&
0 0 if (our_conflict && our_conflict != ancestor_conflict &&
0 0 if (our_conflict && our_conflict != ancestor_conflict &&
1151 0 0 their_conflict && their_conflict != ancestor_conflict)
1172 36 17 if ((index = git_iterator_index(data->target)) == NULL)
1178 3 17 git_vector_foreach(&data->update_conflicts, i, conflict) {
1179 3 0 if ((conflict->ours && conflict->theirs) ||
0 3 if ((conflict->ours && conflict->theirs) ||
0 0 if ((conflict->ours && conflict->theirs) ||
1180 0 0 (!conflict->ours && !conflict->theirs))
1184 0 0 conflict->ours->path : conflict->theirs->path;
1186 0 0 if ((error = git_index_find(&j, index, path)) < 0) {
1187 0 0 if (error == GIT_ENOTFOUND)
1194 0 0 for (; j < len; j++) {
1195 0 0 if ((entry = git_index_get_byindex(index, j)) == NULL) {
1204 0 0 if (prefixed == GIT_PATH_EQUAL)
1207 0 0 if (prefixed == GIT_PATH_PREFIX)
1225 0 53 if (data->strategy & GIT_CHECKOUT_SKIP_UNMERGED)
1228 53 0 if ((error = checkout_conflicts_load(data, workdir, pathspec)) < 0 ||
53 0 if ((error = checkout_conflicts_load(data, workdir, pathspec)) < 0 ||
1246 0 0 assert(ancestor || ours || theirs);
0 0 assert(ancestor || ours || theirs);
0 0 assert(ancestor || ours || theirs);
1248 0 0 if (ancestor)
1250 0 0 else if (ours)
1252 0 0 else if (theirs)
1257 0 0 GIT_ERROR_CHECK_ALLOC(name);
1267 2 51 if ((data->strategy & GIT_CHECKOUT_DONT_UPDATE_INDEX) != 0)
1280 7 108 if (action & CHECKOUT_ACTION__REMOVE) {
1281 0 7 if (!git_path_isvalid(repo, delta->old_file.path, delta->old_file.mode, flags)) {
1287 31 84 if (action & ~CHECKOUT_ACTION__REMOVE) {
1288 0 31 if (!git_path_isvalid(repo, delta->new_file.path, delta->new_file.mode, flags)) {
1311 0 53 if (git_pool_init(&pathpool, 1) < 0)
1318 2 51 if ((error = git_iterator_current(&wditem, workdir)) < 0 &&
0 2 if ((error = git_iterator_current(&wditem, workdir)) < 0 &&
1325 53 0 *actions_ptr = actions = git__calloc(
1327 53 0 if (!counts || !actions) {
0 53 if (!counts || !actions) {
1332 115 53 git_vector_foreach(deltas, i, delta) {
1333 115 0 if ((error = checkout_action(&act, data, delta, workdir, &wditem, &pathspec)) == 0)
1336 0 115 if (error != 0)
1341 7 108 if (act & CHECKOUT_ACTION__REMOVE)
1343 31 84 if (act & CHECKOUT_ACTION__UPDATE_BLOB)
1345 0 115 if (act & CHECKOUT_ACTION__UPDATE_SUBMODULE)
1347 0 115 if (act & CHECKOUT_ACTION__CONFLICT)
1352 0 53 if (error)
1357 0 53 if (counts[CHECKOUT_ACTION__CONFLICT] > 0 &&
0 0 if (counts[CHECKOUT_ACTION__CONFLICT] > 0 &&
1359 0 0 git_error_set(GIT_ERROR_CHECKOUT, "%"PRIuZ" %s checkout",
1368 53 0 if ((error = checkout_get_remove_conflicts(data, workdir, &pathspec)) < 0 ||
53 0 if ((error = checkout_get_remove_conflicts(data, workdir, &pathspec)) < 0 ||
1396 0 34 if (git_repository__configmap_lookup(&ignorecase, data->repo, GIT_CONFIGMAP_IGNORECASE) < 0) {
1400 0 34 return (ignorecase &&
0 0 return (ignorecase &&
1437 0 34 unsigned int flags =
1442 0 34 if ((error = checkout_mkdir(
1446 0 34 if (remove_existing) {
1449 0 0 if (p_lstat(path, &st) == 0) {
1457 0 0 } else if (errno != ENOENT) {
1481 0 31 if ((ret = p_write(stream->fd, buffer, len)) < 0)
1490 31 0 assert(stream && stream->open);
0 31 assert(stream && stream->open);
1511 0 31 data->opts.file_mode : entry_filemode;
1519 31 0 if (hint_path == NULL)
1522 0 31 if ((error = mkpath2file(data, path, data->opts.dir_mode)) < 0)
1525 0 31 if (flags <= 0)
1527 0 31 if (!(mode = file_mode))
1530 0 31 if ((fd = p_open(path, flags, mode)) < 0) {
1538 31 0 if (!data->opts.disable_filters &&
0 31 if (!data->opts.disable_filters &&
1557 0 31 assert(writer.open == 0);
1561 0 31 if (error < 0)
1564 31 0 if (st) {
1567 0 31 if ((error = p_stat(path, st)) < 0) {
1587 0 0 if ((error = mkpath2file(data, path, data->opts.dir_mode)) < 0)
1590 0 0 if ((error = git_blob__getbuf(&linktarget, blob)) < 0)
1593 0 0 if (data->can_symlink) {
1594 0 0 if ((error = p_symlink(git_buf_cstr(&linktarget), path)) < 0)
1600 0 0 if (!error) {
1603 0 0 if ((error = p_lstat(path, st)) < 0)
1621 0 29 if (!data->index)
1640 0 0 if ((data->strategy & GIT_CHECKOUT_DONT_UPDATE_INDEX) != 0)
1643 0 0 if (checkout_target_fullpath(&fullpath, data, file->path) < 0)
1647 0 0 if (p_stat(fullpath->ptr, &st) < 0) {
1666 0 0 if ((data->strategy & GIT_CHECKOUT_UPDATE_ONLY) != 0)
1669 0 0 if ((error = checkout_mkdir(
0 0 if ((error = checkout_mkdir(
1675 0 0 if ((error = git_submodule_lookup(NULL, data->repo, file->path)) < 0) {
1679 0 0 if (error == GIT_ENOTFOUND) {
1703 3 103 if (data->opts.progress_cb)
1716 0 0 if (p_lstat(path, &st) < 0) {
1718 0 0 if (errno == ENOENT || errno == ENOTDIR)
0 0 if (errno == ENOENT || errno == ENOTDIR)
1727 0 0 if ((st.st_mode & ~0777) == (expected_mode & ~0777))
1744 0 31 if ((error = git_blob_lookup(&blob, data->repo, oid)) < 0)
1747 0 31 if (S_ISLNK(mode))
1758 0 31 if ((data->strategy & GIT_CHECKOUT_ALLOW_CONFLICTS) != 0 &&
0 0 if ((data->strategy & GIT_CHECKOUT_ALLOW_CONFLICTS) != 0 &&
1759 0 0 (error == GIT_ENOTFOUND || error == GIT_EEXISTS))
1776 0 31 if (checkout_target_fullpath(&fullpath, data, file->path) < 0)
1779 0 31 if ((data->strategy & GIT_CHECKOUT_UPDATE_ONLY) != 0) {
1783 0 0 if (rval <= 0)
1791 31 0 if (!error && (data->strategy & GIT_CHECKOUT_DONT_UPDATE_INDEX) == 0)
29 2 if (!error && (data->strategy & GIT_CHECKOUT_DONT_UPDATE_INDEX) == 0)
1795 31 0 if (!error && strcmp(file->path, ".gitmodules") == 0)
0 31 if (!error && strcmp(file->path, ".gitmodules") == 0)
1813 0 13 if (data->opts.checkout_strategy & GIT_CHECKOUT_SKIP_LOCKED_DIRECTORIES)
1816 0 13 if (checkout_target_fullpath(&fullpath, data, NULL) < 0)
1819 29 13 git_vector_foreach(&data->diff->deltas, i, delta) {
1820 7 22 if (actions[i] & CHECKOUT_ACTION__REMOVE) {
1824 0 7 if (error < 0)
1830 7 0 if ((actions[i] & CHECKOUT_ACTION__UPDATE_BLOB) == 0 &&
7 0 if ((actions[i] & CHECKOUT_ACTION__UPDATE_BLOB) == 0 &&
1831 7 0 (data->strategy & GIT_CHECKOUT_DONT_UPDATE_INDEX) == 0 &&
1839 12 13 git_vector_foreach(&data->removes, i, str) {
1841 0 12 if (error < 0)
1847 12 0 if ((data->strategy & GIT_CHECKOUT_DONT_UPDATE_INDEX) == 0 &&
12 0 if ((data->strategy & GIT_CHECKOUT_DONT_UPDATE_INDEX) == 0 &&
1850 1 11 if (str[strlen(str) - 1] == '/')
1868 62 29 git_vector_foreach(&data->diff->deltas, i, delta) {
1869 31 31 if (actions[i] & CHECKOUT_ACTION__UPDATE_BLOB && !S_ISLNK(delta->new_file.mode)) {
31 0 if (actions[i] & CHECKOUT_ACTION__UPDATE_BLOB && !S_ISLNK(delta->new_file.mode)) {
1870 0 31 if ((error = checkout_blob(data, &delta->new_file)) < 0)
1877 62 29 git_vector_foreach(&data->diff->deltas, i, delta) {
1878 31 31 if (actions[i] & CHECKOUT_ACTION__UPDATE_BLOB && S_ISLNK(delta->new_file.mode)) {
0 31 if (actions[i] & CHECKOUT_ACTION__UPDATE_BLOB && S_ISLNK(delta->new_file.mode)) {
1879 0 0 if ((error = checkout_blob(data, &delta->new_file)) < 0)
1896 0 0 git_vector_foreach(&data->diff->deltas, i, delta) {
1897 0 0 if (actions[i] & CHECKOUT_ACTION__UPDATE_SUBMODULE) {
1899 0 0 if (error < 0)
1916 67 0 if (!(error = git_repository_head(&ref, repo)) &&
67 0 if (!(error = git_repository_head(&ref, repo)) &&
1932 0 0 git_buf_putc(out, ':') < 0 ||
1944 0 0 if ((error = git_buf_putc(path, '~')) < 0 || (error = git_buf_puts(path, suffix)) < 0)
0 0 if ((error = git_buf_putc(path, '~')) < 0 || (error = git_buf_puts(path, suffix)) < 0)
1949 0 0 while (git_path_exists(git_buf_cstr(path)) && i < INT_MAX) {
0 0 while (git_path_exists(git_buf_cstr(path)) && i < INT_MAX) {
1952 0 0 if ((error = git_buf_putc(path, '_')) < 0 ||
0 0 if ((error = git_buf_putc(path, '_')) < 0 ||
1959 0 0 if (i == INT_MAX) {
1979 0 0 assert (side == conflict->ours || side == conflict->theirs);
0 0 assert (side == conflict->ours || side == conflict->theirs);
1981 0 0 if (checkout_target_fullpath(&fullpath, data, side->path) < 0)
1984 0 0 if ((conflict->name_collision || conflict->directoryfile) &&
0 0 if ((conflict->name_collision || conflict->directoryfile) &&
0 0 if ((conflict->name_collision || conflict->directoryfile) &&
1985 0 0 (data->strategy & GIT_CHECKOUT_USE_OURS) == 0 &&
1988 0 0 if (side == conflict->ours)
1989 0 0 suffix = data->opts.our_label ? data->opts.our_label :
1992 0 0 suffix = data->opts.their_label ? data->opts.their_label :
1995 0 0 if (checkout_path_suffixed(fullpath, suffix) < 0)
2001 0 0 if ((data->strategy & GIT_CHECKOUT_UPDATE_ONLY) != 0 &&
0 0 if ((data->strategy & GIT_CHECKOUT_UPDATE_ONLY) != 0 &&
2005 0 0 if (!S_ISGITLINK(side->mode))
2018 0 0 if ((error = checkout_write_entry(data, conflict, conflict->ours)) >= 0)
2033 0 3 if ((error = git_buf_joinpath(out, git_repository_workdir(data->repo), result->path)) < 0)
2037 3 0 if (!conflict->name_collision)
2041 0 0 our_label_raw = data->opts.our_label ? data->opts.our_label : "ours";
2042 0 0 their_label_raw = data->opts.their_label ? data->opts.their_label : "theirs";
2043 0 0 suffix = strcmp(result->path, conflict->ours->path) == 0 ? our_label_raw : their_label_raw;
2045 0 0 if ((error = checkout_path_suffixed(out, suffix)) < 0)
2065 0 3 if (data->opts.checkout_strategy & GIT_CHECKOUT_CONFLICT_STYLE_DIFF3)
2069 2 1 data->opts.ancestor_label : "ancestor";
2071 3 0 data->opts.our_label : "ours";
2073 3 0 data->opts.their_label : "theirs";
2078 3 0 if (conflict->ours && conflict->theirs &&
3 0 if (conflict->ours && conflict->theirs &&
0 3 if (conflict->ours && conflict->theirs &&
2081 0 0 if ((error = conflict_entry_name(
2082 0 0 &our_label, opts.our_label, conflict->ours->path)) < 0 ||
2091 0 3 if ((error = git_merge_file_from_index(&result, data->repo,
2095 3 0 if (result.path == NULL || result.mode == 0) {
0 3 if (result.path == NULL || result.mode == 0) {
2101 0 3 if ((error = checkout_merge_path(&path_workdir, data, conflict, &result)) < 0)
2104 0 3 if ((data->strategy & GIT_CHECKOUT_UPDATE_ONLY) != 0 &&
0 0 if ((data->strategy & GIT_CHECKOUT_UPDATE_ONLY) != 0 &&
2108 3 0 if (!data->opts.disable_filters) {
2115 3 0 if ((error = git_filter_list__load_ext(
2117 3 0 GIT_FILTER_TO_WORKTREE, &filter_opts)) < 0 ||
2125 3 0 if ((error = mkpath2file(data, path_workdir.ptr, data->opts.dir_mode)) < 0 ||
3 0 if ((error = mkpath2file(data, path_workdir.ptr, data->opts.dir_mode)) < 0 ||
2126 3 0 (error = git_filebuf_open(&output, git_buf_cstr(&path_workdir), GIT_FILEBUF_DO_NOT_BUFFER, result.mode)) < 0 ||
2151 9 0 if (error == GIT_ENOTFOUND)
2153 0 0 else if (error < 0)
2165 3 0 if (conflict->ancestor)
2168 3 0 if (!error && conflict->ours)
3 0 if (!error && conflict->ours)
2171 3 0 if (!error && conflict->theirs)
3 0 if (!error && conflict->theirs)
2183 3 3 git_vector_foreach(&data->update_conflicts, i, conflict) {
2186 0 3 if (conflict->ours == NULL && conflict->theirs == NULL)
0 0 if (conflict->ours == NULL && conflict->theirs == NULL)
2189 0 3 else if ((data->strategy & GIT_CHECKOUT_USE_OURS) &&
0 0 else if ((data->strategy & GIT_CHECKOUT_USE_OURS) &&
2192 0 3 else if ((data->strategy & GIT_CHECKOUT_USE_THEIRS) &&
0 0 else if ((data->strategy & GIT_CHECKOUT_USE_THEIRS) &&
2197 0 3 else if ((data->strategy & GIT_CHECKOUT_USE_OURS) &&
0 0 else if ((data->strategy & GIT_CHECKOUT_USE_OURS) &&
2198 0 0 !conflict->ours && conflict->name_collision)
2200 0 3 else if ((data->strategy & GIT_CHECKOUT_USE_THEIRS) &&
0 0 else if ((data->strategy & GIT_CHECKOUT_USE_THEIRS) &&
2201 0 0 !conflict->theirs && conflict->name_collision)
2207 3 0 else if (conflict->ours != NULL && conflict->theirs == NULL)
0 3 else if (conflict->ours != NULL && conflict->theirs == NULL)
2209 0 3 else if (conflict->ours == NULL && conflict->theirs != NULL)
0 0 else if (conflict->ours == NULL && conflict->theirs != NULL)
2215 0 3 else if (conflict->one_to_two)
2219 0 3 else if (S_ISLNK(conflict->ours->mode) &&
0 0 else if (S_ISLNK(conflict->ours->mode) &&
2223 0 3 else if (S_ISLNK(conflict->ours->mode))
2225 0 3 else if (S_ISLNK(conflict->theirs->mode))
2229 0 3 else if (conflict->submodule)
2233 0 3 else if (conflict->binary)
2236 3 0 else if (!error)
2242 3 0 if (!error && (data->strategy & GIT_CHECKOUT_DONT_UPDATE_INDEX) == 0)
3 0 if (!error && (data->strategy & GIT_CHECKOUT_DONT_UPDATE_INDEX) == 0)
2245 0 3 if (error)
2249 3 0 report_progress(data,
2251 0 0 (conflict->theirs ? conflict->theirs->path : conflict->ancestor->path));
2262 0 0 git_vector_foreach(&data->remove_conflicts, i, conflict) {
2263 0 0 if (git_index_conflict_remove(data->index, conflict) < 0)
2279 0 52 if ((data->strategy & GIT_CHECKOUT_UPDATE_ONLY) != 0)
2282 16 36 if (data->update_reuc) {
2283 2 16 git_vector_foreach(data->update_reuc, i, reuc_entry) {
2284 0 2 if ((error = git_index_reuc_add(data->index, reuc_entry->path,
2292 16 36 if (data->update_names) {
2293 0 16 git_vector_foreach(data->update_names, i, name_entry) {
2294 0 0 if ((error = git_index_name_add(data->index, name_entry->ancestor,
2306 51 2 if (data->opts_free_baseline) {
2342 0 53 if (!repo) {
2347 53 0 if ((!proposed || !proposed->target_directory) &&
53 0 if ((!proposed || !proposed->target_directory) &&
0 53 if ((!proposed || !proposed->target_directory) &&
2354 0 53 GIT_ERROR_CHECK_VERSION(
2357 0 53 if (!proposed)
2362 53 0 if (!data->opts.target_directory)
2364 0 0 else if (!git_path_isdir(data->opts.target_directory) &&
0 0 else if (!git_path_isdir(data->opts.target_directory) &&
2370 0 53 if ((error = git_repository_index(&data->index, data->repo)) < 0)
2374 51 2 if ((data->opts.checkout_strategy & GIT_CHECKOUT_NO_REFRESH) == 0) {
2377 0 51 if ((error = git_repository_config__weakptr(&cfg, repo)) < 0)
2384 50 1 if (data->index != git_iterator_index(target)) {
2385 24 26 if (data->opts.checkout_strategy & GIT_CHECKOUT_FORCE) {
2387 0 24 if ((error = git_index_read(data->index, false)) < 0)
2395 0 26 if (git_index_has_conflicts(data->index)) {
2402 0 26 if ((error = git_index_read_safely(data->index)) < 0)
2413 25 28 if ((data->opts.checkout_strategy & GIT_CHECKOUT_FORCE) != 0)
2420 2 51 if (!data->index->on_disk &&
2 0 if (!data->index->on_disk &&
2428 53 0 if (!data->opts.dir_mode)
2431 53 0 if (!data->opts.file_open_flags)
2436 0 53 if ((error = git_repository__configmap_lookup(
2440 0 53 if ((error = git_repository__configmap_lookup(
2444 53 0 if (!data->opts.baseline && !data->opts.baseline_index) {
51 2 if (!data->opts.baseline && !data->opts.baseline_index) {
2451 49 2 if (data->index->on_disk)
2454 0 51 if (error == GIT_EUNBORNBRANCH) {
2459 0 51 if (error < 0)
2463 53 0 if ((data->opts.checkout_strategy &
2468 53 0 if ((error = git_repository_config__weakptr(&cfg, repo)) < 0 ||
11 42 if ((error = git_repository_config__weakptr(&cfg, repo)) < 0 ||
2469 11 0 (error = git_config_get_entry(&conflict_style, cfg, "merge.conflictstyle")) < 0 ||
2472 0 11 else if (error)
2474 11 0 else if (strcmp(conflict_style->value, "merge") == 0)
2476 0 0 else if (strcmp(conflict_style->value, "diff3") == 0)
2488 53 0 if ((error = git_pool_init(&data->pool, 1)) < 0 ||
53 0 if ((error = git_pool_init(&data->pool, 1)) < 0 ||
2489 53 0 (error = git_vector_init(&data->removes, 0, git__strcmp_cb)) < 0 ||
2490 53 0 (error = git_vector_init(&data->remove_conflicts, 0, NULL)) < 0 ||
2491 53 0 (error = git_vector_init(&data->update_conflicts, 0, NULL)) < 0 ||
2492 53 0 (error = git_buf_puts(&data->target_path, data->opts.target_directory)) < 0 ||
2493 53 0 (error = git_path_to_dir(&data->target_path)) < 0 ||
2502 0 53 if (error < 0)
2515 159 0 if (checkout_opts &&
0 159 if (checkout_opts &&
2538 0 53 if (error < 0)
2551 0 53 if (data.opts.checkout_strategy & GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH)
2553 2 51 if (data.opts.paths.count > 0)
2558 0 53 workdir_opts.flags = git_iterator_ignore_case(target) ?
2566 53 0 if ((error = git_iterator_reset_range(target, data.pfx, data.pfx)) < 0 ||
53 0 if ((error = git_iterator_reset_range(target, data.pfx, data.pfx)) < 0 ||
2572 0 53 baseline_opts.flags = git_iterator_ignore_case(target) ?
2579 2 51 if (data.opts.baseline_index) {
2580 0 2 if ((error = git_iterator_for_index(
2585 0 51 if ((error = git_iterator_for_tree(
2591 0 53 assert(git_iterator_ignore_case(workdir) == git_iterator_ignore_case(baseline));
2596 0 53 if ((error = git_diff__from_iterators(
2604 0 53 if ((error = checkout_get_actions(&actions, &counts, &data, workdir)) != 0)
2618 13 40 if (counts[CHECKOUT_ACTION__REMOVE] > 0 &&
0 13 if (counts[CHECKOUT_ACTION__REMOVE] > 0 &&
2622 0 53 if (counts[CHECKOUT_ACTION__REMOVE_CONFLICT] > 0 &&
0 0 if (counts[CHECKOUT_ACTION__REMOVE_CONFLICT] > 0 &&
2626 29 24 if (counts[CHECKOUT_ACTION__UPDATE_BLOB] > 0 &&
0 29 if (counts[CHECKOUT_ACTION__UPDATE_BLOB] > 0 &&
2630 0 53 if (counts[CHECKOUT_ACTION__UPDATE_SUBMODULE] > 0 &&
0 0 if (counts[CHECKOUT_ACTION__UPDATE_SUBMODULE] > 0 &&
2634 3 50 if (counts[CHECKOUT_ACTION__UPDATE_CONFLICT] > 0 &&
0 3 if (counts[CHECKOUT_ACTION__UPDATE_CONFLICT] > 0 &&
2638 52 1 if (data.index != git_iterator_index(target) &&
0 52 if (data.index != git_iterator_index(target) &&
2642 0 53 assert(data.completed_steps == data.total_steps);
2644 0 53 if (data.opts.perfdata_cb)
2648 53 0 if (!error && data.index != NULL &&
53 0 if (!error && data.index != NULL &&
37 16 if (!error && data.index != NULL &&
2671 0 17 if (!index && !repo) {
0 0 if (!index && !repo) {
2677 17 0 if (index && repo &&
2678 0 1 git_index_owner(index) &&
2683 17 0 } else if(index && repo && !git_index_owner(index)) {
17 0 } else if(index && repo && !git_index_owner(index)) {
16 1 } else if(index && repo && !git_index_owner(index)) {
2688 0 17 if (!repo)
2691 0 17 if (!index && (error = git_repository_index__weakptr(&index, repo)) < 0)
0 0 if (!index && (error = git_repository_index__weakptr(&index, repo)) < 0)
2697 17 0 if (!(error = git_iterator_for_index(&index_i, repo, index, &iter_opts)))
2700 16 1 if (owned)
2720 18 18 if (!treeish && !repo) {
0 18 if (!treeish && !repo) {
2725 18 18 if (treeish && repo && git_object_owner(treeish) != repo) {
18 0 if (treeish && repo && git_object_owner(treeish) != repo) {
0 18 if (treeish && repo && git_object_owner(treeish) != repo) {
2731 0 36 if (!repo)
2734 18 18 if (treeish) {
2735 0 18 if (git_object_peel((git_object **)&tree, treeish, GIT_OBJECT_TREE) < 0) {
2742 0 18 if ((error = checkout_lookup_head_tree(&tree, repo)) < 0) {
2743 0 0 if (error != GIT_EUNBORNBRANCH)
2751 0 36 if ((error = git_repository_index(&index, repo)) < 0)
2756 36 0 if (!(error = git_iterator_for_tree(&tree_i, tree, &iter_opts)))
2770 0 2 assert(repo);
2776 0 0 GIT_INIT_STRUCTURE_FROM_TEMPLATE(