Branch Coverage

deps/libgit2/src/libgit2/checkout.c
Criterion Covered Total %
branch 412 1092 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 168 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 62 2 !git_index_entry_newer_than_index(ie, data->index) &&
220 62 0 git_index_time_eq(&wditem->mtime, &ie->mtime) &&
221 62 0 wditem->file_size == ie->file_size &&
232 2 43 if (baseitem->size && wditem->file_size != baseitem->size)
0 2 if (baseitem->size && wditem->file_size != baseitem->size)
236 0 45 if (S_ISDIR(wditem->mode))
239 0 45 if (is_filemode_changed(baseitem->mode, wditem->mode, data->respect_filemode))
242 0 45 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_str_puts(&data->target_path, path) < 0)
0 38 if (path && git_str_puts(&data->target_path, path) < 0)
332 0 51 if (git_path_validate_str_length(data->repo, &data->target_path) < 0)
345 53 7 if (wd->mode != GIT_FILEMODE_TREE)
348 0 7 if (checkout_target_fullpath(&full, data, wd->path) < 0)
351 7 0 return !full || !git_fs_path_contains(full, DOT_GIT);
7 0 return !full || !git_fs_path_contains(full, DOT_GIT);
357 0 12 GIT_ERROR_CHECK_ALLOC(copy);
373 2 60 if (!git_pathspec__match(
378 0 2 if (wd->mode == GIT_FILEMODE_TREE)
385 60 0 if (data->index != NULL) {
391 53 7 if (wd->mode != GIT_FILEMODE_TREE) {
392 4 49 if (!error) { /* found by git_index__find_pos call */
395 0 49 } else if (error != GIT_ENOTFOUND)
405 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)
410 4 56 if (notify != GIT_CHECKOUT_NOTIFY_NONE) {
412 0 4 if ((error = checkout_notify(data, notify, NULL, wd)) != 0)
415 4 0 if (remove && wd_item_is_removable(data, wd))
4 0 if (remove && wd_item_is_removable(data, wd))
418 4 0 if (!error)
432 8 48 if (error == GIT_ITEROVER)
434 0 48 else if (error < 0)
437 1 55 if (untracked_state == GIT_ITERATOR_STATUS_IGNORED) {
445 0 56 if ((error = checkout_notify(data, notify, NULL, &saved_wd)) != 0)
448 8 48 if (remove && removable)
8 0 if (remove && removable)
451 56 0 if (!error && over) /* restore ITEROVER if needed */
8 48 if (!error && over) /* restore ITEROVER if needed */
466 0 0 if (git_submodule_lookup(&sm, data->repo, path) < 0)
469 0 0 if (git_submodule_location(&sm_loc, sm) < 0 ||
0 0 if (git_submodule_location(&sm_loc, sm) < 0 ||
482 0 0 if (checkout_target_fullpath(&fullpath, data, path) < 0)
499 14 73 if (checkout_is_workdir_modified(data, &delta->old_file, &delta->new_file, wd)) {
500 0 14 GIT_ERROR_CHECK_ERROR(
506 0 1 if (git_iterator_current_is_ignored(workdir))
507 0 0 *action = CHECKOUT_ACTION_IF(DONT_OVERWRITE_IGNORED, CONFLICT, UPDATE_BLOB);
509 1 0 *action = CHECKOUT_ACTION_IF(FORCE, UPDATE_BLOB, CONFLICT);
512 0 8 if (checkout_is_workdir_modified(data, &delta->old_file, &delta->new_file, wd))
513 0 0 *action = CHECKOUT_ACTION_IF(FORCE, REMOVE, CONFLICT);
520 1 0 *action = CHECKOUT_ACTION_IF(FORCE, UPDATE_BLOB, CONFLICT);
522 11 0 *action = CHECKOUT_ACTION_IF(SAFE, UPDATE_BLOB, NONE);
525 0 0 if (delta->old_file.mode == GIT_FILEMODE_TREE) {
526 0 0 if (wd->mode == GIT_FILEMODE_TREE)
530 0 0 *action = CHECKOUT_ACTION_IF(SAFE, UPDATE_BLOB, NONE);
531 0 0 else if (wd->mode == GIT_FILEMODE_COMMIT) {
535 0 0 if (submodule_is_config_only(data, wd->path))
536 0 0 *action = CHECKOUT_ACTION_IF(SAFE, UPDATE_BLOB, NONE);
538 0 0 *action = CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, CONFLICT);
540 0 0 *action = CHECKOUT_ACTION_IF(FORCE, REMOVE, CONFLICT);
542 0 0 else if (checkout_is_workdir_modified(data, &delta->old_file, &delta->new_file, wd))
543 0 0 *action = CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, CONFLICT);
545 0 0 *action = CHECKOUT_ACTION_IF(SAFE, REMOVE_AND_UPDATE, NONE);
548 0 0 if (delta->new_file.mode == GIT_FILEMODE_TREE)
569 0 0 GIT_ERROR_CHECK_ERROR(
571 0 0 *action = CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, NONE);
575 0 0 *action = CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, CONFLICT);
578 0 0 *action = CHECKOUT_ACTION_IF(FORCE, REMOVE, CONFLICT);
582 0 0 *action = CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, CONFLICT);
602 0 0 GIT_ERROR_CHECK_ERROR(
604 0 0 GIT_ERROR_CHECK_ERROR(
606 0 0 *action = CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, NONE);
610 0 0 if (delta->old_file.mode == GIT_FILEMODE_COMMIT)
612 0 0 else if (delta->new_file.mode != GIT_FILEMODE_TREE)
614 0 0 CHECKOUT_ACTION_IF(DONT_OVERWRITE_IGNORED, CONFLICT, REMOVE_AND_UPDATE) :
0 0 CHECKOUT_ACTION_IF(DONT_OVERWRITE_IGNORED, CONFLICT, REMOVE_AND_UPDATE) :
615 0 0 CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, CONFLICT);
618 0 0 if (delta->old_file.mode != GIT_FILEMODE_TREE)
619 0 0 GIT_ERROR_CHECK_ERROR(
623 0 0 if (delta->old_file.mode == GIT_FILEMODE_TREE) {
630 0 0 *action = CHECKOUT_ACTION_IF(SAFE, UPDATE_BLOB, NONE);
632 0 0 else if (delta->new_file.mode != GIT_FILEMODE_TREE)
634 0 0 *action = CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, CONFLICT);
651 0 0 if (error == 0 && *action != CHECKOUT_ACTION__NONE)
0 0 if (error == 0 && *action != CHECKOUT_ACTION__NONE)
675 6 205 if (!wd)
688 96 109 if (cmp < 0) {
691 45 51 if (cmp == 0) {
692 44 1 if (wd->mode == GIT_FILEMODE_TREE) {
695 0 44 if (error < 0 && error != GIT_ITEROVER)
0 0 if (error < 0 && error != GIT_ITEROVER)
701 0 1 if (delta->old_file.path[strlen(wd->path)] == '/') {
711 0 52 if (error && error != GIT_ITEROVER)
0 0 if (error && error != GIT_ITEROVER)
716 108 1 if (cmp == 0) {
725 0 1 if (cmp == 0) { /* case 5 */
726 0 0 if (wd->path[strlen(delta->old_file.path)] != '/')
729 0 0 if (delta->status == GIT_DELTA_TYPECHANGE) {
730 0 0 if (delta->old_file.mode == GIT_FILEMODE_TREE) {
736 0 0 if (delta->new_file.mode == GIT_FILEMODE_TREE ||
0 0 if (delta->new_file.mode == GIT_FILEMODE_TREE ||
737 0 0 delta->new_file.mode == GIT_FILEMODE_COMMIT ||
747 0 0 checkout_action_with_wd_dir_empty(action, data, delta) :
756 108 0 if (!error && advance != NULL &&
108 0 if (!error && advance != NULL &&
41 67 if (!error && advance != NULL &&
759 41 0 if (error == GIT_ITEROVER)
774 10 53 while (wd && !error)
10 0 while (wd && !error)
777 10 43 if (error == GIT_ITEROVER)
787 0 0 if (!a && !b)
0 0 if (!a && !b)
789 0 0 else if (!a && b)
0 0 else if (!a && b)
791 0 0 else if(a && !b)
0 0 else if(a && !b)
803 0 0 if ((diff = checkout_idxentry_cmp(ca->ancestor, cb->ancestor)) == 0 &&
0 0 if ((diff = checkout_idxentry_cmp(ca->ancestor, cb->ancestor)) == 0 &&
817 0 3 if ((conflict = git_vector_get(conflicts, idx)) == NULL)
820 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)
836 3 0 if (ours && git_pathspec__match(pathspec, ours->path,
3 0 if (ours && git_pathspec__match(pathspec, ours->path,
841 0 0 if (theirs && git_pathspec__match(pathspec, theirs->path,
0 0 if (theirs && git_pathspec__match(pathspec, theirs->path,
846 0 0 if (ancestor && git_pathspec__match(pathspec, ancestor->path,
0 0 if (ancestor && git_pathspec__match(pathspec, ancestor->path,
856 3 0 conflict->submodule = ((conflict->ancestor && S_ISGITLINK(conflict->ancestor->mode)) ||
3 0 conflict->submodule = ((conflict->ancestor && S_ISGITLINK(conflict->ancestor->mode)) ||
857 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)) ||
858 0 3 (conflict->theirs && S_ISGITLINK(conflict->theirs->mode)));
867 0 3 if (conflict->submodule)
870 3 0 if (conflict->ancestor) {
871 0 3 if ((error = git_blob_lookup(&ancestor_blob, repo, &conflict->ancestor->id)) < 0)
877 3 0 if (!conflict->binary && conflict->ours) {
3 0 if (!conflict->binary && conflict->ours) {
878 0 3 if ((error = git_blob_lookup(&our_blob, repo, &conflict->ours->id)) < 0)
884 3 0 if (!conflict->binary && conflict->theirs) {
3 0 if (!conflict->binary && conflict->theirs) {
885 0 3 if ((error = git_blob_lookup(&their_blob, repo, &conflict->theirs->id)) < 0)
910 0 3 GIT_ERROR_CHECK_ALLOC(conflict);
916 3 0 if ((error = checkout_conflict_detect_submodule(conflict)) < 0 ||
0 3 if ((error = checkout_conflict_detect_submodule(conflict)) < 0 ||
923 0 3 if (git_vector_insert(&data->update_conflicts, conflict))
941 0 68 if ((error = git_index_conflict_iterator_new(&iterator, index)) < 0)
945 3 68 while ((error = git_index_conflict_next(&ancestor, &ours, &theirs, iterator)) == 0) {
946 0 3 if (!conflict_pathspec_match(data, workdir, pathspec, ancestor, ours, theirs))
949 0 3 if ((error = cb(ancestor, ours, theirs, payload)) < 0)
953 68 0 if (error == GIT_ITEROVER)
967 36 17 if ((index = git_iterator_index(data->target)) == NULL)
972 0 17 if (checkout_conflicts_foreach(data, index, workdir, pathspec, checkout_conflict_append_update, data) < 0)
994 0 0 if (!conflict->ancestor)
1006 0 0 if (git_vector_bsearch2(&pos, &data->update_conflicts, checkout_conflicts_cmp_ancestor, path) < 0)
1019 0 0 git_vector_foreach(&data->update_conflicts, i, conflict) {
1022 0 0 if (conflict->ancestor)
1025 0 0 if (conflict->ours)
1027 0 0 else if (conflict->theirs)
1030 0 0 if (cmp == 0)
1051 0 0 if (!name_entry->ancestor) {
1057 0 0 if (!name_entry->ours && !name_entry->theirs) {
0 0 if (!name_entry->ours && !name_entry->theirs) {
1063 0 0 if ((ancestor = checkout_conflicts_search_ancestor(data,
1072 0 0 if (name_entry->ours) {
1073 0 0 if (strcmp(name_entry->ancestor, name_entry->ours) == 0)
1075 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 ||
1085 0 0 if (name_entry->theirs) {
1086 0 0 if (strcmp(name_entry->ancestor, name_entry->theirs) == 0)
1088 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)
1090 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 ||
1117 36 17 if ((index = git_iterator_index(data->target)) == NULL)
1123 0 17 for (i = 0; i < names; i++) {
1126 0 0 if ((error = checkout_conflicts_load_byname_entry(
1131 0 0 if (our_conflict && our_conflict != ancestor_conflict) {
0 0 if (our_conflict && our_conflict != ancestor_conflict) {
1135 0 0 if (our_conflict->theirs)
1138 0 0 if (our_conflict->name_collision)
1142 0 0 if (their_conflict && their_conflict != ancestor_conflict) {
0 0 if (their_conflict && their_conflict != ancestor_conflict) {
1146 0 0 if (their_conflict->ours)
1149 0 0 if (their_conflict->name_collision)
1153 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 &&
1154 0 0 their_conflict && their_conflict != ancestor_conflict)
1175 36 17 if ((index = git_iterator_index(data->target)) == NULL)
1181 3 17 git_vector_foreach(&data->update_conflicts, i, conflict) {
1182 3 0 if ((conflict->ours && conflict->theirs) ||
0 3 if ((conflict->ours && conflict->theirs) ||
0 0 if ((conflict->ours && conflict->theirs) ||
1183 0 0 (!conflict->ours && !conflict->theirs))
1187 0 0 conflict->ours->path : conflict->theirs->path;
1189 0 0 if ((error = git_index_find(&j, index, path)) < 0) {
1190 0 0 if (error == GIT_ENOTFOUND)
1197 0 0 for (; j < len; j++) {
1198 0 0 if ((entry = git_index_get_byindex(index, j)) == NULL) {
1207 0 0 if (prefixed == GIT_FS_PATH_EQUAL)
1210 0 0 if (prefixed == GIT_FS_PATH_PREFIX)
1228 0 53 if (data->strategy & GIT_CHECKOUT_SKIP_UNMERGED)
1231 53 0 if ((error = checkout_conflicts_load(data, workdir, pathspec)) < 0 ||
53 0 if ((error = checkout_conflicts_load(data, workdir, pathspec)) < 0 ||
1249 0 0 GIT_ASSERT_ARG(ancestor || ours || theirs);
0 0 GIT_ASSERT_ARG(ancestor || ours || theirs);
0 0 GIT_ASSERT_ARG(ancestor || ours || theirs);
1251 0 0 if (ancestor)
1253 0 0 else if (ours)
1255 0 0 else if (theirs)
1260 0 0 GIT_ERROR_CHECK_ALLOC(name);
1270 2 51 if ((data->strategy & GIT_CHECKOUT_DONT_UPDATE_INDEX) != 0)
1283 7 108 if (action & CHECKOUT_ACTION__REMOVE) {
1284 0 7 if (!git_path_is_valid(repo, delta->old_file.path, delta->old_file.mode, flags)) {
1290 31 84 if (action & ~CHECKOUT_ACTION__REMOVE) {
1291 0 31 if (!git_path_is_valid(repo, delta->new_file.path, delta->new_file.mode, flags)) {
1314 0 53 if (git_pool_init(&pathpool, 1) < 0)
1321 2 51 if ((error = git_iterator_current(&wditem, workdir)) < 0 &&
0 2 if ((error = git_iterator_current(&wditem, workdir)) < 0 &&
1328 53 0 *actions_ptr = actions = git__calloc(
1330 53 0 if (!counts || !actions) {
0 53 if (!counts || !actions) {
1335 115 53 git_vector_foreach(deltas, i, delta) {
1336 115 0 if ((error = checkout_action(&act, data, delta, workdir, &wditem, &pathspec)) == 0)
1339 0 115 if (error != 0)
1344 7 108 if (act & CHECKOUT_ACTION__REMOVE)
1346 31 84 if (act & CHECKOUT_ACTION__UPDATE_BLOB)
1348 0 115 if (act & CHECKOUT_ACTION__UPDATE_SUBMODULE)
1350 0 115 if (act & CHECKOUT_ACTION__CONFLICT)
1355 0 53 if (error)
1360 0 53 if (counts[CHECKOUT_ACTION__CONFLICT] > 0 &&
0 0 if (counts[CHECKOUT_ACTION__CONFLICT] > 0 &&
1362 0 0 git_error_set(GIT_ERROR_CHECKOUT, "%"PRIuZ" %s checkout",
1371 53 0 if ((error = checkout_get_remove_conflicts(data, workdir, &pathspec)) < 0 ||
53 0 if ((error = checkout_get_remove_conflicts(data, workdir, &pathspec)) < 0 ||
1399 0 34 if (git_repository__configmap_lookup(&ignorecase, data->repo, GIT_CONFIGMAP_IGNORECASE) < 0) {
1403 0 34 return (ignorecase &&
0 0 return (ignorecase &&
1440 0 34 unsigned int flags =
1445 0 34 if ((error = checkout_mkdir(
1449 0 34 if (remove_existing) {
1452 0 0 if (p_lstat(path, &st) == 0) {
1460 0 0 } else if (errno != ENOENT) {
1484 0 31 if ((ret = p_write(stream->fd, buffer, len)) < 0)
1494 0 31 GIT_ASSERT_ARG(stream);
1495 0 31 GIT_ASSERT_ARG(stream->open);
1516 0 31 data->opts.file_mode : entry_filemode;
1524 0 31 GIT_ASSERT(hint_path != NULL);
1526 0 31 if ((error = mkpath2file(data, path, data->opts.dir_mode)) < 0)
1529 0 31 if (flags <= 0)
1531 0 31 if (!(mode = file_mode))
1534 0 31 if ((fd = p_open(path, flags, mode)) < 0) {
1542 31 0 if (!data->opts.disable_filters &&
0 31 if (!data->opts.disable_filters &&
1561 0 31 GIT_ASSERT(writer.open == 0);
1565 0 31 if (error < 0)
1568 31 0 if (st) {
1571 0 31 if ((error = p_stat(path, st)) < 0) {
1591 0 0 if ((error = mkpath2file(data, path, data->opts.dir_mode)) < 0)
1594 0 0 if ((error = git_blob__getbuf(&linktarget, blob)) < 0)
1597 0 0 if (data->can_symlink) {
1598 0 0 if ((error = p_symlink(git_str_cstr(&linktarget), path)) < 0)
1604 0 0 if (!error) {
1607 0 0 if ((error = p_lstat(path, st)) < 0)
1625 0 29 if (!data->index)
1644 0 0 if ((data->strategy & GIT_CHECKOUT_DONT_UPDATE_INDEX) != 0)
1647 0 0 if (checkout_target_fullpath(&fullpath, data, file->path) < 0)
1651 0 0 if (p_stat(fullpath->ptr, &st) < 0) {
1670 0 0 if ((data->strategy & GIT_CHECKOUT_UPDATE_ONLY) != 0)
1673 0 0 if ((error = checkout_mkdir(
0 0 if ((error = checkout_mkdir(
1679 0 0 if ((error = git_submodule_lookup(NULL, data->repo, file->path)) < 0) {
1683 0 0 if (error == GIT_ENOTFOUND) {
1707 3 103 if (data->opts.progress_cb)
1720 0 0 if (p_lstat(path, &st) < 0) {
1722 0 0 if (errno == ENOENT || errno == ENOTDIR)
0 0 if (errno == ENOENT || errno == ENOTDIR)
1731 0 0 if ((st.st_mode & ~0777) == (expected_mode & ~0777))
1748 0 31 if ((error = git_blob_lookup(&blob, data->repo, oid)) < 0)
1751 0 31 if (S_ISLNK(mode))
1762 0 31 if ((data->strategy & GIT_CHECKOUT_ALLOW_CONFLICTS) != 0 &&
0 0 if ((data->strategy & GIT_CHECKOUT_ALLOW_CONFLICTS) != 0 &&
1763 0 0 (error == GIT_ENOTFOUND || error == GIT_EEXISTS))
1780 0 31 if (checkout_target_fullpath(&fullpath, data, file->path) < 0)
1783 0 31 if ((data->strategy & GIT_CHECKOUT_UPDATE_ONLY) != 0) {
1787 0 0 if (rval <= 0)
1795 31 0 if (!error && (data->strategy & GIT_CHECKOUT_DONT_UPDATE_INDEX) == 0)
29 2 if (!error && (data->strategy & GIT_CHECKOUT_DONT_UPDATE_INDEX) == 0)
1799 31 0 if (!error && strcmp(file->path, ".gitmodules") == 0)
0 31 if (!error && strcmp(file->path, ".gitmodules") == 0)
1817 0 13 if (data->opts.checkout_strategy & GIT_CHECKOUT_SKIP_LOCKED_DIRECTORIES)
1820 0 13 if (checkout_target_fullpath(&fullpath, data, NULL) < 0)
1823 29 13 git_vector_foreach(&data->diff->deltas, i, delta) {
1824 7 22 if (actions[i] & CHECKOUT_ACTION__REMOVE) {
1828 0 7 if (error < 0)
1834 7 0 if ((actions[i] & CHECKOUT_ACTION__UPDATE_BLOB) == 0 &&
7 0 if ((actions[i] & CHECKOUT_ACTION__UPDATE_BLOB) == 0 &&
1835 7 0 (data->strategy & GIT_CHECKOUT_DONT_UPDATE_INDEX) == 0 &&
1843 12 13 git_vector_foreach(&data->removes, i, str) {
1845 0 12 if (error < 0)
1851 12 0 if ((data->strategy & GIT_CHECKOUT_DONT_UPDATE_INDEX) == 0 &&
12 0 if ((data->strategy & GIT_CHECKOUT_DONT_UPDATE_INDEX) == 0 &&
1854 1 11 if (str[strlen(str) - 1] == '/')
1872 62 29 git_vector_foreach(&data->diff->deltas, i, delta) {
1873 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)) {
1874 0 31 if ((error = checkout_blob(data, &delta->new_file)) < 0)
1881 62 29 git_vector_foreach(&data->diff->deltas, i, delta) {
1882 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)) {
1883 0 0 if ((error = checkout_blob(data, &delta->new_file)) < 0)
1900 0 0 git_vector_foreach(&data->diff->deltas, i, delta) {
1901 0 0 if (actions[i] & CHECKOUT_ACTION__UPDATE_SUBMODULE) {
1903 0 0 if (error < 0)
1920 67 0 if (!(error = git_repository_head(&ref, repo)) &&
67 0 if (!(error = git_repository_head(&ref, repo)) &&
1936 0 0 git_str_putc(out, ':') < 0 ||
1948 0 0 if ((error = git_str_putc(path, '~')) < 0 || (error = git_str_puts(path, suffix)) < 0)
0 0 if ((error = git_str_putc(path, '~')) < 0 || (error = git_str_puts(path, suffix)) < 0)
1953 0 0 while (git_fs_path_exists(git_str_cstr(path)) && i < INT_MAX) {
0 0 while (git_fs_path_exists(git_str_cstr(path)) && i < INT_MAX) {
1956 0 0 if ((error = git_str_putc(path, '_')) < 0 ||
0 0 if ((error = git_str_putc(path, '_')) < 0 ||
1963 0 0 if (i == INT_MAX) {
1983 0 0 GIT_ASSERT(side == conflict->ours || side == conflict->theirs);
0 0 GIT_ASSERT(side == conflict->ours || side == conflict->theirs);
1985 0 0 if (checkout_target_fullpath(&fullpath, data, side->path) < 0)
1988 0 0 if ((conflict->name_collision || conflict->directoryfile) &&
0 0 if ((conflict->name_collision || conflict->directoryfile) &&
0 0 if ((conflict->name_collision || conflict->directoryfile) &&
1989 0 0 (data->strategy & GIT_CHECKOUT_USE_OURS) == 0 &&
1992 0 0 if (side == conflict->ours)
1993 0 0 suffix = data->opts.our_label ? data->opts.our_label :
1996 0 0 suffix = data->opts.their_label ? data->opts.their_label :
1999 0 0 if (checkout_path_suffixed(fullpath, suffix) < 0)
2005 0 0 if ((data->strategy & GIT_CHECKOUT_UPDATE_ONLY) != 0 &&
0 0 if ((data->strategy & GIT_CHECKOUT_UPDATE_ONLY) != 0 &&
2009 0 0 if (!S_ISGITLINK(side->mode))
2022 0 0 if ((error = checkout_write_entry(data, conflict, conflict->ours)) >= 0)
2037 3 0 if ((error = git_str_joinpath(out, data->opts.target_directory, result->path)) < 0 ||
0 3 if ((error = git_str_joinpath(out, data->opts.target_directory, result->path)) < 0 ||
2042 3 0 if (!conflict->name_collision)
2046 0 0 our_label_raw = data->opts.our_label ? data->opts.our_label : "ours";
2047 0 0 their_label_raw = data->opts.their_label ? data->opts.their_label : "theirs";
2048 0 0 suffix = strcmp(result->path, conflict->ours->path) == 0 ? our_label_raw : their_label_raw;
2050 0 0 if ((error = checkout_path_suffixed(out, suffix)) < 0)
2070 0 3 if (data->opts.checkout_strategy & GIT_CHECKOUT_CONFLICT_STYLE_DIFF3)
2073 0 3 if (data->opts.checkout_strategy & GIT_CHECKOUT_CONFLICT_STYLE_ZDIFF3)
2077 2 1 data->opts.ancestor_label : "ancestor";
2079 3 0 data->opts.our_label : "ours";
2081 3 0 data->opts.their_label : "theirs";
2086 3 0 if (conflict->ours && conflict->theirs &&
3 0 if (conflict->ours && conflict->theirs &&
0 3 if (conflict->ours && conflict->theirs &&
2089 0 0 if ((error = conflict_entry_name(
2090 0 0 &our_label, opts.our_label, conflict->ours->path)) < 0 ||
2099 0 3 if ((error = git_merge_file_from_index(&result, data->repo,
2103 3 0 if (result.path == NULL || result.mode == 0) {
0 3 if (result.path == NULL || result.mode == 0) {
2109 0 3 if ((error = checkout_merge_path(&path_workdir, data, conflict, &result)) < 0)
2112 0 3 if ((data->strategy & GIT_CHECKOUT_UPDATE_ONLY) != 0 &&
0 0 if ((data->strategy & GIT_CHECKOUT_UPDATE_ONLY) != 0 &&
2116 3 0 if (!data->opts.disable_filters) {
2123 3 0 if ((error = git_filter_list__load(
2125 3 0 GIT_FILTER_TO_WORKTREE, &filter_session)) < 0 ||
2133 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 ||
2134 3 0 (error = git_filebuf_open(&output, git_str_cstr(&path_workdir), GIT_FILEBUF_DO_NOT_BUFFER, result.mode)) < 0 ||
2159 9 0 if (error == GIT_ENOTFOUND)
2161 0 0 else if (error < 0)
2173 3 0 if (conflict->ancestor)
2176 3 0 if (!error && conflict->ours)
3 0 if (!error && conflict->ours)
2179 3 0 if (!error && conflict->theirs)
3 0 if (!error && conflict->theirs)
2191 3 3 git_vector_foreach(&data->update_conflicts, i, conflict) {
2194 0 3 if (conflict->ours == NULL && conflict->theirs == NULL)
0 0 if (conflict->ours == NULL && conflict->theirs == NULL)
2197 0 3 else if ((data->strategy & GIT_CHECKOUT_USE_OURS) &&
0 0 else if ((data->strategy & GIT_CHECKOUT_USE_OURS) &&
2200 0 3 else if ((data->strategy & GIT_CHECKOUT_USE_THEIRS) &&
0 0 else if ((data->strategy & GIT_CHECKOUT_USE_THEIRS) &&
2205 0 3 else if ((data->strategy & GIT_CHECKOUT_USE_OURS) &&
0 0 else if ((data->strategy & GIT_CHECKOUT_USE_OURS) &&
2206 0 0 !conflict->ours && conflict->name_collision)
2208 0 3 else if ((data->strategy & GIT_CHECKOUT_USE_THEIRS) &&
0 0 else if ((data->strategy & GIT_CHECKOUT_USE_THEIRS) &&
2209 0 0 !conflict->theirs && conflict->name_collision)
2215 3 0 else if (conflict->ours != NULL && conflict->theirs == NULL)
0 3 else if (conflict->ours != NULL && conflict->theirs == NULL)
2217 0 3 else if (conflict->ours == NULL && conflict->theirs != NULL)
0 0 else if (conflict->ours == NULL && conflict->theirs != NULL)
2223 0 3 else if (conflict->one_to_two)
2227 0 3 else if (S_ISLNK(conflict->ours->mode) &&
0 0 else if (S_ISLNK(conflict->ours->mode) &&
2231 0 3 else if (S_ISLNK(conflict->ours->mode))
2233 0 3 else if (S_ISLNK(conflict->theirs->mode))
2237 0 3 else if (conflict->submodule)
2241 0 3 else if (conflict->binary)
2244 3 0 else if (!error)
2250 3 0 if (!error && (data->strategy & GIT_CHECKOUT_DONT_UPDATE_INDEX) == 0)
3 0 if (!error && (data->strategy & GIT_CHECKOUT_DONT_UPDATE_INDEX) == 0)
2253 0 3 if (error)
2257 3 0 report_progress(data,
2259 0 0 (conflict->theirs ? conflict->theirs->path : conflict->ancestor->path));
2270 0 0 git_vector_foreach(&data->remove_conflicts, i, conflict) {
2271 0 0 if (git_index_conflict_remove(data->index, conflict) < 0)
2287 0 52 if ((data->strategy & GIT_CHECKOUT_UPDATE_ONLY) != 0)
2290 16 36 if (data->update_reuc) {
2291 2 16 git_vector_foreach(data->update_reuc, i, reuc_entry) {
2292 0 2 if ((error = git_index_reuc_add(data->index, reuc_entry->path,
2300 16 36 if (data->update_names) {
2301 0 16 git_vector_foreach(data->update_names, i, name_entry) {
2302 0 0 if ((error = git_index_name_add(data->index, name_entry->ancestor,
2314 51 2 if (data->opts_free_baseline) {
2344 0 0 if ((error = git_path_validate_length(data->repo, data->opts.target_directory)) < 0)
2347 0 0 if (git_fs_path_isdir(data->opts.target_directory))
2366 0 53 if (!repo) {
2371 53 0 if ((!proposed || !proposed->target_directory) &&
53 0 if ((!proposed || !proposed->target_directory) &&
0 53 if ((!proposed || !proposed->target_directory) &&
2378 0 53 GIT_ERROR_CHECK_VERSION(
2381 0 53 if (!proposed)
2386 53 0 if (!data->opts.target_directory)
2388 0 0 else if ((error = validate_target_directory(data)) < 0)
2391 0 53 if ((error = git_repository_index(&data->index, data->repo)) < 0)
2395 51 2 if ((data->opts.checkout_strategy & GIT_CHECKOUT_NO_REFRESH) == 0) {
2398 0 51 if ((error = git_repository_config__weakptr(&cfg, repo)) < 0)
2405 50 1 if (data->index != git_iterator_index(target)) {
2406 22 28 if (data->opts.checkout_strategy & GIT_CHECKOUT_FORCE) {
2408 0 22 if ((error = git_index_read(data->index, false)) < 0)
2416 0 28 if (git_index_has_conflicts(data->index)) {
2423 0 28 if ((error = git_index_read_safely(data->index)) < 0)
2434 23 30 if ((data->opts.checkout_strategy & GIT_CHECKOUT_FORCE) != 0)
2441 2 51 if (!data->index->on_disk &&
2 0 if (!data->index->on_disk &&
2449 53 0 if (!data->opts.dir_mode)
2452 53 0 if (!data->opts.file_open_flags)
2457 0 53 if ((error = git_repository__configmap_lookup(
2461 0 53 if ((error = git_repository__configmap_lookup(
2465 53 0 if (!data->opts.baseline && !data->opts.baseline_index) {
51 2 if (!data->opts.baseline && !data->opts.baseline_index) {
2472 49 2 if (data->index->on_disk)
2475 0 51 if (error == GIT_EUNBORNBRANCH) {
2480 0 51 if (error < 0)
2484 53 0 if ((data->opts.checkout_strategy &
2489 53 0 if ((error = git_repository_config__weakptr(&cfg, repo)) < 0 ||
11 42 if ((error = git_repository_config__weakptr(&cfg, repo)) < 0 ||
2490 11 0 (error = git_config_get_entry(&conflict_style, cfg, "merge.conflictstyle")) < 0 ||
2493 0 11 else if (error)
2495 11 0 else if (strcmp(conflict_style->value, "merge") == 0)
2497 0 0 else if (strcmp(conflict_style->value, "diff3") == 0)
2499 0 0 else if (strcmp(conflict_style->value, "zdiff3") == 0)
2511 53 0 if ((error = git_pool_init(&data->pool, 1)) < 0 ||
53 0 if ((error = git_pool_init(&data->pool, 1)) < 0 ||
2512 53 0 (error = git_vector_init(&data->removes, 0, git__strcmp_cb)) < 0 ||
2513 53 0 (error = git_vector_init(&data->remove_conflicts, 0, NULL)) < 0 ||
2514 53 0 (error = git_vector_init(&data->update_conflicts, 0, NULL)) < 0 ||
2515 53 0 (error = git_str_puts(&data->target_path, data->opts.target_directory)) < 0 ||
2516 53 0 (error = git_fs_path_to_dir(&data->target_path)) < 0 ||
2525 0 53 if (error < 0)
2538 159 0 if (checkout_opts &&
0 159 if (checkout_opts &&
2561 0 53 if (error < 0)
2574 0 53 if (data.opts.checkout_strategy & GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH)
2576 2 51 if (data.opts.paths.count > 0)
2581 0 53 workdir_opts.flags = git_iterator_ignore_case(target) ?
2589 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 ||
2595 0 53 baseline_opts.flags = git_iterator_ignore_case(target) ?
2602 2 51 if (data.opts.baseline_index) {
2603 0 2 if ((error = git_iterator_for_index(
2608 0 51 if ((error = git_iterator_for_tree(
2614 0 53 GIT_ASSERT(git_iterator_ignore_case(workdir) == git_iterator_ignore_case(baseline));
2619 0 53 if ((error = git_diff__from_iterators(
2627 0 53 if ((error = checkout_get_actions(&actions, &counts, &data, workdir)) != 0)
2630 0 53 if (data.strategy & GIT_CHECKOUT_DRY_RUN)
2644 13 40 if (counts[CHECKOUT_ACTION__REMOVE] > 0 &&
0 13 if (counts[CHECKOUT_ACTION__REMOVE] > 0 &&
2648 0 53 if (counts[CHECKOUT_ACTION__REMOVE_CONFLICT] > 0 &&
0 0 if (counts[CHECKOUT_ACTION__REMOVE_CONFLICT] > 0 &&
2652 29 24 if (counts[CHECKOUT_ACTION__UPDATE_BLOB] > 0 &&
0 29 if (counts[CHECKOUT_ACTION__UPDATE_BLOB] > 0 &&
2656 0 53 if (counts[CHECKOUT_ACTION__UPDATE_SUBMODULE] > 0 &&
0 0 if (counts[CHECKOUT_ACTION__UPDATE_SUBMODULE] > 0 &&
2660 3 50 if (counts[CHECKOUT_ACTION__UPDATE_CONFLICT] > 0 &&
0 3 if (counts[CHECKOUT_ACTION__UPDATE_CONFLICT] > 0 &&
2664 52 1 if (data.index != git_iterator_index(target) &&
0 52 if (data.index != git_iterator_index(target) &&
2668 0 53 GIT_ASSERT(data.completed_steps == data.total_steps);
2670 0 53 if (data.opts.perfdata_cb)
2674 53 0 if (!error && data.index != NULL &&
53 0 if (!error && data.index != NULL &&
37 16 if (!error && data.index != NULL &&
2697 0 17 if (!index && !repo) {
0 0 if (!index && !repo) {
2703 17 0 if (index && repo &&
2704 0 1 git_index_owner(index) &&
2709 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)) {
2714 0 17 if (!repo)
2717 0 17 if (!index && (error = git_repository_index__weakptr(&index, repo)) < 0)
0 0 if (!index && (error = git_repository_index__weakptr(&index, repo)) < 0)
2723 17 0 if (!(error = git_iterator_for_index(&index_i, repo, index, &iter_opts)))
2726 16 1 if (owned)
2746 18 18 if (!treeish && !repo) {
0 18 if (!treeish && !repo) {
2751 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) {
2757 0 36 if (!repo)
2760 18 18 if (treeish) {
2761 0 18 if (git_object_peel((git_object **)&tree, treeish, GIT_OBJECT_TREE) < 0) {
2768 0 18 if ((error = checkout_lookup_head_tree(&tree, repo)) < 0) {
2769 0 0 if (error != GIT_EUNBORNBRANCH)
2777 0 36 if ((error = git_repository_index(&index, repo)) < 0)
2782 36 0 if (!(error = git_iterator_for_tree(&tree_i, tree, &iter_opts)))
2796 0 2 GIT_ASSERT_ARG(repo);
2803 0 0 GIT_INIT_STRUCTURE_FROM_TEMPLATE(