Branch Coverage

deps/libgit2/src/checkout.c
Criterion Covered Total %
branch 404 1084 37.2


line true false branch
102 2 188 if (!data->opts.notify_cb ||
0 2 if (!data->opts.notify_cb ||
106 2 0 if (wditem) {
120 1 1 if (delta) {
164 0 198 if (!respect_filemode) {
165 0 0 if (a == S_IFLNK)
167 0 0 if (b == S_IFLNK)
187 0 107 if (wditem->mode == GIT_FILEMODE_COMMIT) {
193 0 0 if (git_submodule_lookup(&sm, data->repo, wditem->path) < 0) {
198 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 ||
201 0 0 else if ((sm_oid = git_submodule_wd_id(sm)) == NULL)
220 100 3 git_index_time_eq(&wditem->mtime, &ie->mtime) &&
221 100 0 wditem->file_size == ie->file_size &&
232 0 7 if (baseitem->size && wditem->file_size != baseitem->size)
0 0 if (baseitem->size && wditem->file_size != baseitem->size)
236 0 7 if (S_ISDIR(wditem->mode))
239 0 7 if (is_filemode_changed(baseitem->mode, wditem->mode, data->respect_filemode))
242 0 7 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 &&
283 0 115 if ((*action & CHECKOUT_ACTION__CONFLICT) != 0)
301 0 1 if (error)
303 0 1 *action = CHECKOUT_ACTION_IF(RECREATE_MISSING, UPDATE_BLOB, NONE);
306 6 0 *action = CHECKOUT_ACTION_IF(SAFE, UPDATE_BLOB, NONE);
309 0 0 *action = CHECKOUT_ACTION_IF(RECREATE_MISSING, UPDATE_BLOB, CONFLICT);
312 0 0 if (delta->new_file.mode == GIT_FILEMODE_TREE)
313 0 0 *action = CHECKOUT_ACTION_IF(SAFE, UPDATE_BLOB, NONE);
330 38 13 if (path && git_buf_puts(&data->target_path, path) < 0)
0 38 if (path && git_buf_puts(&data->target_path, path) < 0)
343 53 7 if (wd->mode != GIT_FILEMODE_TREE)
346 0 7 if (checkout_target_fullpath(&full, data, wd->path) < 0)
349 7 0 return !full || !git_path_contains(full, DOT_GIT);
7 0 return !full || !git_path_contains(full, DOT_GIT);
355 0 12 GIT_ERROR_CHECK_ALLOC(copy);
371 2 60 if (!git_pathspec__match(
378 60 0 if (data->index != NULL) {
384 53 7 if (wd->mode != GIT_FILEMODE_TREE) {
385 4 49 if (!error) { /* found by git_index__find_pos call */
388 0 49 } else if (error != GIT_ENOTFOUND)
398 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)
403 4 56 if (notify != GIT_CHECKOUT_NOTIFY_NONE) {
405 0 4 if ((error = checkout_notify(data, notify, NULL, wd)) != 0)
408 4 0 if (remove && wd_item_is_removable(data, wd))
4 0 if (remove && wd_item_is_removable(data, wd))
411 4 0 if (!error)
425 8 48 if (error == GIT_ITEROVER)
427 0 48 else if (error < 0)
430 1 55 if (untracked_state == GIT_ITERATOR_STATUS_IGNORED) {
438 0 56 if ((error = checkout_notify(data, notify, NULL, &saved_wd)) != 0)
441 8 48 if (remove && removable)
8 0 if (remove && removable)
444 56 0 if (!error && over) /* restore ITEROVER if needed */
8 48 if (!error && over) /* restore ITEROVER if needed */
459 0 0 if (git_submodule_lookup(&sm, data->repo, path) < 0)
462 0 0 if (git_submodule_location(&sm_loc, sm) < 0 ||
0 0 if (git_submodule_location(&sm_loc, sm) < 0 ||
475 0 0 if (checkout_target_fullpath(&fullpath, data, path) < 0)
492 14 73 if (checkout_is_workdir_modified(data, &delta->old_file, &delta->new_file, wd)) {
493 0 14 GIT_ERROR_CHECK_ERROR(
499 0 1 if (git_iterator_current_is_ignored(workdir))
500 0 0 *action = CHECKOUT_ACTION_IF(DONT_OVERWRITE_IGNORED, CONFLICT, UPDATE_BLOB);
502 1 0 *action = CHECKOUT_ACTION_IF(FORCE, UPDATE_BLOB, CONFLICT);
505 0 8 if (checkout_is_workdir_modified(data, &delta->old_file, &delta->new_file, wd))
506 0 0 *action = CHECKOUT_ACTION_IF(FORCE, REMOVE, CONFLICT);
513 0 0 *action = CHECKOUT_ACTION_IF(FORCE, UPDATE_BLOB, CONFLICT);
515 12 0 *action = CHECKOUT_ACTION_IF(SAFE, UPDATE_BLOB, NONE);
518 0 0 if (delta->old_file.mode == GIT_FILEMODE_TREE) {
519 0 0 if (wd->mode == GIT_FILEMODE_TREE)
523 0 0 *action = CHECKOUT_ACTION_IF(SAFE, UPDATE_BLOB, NONE);
524 0 0 else if (wd->mode == GIT_FILEMODE_COMMIT) {
528 0 0 if (submodule_is_config_only(data, wd->path))
529 0 0 *action = CHECKOUT_ACTION_IF(SAFE, UPDATE_BLOB, NONE);
531 0 0 *action = CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, CONFLICT);
533 0 0 *action = CHECKOUT_ACTION_IF(FORCE, REMOVE, CONFLICT);
535 0 0 else if (checkout_is_workdir_modified(data, &delta->old_file, &delta->new_file, wd))
536 0 0 *action = CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, CONFLICT);
538 0 0 *action = CHECKOUT_ACTION_IF(SAFE, REMOVE_AND_UPDATE, NONE);
541 0 0 if (delta->new_file.mode == GIT_FILEMODE_TREE)
562 0 0 GIT_ERROR_CHECK_ERROR(
564 0 0 *action = CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, NONE);
568 0 0 *action = CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, CONFLICT);
571 0 0 *action = CHECKOUT_ACTION_IF(FORCE, REMOVE, CONFLICT);
575 0 0 *action = CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, CONFLICT);
595 0 0 GIT_ERROR_CHECK_ERROR(
597 0 0 GIT_ERROR_CHECK_ERROR(
599 0 0 *action = CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, NONE);
603 0 0 if (delta->old_file.mode == GIT_FILEMODE_COMMIT)
605 0 0 else if (delta->new_file.mode != GIT_FILEMODE_TREE)
607 0 0 CHECKOUT_ACTION_IF(DONT_OVERWRITE_IGNORED, CONFLICT, REMOVE_AND_UPDATE) :
0 0 CHECKOUT_ACTION_IF(DONT_OVERWRITE_IGNORED, CONFLICT, REMOVE_AND_UPDATE) :
608 0 0 CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, CONFLICT);
611 0 0 if (delta->old_file.mode != GIT_FILEMODE_TREE)
612 0 0 GIT_ERROR_CHECK_ERROR(
616 0 0 if (delta->old_file.mode == GIT_FILEMODE_TREE) {
623 0 0 *action = CHECKOUT_ACTION_IF(SAFE, UPDATE_BLOB, NONE);
625 0 0 else if (delta->new_file.mode != GIT_FILEMODE_TREE)
627 0 0 *action = CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, CONFLICT);
644 0 0 if (error == 0 && *action != CHECKOUT_ACTION__NONE)
0 0 if (error == 0 && *action != CHECKOUT_ACTION__NONE)
668 6 205 if (!wd)
681 96 109 if (cmp < 0) {
684 45 51 if (cmp == 0) {
685 44 1 if (wd->mode == GIT_FILEMODE_TREE) {
688 0 44 if (error < 0 && error != GIT_ITEROVER)
0 0 if (error < 0 && error != GIT_ITEROVER)
694 0 1 if (delta->old_file.path[strlen(wd->path)] == '/') {
704 0 52 if (error && error != GIT_ITEROVER)
0 0 if (error && error != GIT_ITEROVER)
709 108 1 if (cmp == 0) {
718 0 1 if (cmp == 0) { /* case 5 */
719 0 0 if (wd->path[strlen(delta->old_file.path)] != '/')
722 0 0 if (delta->status == GIT_DELTA_TYPECHANGE) {
723 0 0 if (delta->old_file.mode == GIT_FILEMODE_TREE) {
729 0 0 if (delta->new_file.mode == GIT_FILEMODE_TREE ||
0 0 if (delta->new_file.mode == GIT_FILEMODE_TREE ||
730 0 0 delta->new_file.mode == GIT_FILEMODE_COMMIT ||
740 0 0 checkout_action_with_wd_dir_empty(action, data, delta) :
749 108 0 if (!error && advance != NULL &&
108 0 if (!error && advance != NULL &&
41 67 if (!error && advance != NULL &&
752 41 0 if (error == GIT_ITEROVER)
767 10 53 while (wd && !error)
10 0 while (wd && !error)
770 10 43 if (error == GIT_ITEROVER)
780 0 0 if (!a && !b)
0 0 if (!a && !b)
782 0 0 else if (!a && b)
0 0 else if (!a && b)
784 0 0 else if(a && !b)
0 0 else if(a && !b)
796 0 0 if ((diff = checkout_idxentry_cmp(ca->ancestor, cb->ancestor)) == 0 &&
0 0 if ((diff = checkout_idxentry_cmp(ca->ancestor, cb->ancestor)) == 0 &&
810 0 3 if ((conflict = git_vector_get(conflicts, idx)) == NULL)
813 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)
829 3 0 if (ours && git_pathspec__match(pathspec, ours->path,
3 0 if (ours && git_pathspec__match(pathspec, ours->path,
834 0 0 if (theirs && git_pathspec__match(pathspec, theirs->path,
0 0 if (theirs && git_pathspec__match(pathspec, theirs->path,
839 0 0 if (ancestor && git_pathspec__match(pathspec, ancestor->path,
0 0 if (ancestor && git_pathspec__match(pathspec, ancestor->path,
849 3 0 conflict->submodule = ((conflict->ancestor && S_ISGITLINK(conflict->ancestor->mode)) ||
3 0 conflict->submodule = ((conflict->ancestor && S_ISGITLINK(conflict->ancestor->mode)) ||
850 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)) ||
851 0 3 (conflict->theirs && S_ISGITLINK(conflict->theirs->mode)));
860 0 3 if (conflict->submodule)
863 3 0 if (conflict->ancestor) {
864 0 3 if ((error = git_blob_lookup(&ancestor_blob, repo, &conflict->ancestor->id)) < 0)
870 3 0 if (!conflict->binary && conflict->ours) {
3 0 if (!conflict->binary && conflict->ours) {
871 0 3 if ((error = git_blob_lookup(&our_blob, repo, &conflict->ours->id)) < 0)
877 3 0 if (!conflict->binary && conflict->theirs) {
3 0 if (!conflict->binary && conflict->theirs) {
878 0 3 if ((error = git_blob_lookup(&their_blob, repo, &conflict->theirs->id)) < 0)
903 0 3 GIT_ERROR_CHECK_ALLOC(conflict);
909 3 0 if ((error = checkout_conflict_detect_submodule(conflict)) < 0 ||
0 3 if ((error = checkout_conflict_detect_submodule(conflict)) < 0 ||
916 0 3 if (git_vector_insert(&data->update_conflicts, conflict))
934 0 68 if ((error = git_index_conflict_iterator_new(&iterator, index)) < 0)
938 3 68 while ((error = git_index_conflict_next(&ancestor, &ours, &theirs, iterator)) == 0) {
939 0 3 if (!conflict_pathspec_match(data, workdir, pathspec, ancestor, ours, theirs))
942 0 3 if ((error = cb(ancestor, ours, theirs, payload)) < 0)
946 68 0 if (error == GIT_ITEROVER)
960 36 17 if ((index = git_iterator_index(data->target)) == NULL)
965 0 17 if (checkout_conflicts_foreach(data, index, workdir, pathspec, checkout_conflict_append_update, data) < 0)
987 0 0 if (!conflict->ancestor)
999 0 0 if (git_vector_bsearch2(&pos, &data->update_conflicts, checkout_conflicts_cmp_ancestor, path) < 0)
1012 0 0 git_vector_foreach(&data->update_conflicts, i, conflict) {
1015 0 0 if (conflict->ancestor)
1018 0 0 if (conflict->ours)
1020 0 0 else if (conflict->theirs)
1023 0 0 if (cmp == 0)
1044 0 0 if (!name_entry->ancestor) {
1050 0 0 if (!name_entry->ours && !name_entry->theirs) {
0 0 if (!name_entry->ours && !name_entry->theirs) {
1056 0 0 if ((ancestor = checkout_conflicts_search_ancestor(data,
1065 0 0 if (name_entry->ours) {
1066 0 0 if (strcmp(name_entry->ancestor, name_entry->ours) == 0)
1068 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 ||
1078 0 0 if (name_entry->theirs) {
1079 0 0 if (strcmp(name_entry->ancestor, name_entry->theirs) == 0)
1081 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)
1083 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 ||
1110 36 17 if ((index = git_iterator_index(data->target)) == NULL)
1116 0 17 for (i = 0; i < names; i++) {
1119 0 0 if ((error = checkout_conflicts_load_byname_entry(
1124 0 0 if (our_conflict && our_conflict != ancestor_conflict) {
0 0 if (our_conflict && our_conflict != ancestor_conflict) {
1128 0 0 if (our_conflict->theirs)
1131 0 0 if (our_conflict->name_collision)
1135 0 0 if (their_conflict && their_conflict != ancestor_conflict) {
0 0 if (their_conflict && their_conflict != ancestor_conflict) {
1139 0 0 if (their_conflict->ours)
1142 0 0 if (their_conflict->name_collision)
1146 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 &&
1147 0 0 their_conflict && their_conflict != ancestor_conflict)
1168 36 17 if ((index = git_iterator_index(data->target)) == NULL)
1174 3 17 git_vector_foreach(&data->update_conflicts, i, conflict) {
1175 3 0 if ((conflict->ours && conflict->theirs) ||
0 3 if ((conflict->ours && conflict->theirs) ||
0 0 if ((conflict->ours && conflict->theirs) ||
1176 0 0 (!conflict->ours && !conflict->theirs))
1180 0 0 conflict->ours->path : conflict->theirs->path;
1182 0 0 if ((error = git_index_find(&j, index, path)) < 0) {
1183 0 0 if (error == GIT_ENOTFOUND)
1190 0 0 for (; j < len; j++) {
1191 0 0 if ((entry = git_index_get_byindex(index, j)) == NULL) {
1200 0 0 if (prefixed == GIT_PATH_EQUAL)
1203 0 0 if (prefixed == GIT_PATH_PREFIX)
1221 0 53 if (data->strategy & GIT_CHECKOUT_SKIP_UNMERGED)
1224 53 0 if ((error = checkout_conflicts_load(data, workdir, pathspec)) < 0 ||
53 0 if ((error = checkout_conflicts_load(data, workdir, pathspec)) < 0 ||
1242 0 0 assert(ancestor || ours || theirs);
0 0 assert(ancestor || ours || theirs);
0 0 assert(ancestor || ours || theirs);
1244 0 0 if (ancestor)
1246 0 0 else if (ours)
1248 0 0 else if (theirs)
1253 0 0 GIT_ERROR_CHECK_ALLOC(name);
1263 2 51 if ((data->strategy & GIT_CHECKOUT_DONT_UPDATE_INDEX) != 0)
1276 7 108 if (action & CHECKOUT_ACTION__REMOVE) {
1277 0 7 if (!git_path_isvalid(repo, delta->old_file.path, delta->old_file.mode, flags)) {
1283 31 84 if (action & ~CHECKOUT_ACTION__REMOVE) {
1284 0 31 if (!git_path_isvalid(repo, delta->new_file.path, delta->new_file.mode, flags)) {
1313 2 51 if ((error = git_iterator_current(&wditem, workdir)) < 0 &&
0 2 if ((error = git_iterator_current(&wditem, workdir)) < 0 &&
1320 53 0 *actions_ptr = actions = git__calloc(
1322 53 0 if (!counts || !actions) {
0 53 if (!counts || !actions) {
1327 115 53 git_vector_foreach(deltas, i, delta) {
1328 115 0 if ((error = checkout_action(&act, data, delta, workdir, &wditem, &pathspec)) == 0)
1331 0 115 if (error != 0)
1336 7 108 if (act & CHECKOUT_ACTION__REMOVE)
1338 31 84 if (act & CHECKOUT_ACTION__UPDATE_BLOB)
1340 0 115 if (act & CHECKOUT_ACTION__UPDATE_SUBMODULE)
1342 0 115 if (act & CHECKOUT_ACTION__CONFLICT)
1347 0 53 if (error)
1352 0 53 if (counts[CHECKOUT_ACTION__CONFLICT] > 0 &&
0 0 if (counts[CHECKOUT_ACTION__CONFLICT] > 0 &&
1355 0 0 git_error_set(GIT_ERROR_CHECKOUT, "%"PRIuZ" %s checkout",
1364 53 0 if ((error = checkout_get_remove_conflicts(data, workdir, &pathspec)) < 0 ||
53 0 if ((error = checkout_get_remove_conflicts(data, workdir, &pathspec)) < 0 ||
1392 0 34 if (git_repository__configmap_lookup(&ignorecase, data->repo, GIT_CONFIGMAP_IGNORECASE) < 0) {
1396 0 34 return (ignorecase &&
0 0 return (ignorecase &&
1433 0 34 unsigned int flags =
1438 0 34 if ((error = checkout_mkdir(
1442 0 34 if (remove_existing) {
1445 0 0 if (p_lstat(path, &st) == 0) {
1453 0 0 } else if (errno != ENOENT) {
1477 0 31 if ((ret = p_write(stream->fd, buffer, len)) < 0)
1486 31 0 assert(stream && stream->open);
0 31 assert(stream && stream->open);
1507 0 31 data->opts.file_mode : entry_filemode;
1515 31 0 if (hint_path == NULL)
1518 0 31 if ((error = mkpath2file(data, path, data->opts.dir_mode)) < 0)
1521 0 31 if (flags <= 0)
1523 0 31 if (!(mode = file_mode))
1526 0 31 if ((fd = p_open(path, flags, mode)) < 0) {
1534 31 0 if (!data->opts.disable_filters &&
0 31 if (!data->opts.disable_filters &&
1553 0 31 assert(writer.open == 0);
1557 0 31 if (error < 0)
1560 31 0 if (st) {
1563 0 31 if ((error = p_stat(path, st)) < 0) {
1583 0 0 if ((error = mkpath2file(data, path, data->opts.dir_mode)) < 0)
1586 0 0 if ((error = git_blob__getbuf(&linktarget, blob)) < 0)
1589 0 0 if (data->can_symlink) {
1590 0 0 if ((error = p_symlink(git_buf_cstr(&linktarget), path)) < 0)
1596 0 0 if (!error) {
1599 0 0 if ((error = p_lstat(path, st)) < 0)
1617 0 29 if (!data->index)
1636 0 0 if ((data->strategy & GIT_CHECKOUT_DONT_UPDATE_INDEX) != 0)
1639 0 0 if (checkout_target_fullpath(&fullpath, data, file->path) < 0)
1643 0 0 if (p_stat(fullpath->ptr, &st) < 0) {
1662 0 0 if ((data->strategy & GIT_CHECKOUT_UPDATE_ONLY) != 0)
1665 0 0 if ((error = checkout_mkdir(
0 0 if ((error = checkout_mkdir(
1671 0 0 if ((error = git_submodule_lookup(NULL, data->repo, file->path)) < 0) {
1675 0 0 if (error == GIT_ENOTFOUND) {
1699 3 103 if (data->opts.progress_cb)
1712 0 0 if (p_lstat(path, &st) < 0) {
1714 0 0 if (errno == ENOENT || errno == ENOTDIR)
0 0 if (errno == ENOENT || errno == ENOTDIR)
1723 0 0 if ((st.st_mode & ~0777) == (expected_mode & ~0777))
1740 0 31 if ((error = git_blob_lookup(&blob, data->repo, oid)) < 0)
1743 0 31 if (S_ISLNK(mode))
1754 0 31 if ((data->strategy & GIT_CHECKOUT_ALLOW_CONFLICTS) != 0 &&
0 0 if ((data->strategy & GIT_CHECKOUT_ALLOW_CONFLICTS) != 0 &&
1755 0 0 (error == GIT_ENOTFOUND || error == GIT_EEXISTS))
1772 0 31 if (checkout_target_fullpath(&fullpath, data, file->path) < 0)
1775 0 31 if ((data->strategy & GIT_CHECKOUT_UPDATE_ONLY) != 0) {
1779 0 0 if (rval <= 0)
1787 31 0 if (!error && (data->strategy & GIT_CHECKOUT_DONT_UPDATE_INDEX) == 0)
29 2 if (!error && (data->strategy & GIT_CHECKOUT_DONT_UPDATE_INDEX) == 0)
1791 31 0 if (!error && strcmp(file->path, ".gitmodules") == 0)
0 31 if (!error && strcmp(file->path, ".gitmodules") == 0)
1809 0 13 if (data->opts.checkout_strategy & GIT_CHECKOUT_SKIP_LOCKED_DIRECTORIES)
1812 0 13 if (checkout_target_fullpath(&fullpath, data, NULL) < 0)
1815 29 13 git_vector_foreach(&data->diff->deltas, i, delta) {
1816 7 22 if (actions[i] & CHECKOUT_ACTION__REMOVE) {
1820 0 7 if (error < 0)
1826 7 0 if ((actions[i] & CHECKOUT_ACTION__UPDATE_BLOB) == 0 &&
7 0 if ((actions[i] & CHECKOUT_ACTION__UPDATE_BLOB) == 0 &&
1827 7 0 (data->strategy & GIT_CHECKOUT_DONT_UPDATE_INDEX) == 0 &&
1835 12 13 git_vector_foreach(&data->removes, i, str) {
1837 0 12 if (error < 0)
1843 12 0 if ((data->strategy & GIT_CHECKOUT_DONT_UPDATE_INDEX) == 0 &&
12 0 if ((data->strategy & GIT_CHECKOUT_DONT_UPDATE_INDEX) == 0 &&
1846 1 11 if (str[strlen(str) - 1] == '/')
1884 62 29 git_vector_foreach(&data->diff->deltas, i, delta) {
1885 0 62 if (actions[i] & CHECKOUT_ACTION__DEFER_REMOVE) {
1889 0 0 if ((error = checkout_deferred_remove(
1894 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)) {
1895 0 31 if ((error = checkout_blob(data, &delta->new_file)) < 0)
1902 62 29 git_vector_foreach(&data->diff->deltas, i, delta) {
1903 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)) {
1904 0 0 if ((error = checkout_blob(data, &delta->new_file)) < 0)
1922 0 0 git_vector_foreach(&data->diff->deltas, i, delta) {
1923 0 0 if (actions[i] & CHECKOUT_ACTION__DEFER_REMOVE) {
1927 0 0 if ((error = checkout_deferred_remove(
1932 0 0 if (actions[i] & CHECKOUT_ACTION__UPDATE_SUBMODULE) {
1934 0 0 if (error < 0)
1951 67 0 if (!(error = git_repository_head(&ref, repo)) &&
67 0 if (!(error = git_repository_head(&ref, repo)) &&
1967 0 0 git_buf_putc(out, ':') < 0 ||
1979 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)
1984 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) {
1987 0 0 if ((error = git_buf_putc(path, '_')) < 0 ||
0 0 if ((error = git_buf_putc(path, '_')) < 0 ||
1994 0 0 if (i == INT_MAX) {
2014 0 0 assert (side == conflict->ours || side == conflict->theirs);
0 0 assert (side == conflict->ours || side == conflict->theirs);
2016 0 0 if (checkout_target_fullpath(&fullpath, data, side->path) < 0)
2019 0 0 if ((conflict->name_collision || conflict->directoryfile) &&
0 0 if ((conflict->name_collision || conflict->directoryfile) &&
0 0 if ((conflict->name_collision || conflict->directoryfile) &&
2020 0 0 (data->strategy & GIT_CHECKOUT_USE_OURS) == 0 &&
2023 0 0 if (side == conflict->ours)
2024 0 0 suffix = data->opts.our_label ? data->opts.our_label :
2027 0 0 suffix = data->opts.their_label ? data->opts.their_label :
2030 0 0 if (checkout_path_suffixed(fullpath, suffix) < 0)
2036 0 0 if ((data->strategy & GIT_CHECKOUT_UPDATE_ONLY) != 0 &&
0 0 if ((data->strategy & GIT_CHECKOUT_UPDATE_ONLY) != 0 &&
2040 0 0 if (!S_ISGITLINK(side->mode))
2053 0 0 if ((error = checkout_write_entry(data, conflict, conflict->ours)) >= 0)
2068 0 3 if ((error = git_buf_joinpath(out, git_repository_workdir(data->repo), result->path)) < 0)
2072 3 0 if (!conflict->name_collision)
2076 0 0 our_label_raw = data->opts.our_label ? data->opts.our_label : "ours";
2077 0 0 their_label_raw = data->opts.their_label ? data->opts.their_label : "theirs";
2078 0 0 suffix = strcmp(result->path, conflict->ours->path) == 0 ? our_label_raw : their_label_raw;
2080 0 0 if ((error = checkout_path_suffixed(out, suffix)) < 0)
2100 0 3 if (data->opts.checkout_strategy & GIT_CHECKOUT_CONFLICT_STYLE_DIFF3)
2104 2 1 data->opts.ancestor_label : "ancestor";
2106 3 0 data->opts.our_label : "ours";
2108 3 0 data->opts.their_label : "theirs";
2113 3 0 if (conflict->ours && conflict->theirs &&
3 0 if (conflict->ours && conflict->theirs &&
0 3 if (conflict->ours && conflict->theirs &&
2116 0 0 if ((error = conflict_entry_name(
2117 0 0 &our_label, opts.our_label, conflict->ours->path)) < 0 ||
2126 0 3 if ((error = git_merge_file_from_index(&result, data->repo,
2130 3 0 if (result.path == NULL || result.mode == 0) {
0 3 if (result.path == NULL || result.mode == 0) {
2136 0 3 if ((error = checkout_merge_path(&path_workdir, data, conflict, &result)) < 0)
2139 0 3 if ((data->strategy & GIT_CHECKOUT_UPDATE_ONLY) != 0 &&
0 0 if ((data->strategy & GIT_CHECKOUT_UPDATE_ONLY) != 0 &&
2143 3 0 if (!data->opts.disable_filters) {
2150 3 0 if ((error = git_filter_list__load_ext(
2152 3 0 GIT_FILTER_TO_WORKTREE, &filter_opts)) < 0 ||
2160 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 ||
2161 3 0 (error = git_filebuf_open(&output, git_buf_cstr(&path_workdir), GIT_FILEBUF_DO_NOT_BUFFER, result.mode)) < 0 ||
2186 9 0 if (error == GIT_ENOTFOUND)
2188 0 0 else if (error < 0)
2200 3 0 if (conflict->ancestor)
2203 3 0 if (!error && conflict->ours)
3 0 if (!error && conflict->ours)
2206 3 0 if (!error && conflict->theirs)
3 0 if (!error && conflict->theirs)
2218 3 3 git_vector_foreach(&data->update_conflicts, i, conflict) {
2221 0 3 if (conflict->ours == NULL && conflict->theirs == NULL)
0 0 if (conflict->ours == NULL && conflict->theirs == NULL)
2224 0 3 else if ((data->strategy & GIT_CHECKOUT_USE_OURS) &&
0 0 else if ((data->strategy & GIT_CHECKOUT_USE_OURS) &&
2227 0 3 else if ((data->strategy & GIT_CHECKOUT_USE_THEIRS) &&
0 0 else if ((data->strategy & GIT_CHECKOUT_USE_THEIRS) &&
2232 0 3 else if ((data->strategy & GIT_CHECKOUT_USE_OURS) &&
0 0 else if ((data->strategy & GIT_CHECKOUT_USE_OURS) &&
2233 0 0 !conflict->ours && conflict->name_collision)
2235 0 3 else if ((data->strategy & GIT_CHECKOUT_USE_THEIRS) &&
0 0 else if ((data->strategy & GIT_CHECKOUT_USE_THEIRS) &&
2236 0 0 !conflict->theirs && conflict->name_collision)
2242 3 0 else if (conflict->ours != NULL && conflict->theirs == NULL)
0 3 else if (conflict->ours != NULL && conflict->theirs == NULL)
2244 0 3 else if (conflict->ours == NULL && conflict->theirs != NULL)
0 0 else if (conflict->ours == NULL && conflict->theirs != NULL)
2250 0 3 else if (conflict->one_to_two)
2254 0 3 else if (S_ISLNK(conflict->ours->mode) &&
0 0 else if (S_ISLNK(conflict->ours->mode) &&
2258 0 3 else if (S_ISLNK(conflict->ours->mode))
2260 0 3 else if (S_ISLNK(conflict->theirs->mode))
2264 0 3 else if (conflict->submodule)
2268 0 3 else if (conflict->binary)
2271 3 0 else if (!error)
2277 3 0 if (!error && (data->strategy & GIT_CHECKOUT_DONT_UPDATE_INDEX) == 0)
3 0 if (!error && (data->strategy & GIT_CHECKOUT_DONT_UPDATE_INDEX) == 0)
2280 0 3 if (error)
2284 3 0 report_progress(data,
2286 0 0 (conflict->theirs ? conflict->theirs->path : conflict->ancestor->path));
2297 0 0 git_vector_foreach(&data->remove_conflicts, i, conflict) {
2298 0 0 if (git_index_conflict_remove(data->index, conflict) < 0)
2314 0 52 if ((data->strategy & GIT_CHECKOUT_UPDATE_ONLY) != 0)
2317 16 36 if (data->update_reuc) {
2318 2 16 git_vector_foreach(data->update_reuc, i, reuc_entry) {
2319 0 2 if ((error = git_index_reuc_add(data->index, reuc_entry->path,
2327 16 36 if (data->update_names) {
2328 0 16 git_vector_foreach(data->update_names, i, name_entry) {
2329 0 0 if ((error = git_index_name_add(data->index, name_entry->ancestor,
2341 51 2 if (data->opts_free_baseline) {
2377 0 53 if (!repo) {
2382 53 0 if ((!proposed || !proposed->target_directory) &&
53 0 if ((!proposed || !proposed->target_directory) &&
0 53 if ((!proposed || !proposed->target_directory) &&
2389 0 53 GIT_ERROR_CHECK_VERSION(
2392 0 53 if (!proposed)
2397 53 0 if (!data->opts.target_directory)
2399 0 0 else if (!git_path_isdir(data->opts.target_directory) &&
0 0 else if (!git_path_isdir(data->opts.target_directory) &&
2405 0 53 if ((error = git_repository_index(&data->index, data->repo)) < 0)
2409 51 2 if ((data->opts.checkout_strategy & GIT_CHECKOUT_NO_REFRESH) == 0) {
2412 0 51 if ((error = git_repository_config__weakptr(&cfg, repo)) < 0)
2419 50 1 if (data->index != git_iterator_index(target)) {
2420 24 26 if (data->opts.checkout_strategy & GIT_CHECKOUT_FORCE) {
2422 0 24 if ((error = git_index_read(data->index, false)) < 0)
2430 0 26 if (git_index_has_conflicts(data->index)) {
2437 0 26 if ((error = git_index_read_safely(data->index)) < 0)
2448 25 28 if ((data->opts.checkout_strategy & GIT_CHECKOUT_FORCE) != 0)
2455 2 51 if (!data->index->on_disk &&
2 0 if (!data->index->on_disk &&
2463 53 0 if (!data->opts.dir_mode)
2466 53 0 if (!data->opts.file_open_flags)
2471 0 53 if ((error = git_repository__configmap_lookup(
2475 0 53 if ((error = git_repository__configmap_lookup(
2479 53 0 if (!data->opts.baseline && !data->opts.baseline_index) {
51 2 if (!data->opts.baseline && !data->opts.baseline_index) {
2486 49 2 if (data->index->on_disk)
2489 0 51 if (error == GIT_EUNBORNBRANCH) {
2494 0 51 if (error < 0)
2498 53 0 if ((data->opts.checkout_strategy &
2503 53 0 if ((error = git_repository_config__weakptr(&cfg, repo)) < 0 ||
11 42 if ((error = git_repository_config__weakptr(&cfg, repo)) < 0 ||
2504 11 0 (error = git_config_get_entry(&conflict_style, cfg, "merge.conflictstyle")) < 0 ||
2507 0 11 else if (error)
2509 11 0 else if (strcmp(conflict_style->value, "merge") == 0)
2511 0 0 else if (strcmp(conflict_style->value, "diff3") == 0)
2525 53 0 if ((error = git_vector_init(&data->removes, 0, git__strcmp_cb)) < 0 ||
53 0 if ((error = git_vector_init(&data->removes, 0, git__strcmp_cb)) < 0 ||
2526 53 0 (error = git_vector_init(&data->remove_conflicts, 0, NULL)) < 0 ||
2527 53 0 (error = git_vector_init(&data->update_conflicts, 0, NULL)) < 0 ||
2528 53 0 (error = git_buf_puts(&data->target_path, data->opts.target_directory)) < 0 ||
2529 53 0 (error = git_path_to_dir(&data->target_path)) < 0 ||
2538 0 53 if (error < 0)
2563 0 53 if (error < 0)
2576 0 53 if (data.opts.checkout_strategy & GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH)
2578 2 51 if (data.opts.paths.count > 0)
2583 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) ?
2599 53 0 if (opts && (opts->checkout_strategy & GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH)) {
0 53 if (opts && (opts->checkout_strategy & GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH)) {
2604 2 51 if (data.opts.baseline_index) {
2605 0 2 if ((error = git_iterator_for_index(
2610 0 51 if ((error = git_iterator_for_tree(
2616 0 53 assert(git_iterator_ignore_case(workdir) == git_iterator_ignore_case(baseline));
2621 0 53 if ((error = git_diff__from_iterators(
2629 0 53 if ((error = checkout_get_actions(&actions, &counts, &data, workdir)) != 0)
2643 13 40 if (counts[CHECKOUT_ACTION__REMOVE] > 0 &&
0 13 if (counts[CHECKOUT_ACTION__REMOVE] > 0 &&
2647 0 53 if (counts[CHECKOUT_ACTION__REMOVE_CONFLICT] > 0 &&
0 0 if (counts[CHECKOUT_ACTION__REMOVE_CONFLICT] > 0 &&
2651 29 24 if (counts[CHECKOUT_ACTION__UPDATE_BLOB] > 0 &&
0 29 if (counts[CHECKOUT_ACTION__UPDATE_BLOB] > 0 &&
2655 0 53 if (counts[CHECKOUT_ACTION__UPDATE_SUBMODULE] > 0 &&
0 0 if (counts[CHECKOUT_ACTION__UPDATE_SUBMODULE] > 0 &&
2659 3 50 if (counts[CHECKOUT_ACTION__UPDATE_CONFLICT] > 0 &&
0 3 if (counts[CHECKOUT_ACTION__UPDATE_CONFLICT] > 0 &&
2663 52 1 if (data.index != git_iterator_index(target) &&
0 52 if (data.index != git_iterator_index(target) &&
2667 0 53 assert(data.completed_steps == data.total_steps);
2669 0 53 if (data.opts.perfdata_cb)
2673 53 0 if (!error && data.index != NULL &&
53 0 if (!error && data.index != NULL &&
37 16 if (!error && data.index != NULL &&
2695 0 17 if (!index && !repo) {
0 0 if (!index && !repo) {
2701 17 0 if (index && repo &&
2702 0 1 git_index_owner(index) &&
2707 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)) {
2712 0 17 if (!repo)
2715 0 17 if (!index && (error = git_repository_index__weakptr(&index, repo)) < 0)
0 0 if (!index && (error = git_repository_index__weakptr(&index, repo)) < 0)
2719 17 0 if (!(error = git_iterator_for_index(&index_i, repo, index, NULL)))
2722 16 1 if (owned)
2742 18 18 if (!treeish && !repo) {
0 18 if (!treeish && !repo) {
2747 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) {
2753 0 36 if (!repo)
2756 18 18 if (treeish) {
2757 0 18 if (git_object_peel((git_object **)&tree, treeish, GIT_OBJECT_TREE) < 0) {
2764 0 18 if ((error = checkout_lookup_head_tree(&tree, repo)) < 0) {
2765 0 0 if (error != GIT_EUNBORNBRANCH)
2773 0 36 if ((error = git_repository_index(&index, repo)) < 0)
2776 36 0 if (opts && (opts->checkout_strategy & GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH)) {
0 36 if (opts && (opts->checkout_strategy & GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH)) {
2781 36 0 if (!(error = git_iterator_for_tree(&tree_i, tree, &iter_opts)))
2795 0 2 assert(repo);
2801 0 0 GIT_INIT_STRUCTURE_FROM_TEMPLATE(