summaryrefslogtreecommitdiff
path: root/src/checkout.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2018-12-27 13:47:34 -0600
committerEdward Thomson <ethomson@edwardthomson.com>2019-01-22 22:30:35 +0000
commitf673e232afe22eb865cdc915e55a2df6493f0fbb (patch)
treee79e3e6fb1e1d78367679aea75e66c8141b4daa8 /src/checkout.c
parent647dfdb42d06514a85c1499f1be88a32b8a4c24b (diff)
downloadlibgit2-f673e232afe22eb865cdc915e55a2df6493f0fbb.tar.gz
git_error: use new names in internal APIs and usage
Move to the `git_error` name in the internal API for error-related functions.
Diffstat (limited to 'src/checkout.c')
-rw-r--r--src/checkout.c98
1 files changed, 49 insertions, 49 deletions
diff --git a/src/checkout.c b/src/checkout.c
index a57e91924..fe020894a 100644
--- a/src/checkout.c
+++ b/src/checkout.c
@@ -146,7 +146,7 @@ static int checkout_notify(
int error = data->opts.notify_cb(
why, path, baseline, target, workdir, data->opts.notify_payload);
- return giterr_set_after_callback_function(
+ return git_error_set_after_callback_function(
error, "git_checkout notification");
}
}
@@ -193,7 +193,7 @@ static bool checkout_is_workdir_modified(
bool rval = false;
if (git_submodule_lookup(&sm, data->repo, wditem->path) < 0) {
- giterr_clear();
+ git_error_clear();
return true;
}
@@ -354,7 +354,7 @@ static bool wd_item_is_removable(
static int checkout_queue_remove(checkout_data *data, const char *path)
{
char *copy = git_pool_strdup(&data->pool, path);
- GITERR_CHECK_ALLOC(copy);
+ GIT_ERROR_CHECK_ALLOC(copy);
return git_vector_insert(&data->removes, copy);
}
@@ -492,7 +492,7 @@ static int checkout_action_with_wd(
switch (delta->status) {
case GIT_DELTA_UNMODIFIED: /* case 14/15 or 33 */
if (checkout_is_workdir_modified(data, &delta->old_file, &delta->new_file, wd)) {
- GITERR_CHECK_ERROR(
+ GIT_ERROR_CHECK_ERROR(
checkout_notify(data, GIT_CHECKOUT_NOTIFY_DIRTY, delta, wd) );
*action = CHECKOUT_ACTION_IF(FORCE, UPDATE_BLOB, NONE);
}
@@ -561,7 +561,7 @@ static int checkout_action_with_wd_blocker(
switch (delta->status) {
case GIT_DELTA_UNMODIFIED:
/* should show delta as dirty / deleted */
- GITERR_CHECK_ERROR(
+ GIT_ERROR_CHECK_ERROR(
checkout_notify(data, GIT_CHECKOUT_NOTIFY_DIRTY, delta, wd) );
*action = CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, NONE);
break;
@@ -594,9 +594,9 @@ static int checkout_action_with_wd_dir(
switch (delta->status) {
case GIT_DELTA_UNMODIFIED: /* case 19 or 24 (or 34 but not really) */
- GITERR_CHECK_ERROR(
+ GIT_ERROR_CHECK_ERROR(
checkout_notify(data, GIT_CHECKOUT_NOTIFY_DIRTY, delta, NULL));
- GITERR_CHECK_ERROR(
+ GIT_ERROR_CHECK_ERROR(
checkout_notify(data, GIT_CHECKOUT_NOTIFY_UNTRACKED, NULL, wd));
*action = CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, NONE);
break;
@@ -611,7 +611,7 @@ static int checkout_action_with_wd_dir(
break;
case GIT_DELTA_DELETED: /* case 11 (and 27 for dir) */
if (delta->old_file.mode != GIT_FILEMODE_TREE)
- GITERR_CHECK_ERROR(
+ GIT_ERROR_CHECK_ERROR(
checkout_notify(data, GIT_CHECKOUT_NOTIFY_UNTRACKED, NULL, wd));
break;
case GIT_DELTA_TYPECHANGE: /* case 24 or 31 */
@@ -902,7 +902,7 @@ static int checkout_conflict_append_update(
int error;
conflict = git__calloc(1, sizeof(checkout_conflictdata));
- GITERR_CHECK_ALLOC(conflict);
+ GIT_ERROR_CHECK_ALLOC(conflict);
conflict->ancestor = ancestor;
conflict->ours = ours;
@@ -1044,20 +1044,20 @@ static int checkout_conflicts_load_byname_entry(
*theirs_out = NULL;
if (!name_entry->ancestor) {
- giterr_set(GITERR_INDEX, "a NAME entry exists without an ancestor");
+ git_error_set(GIT_ERROR_INDEX, "a NAME entry exists without an ancestor");
error = -1;
goto done;
}
if (!name_entry->ours && !name_entry->theirs) {
- giterr_set(GITERR_INDEX, "a NAME entry exists without an ours or theirs");
+ git_error_set(GIT_ERROR_INDEX, "a NAME entry exists without an ours or theirs");
error = -1;
goto done;
}
if ((ancestor = checkout_conflicts_search_ancestor(data,
name_entry->ancestor)) == NULL) {
- giterr_set(GITERR_INDEX,
+ git_error_set(GIT_ERROR_INDEX,
"a NAME entry referenced ancestor entry '%s' which does not exist in the main index",
name_entry->ancestor);
error = -1;
@@ -1069,7 +1069,7 @@ static int checkout_conflicts_load_byname_entry(
ours = ancestor;
else if ((ours = checkout_conflicts_search_branch(data, name_entry->ours)) == NULL ||
ours->ours == NULL) {
- giterr_set(GITERR_INDEX,
+ git_error_set(GIT_ERROR_INDEX,
"a NAME entry referenced our entry '%s' which does not exist in the main index",
name_entry->ours);
error = -1;
@@ -1084,7 +1084,7 @@ static int checkout_conflicts_load_byname_entry(
theirs = ours;
else if ((theirs = checkout_conflicts_search_branch(data, name_entry->theirs)) == NULL ||
theirs->theirs == NULL) {
- giterr_set(GITERR_INDEX,
+ git_error_set(GIT_ERROR_INDEX,
"a NAME entry referenced their entry '%s' which does not exist in the main index",
name_entry->theirs);
error = -1;
@@ -1183,7 +1183,7 @@ static int checkout_conflicts_mark_directoryfile(
if ((error = git_index_find(&j, index, path)) < 0) {
if (error == GIT_ENOTFOUND)
- giterr_set(GITERR_INDEX,
+ git_error_set(GIT_ERROR_INDEX,
"index inconsistency, could not find entry for expected conflict '%s'", path);
goto done;
@@ -1191,7 +1191,7 @@ static int checkout_conflicts_mark_directoryfile(
for (; j < len; j++) {
if ((entry = git_index_get_byindex(index, j)) == NULL) {
- giterr_set(GITERR_INDEX,
+ git_error_set(GIT_ERROR_INDEX,
"index inconsistency, truncated index while loading expected conflict '%s'", path);
error = -1;
goto done;
@@ -1252,7 +1252,7 @@ static int checkout_conflict_append_remove(
else
abort();
- GITERR_CHECK_ALLOC(name);
+ GIT_ERROR_CHECK_ALLOC(name);
return git_vector_insert(&data->remove_conflicts, (char *)name);
}
@@ -1277,14 +1277,14 @@ static int checkout_verify_paths(
if (action & CHECKOUT_ACTION__REMOVE) {
if (!git_path_isvalid(repo, delta->old_file.path, delta->old_file.mode, flags)) {
- giterr_set(GITERR_CHECKOUT, "cannot remove invalid path '%s'", delta->old_file.path);
+ git_error_set(GIT_ERROR_CHECKOUT, "cannot remove invalid path '%s'", delta->old_file.path);
return -1;
}
}
if (action & ~CHECKOUT_ACTION__REMOVE) {
if (!git_path_isvalid(repo, delta->new_file.path, delta->new_file.mode, flags)) {
- giterr_set(GITERR_CHECKOUT, "cannot checkout to invalid path '%s'", delta->new_file.path);
+ git_error_set(GIT_ERROR_CHECKOUT, "cannot checkout to invalid path '%s'", delta->new_file.path);
return -1;
}
}
@@ -1354,7 +1354,7 @@ static int checkout_get_actions(
if (counts[CHECKOUT_ACTION__CONFLICT] > 0 &&
(data->strategy & GIT_CHECKOUT_ALLOW_CONFLICTS) == 0)
{
- giterr_set(GITERR_CHECKOUT, "%"PRIuZ" %s checkout",
+ git_error_set(GIT_ERROR_CHECKOUT, "%"PRIuZ" %s checkout",
counts[CHECKOUT_ACTION__CONFLICT],
counts[CHECKOUT_ACTION__CONFLICT] == 1 ?
"conflict prevents" : "conflicts prevent");
@@ -1453,10 +1453,10 @@ static int mkpath2file(
*/
error = git_futils_rmdir_r(path, NULL, GIT_RMDIR_REMOVE_FILES);
} else if (errno != ENOENT) {
- giterr_set(GITERR_OS, "failed to stat '%s'", path);
+ git_error_set(GIT_ERROR_OS, "failed to stat '%s'", path);
return GIT_EEXISTS;
} else {
- giterr_clear();
+ git_error_clear();
}
}
@@ -1477,7 +1477,7 @@ static int checkout_stream_write(
int ret;
if ((ret = p_write(stream->fd, buffer, len)) < 0)
- giterr_set(GITERR_OS, "could not write to '%s'", stream->path);
+ git_error_set(GIT_ERROR_OS, "could not write to '%s'", stream->path);
return ret;
}
@@ -1526,7 +1526,7 @@ static int blob_content_to_file(
mode = GIT_FILEMODE_BLOB;
if ((fd = p_open(path, flags, mode)) < 0) {
- giterr_set(GITERR_OS, "could not open '%s' for writing", path);
+ git_error_set(GIT_ERROR_OS, "could not open '%s' for writing", path);
return fd;
}
@@ -1563,7 +1563,7 @@ static int blob_content_to_file(
data->perfdata.stat_calls++;
if ((error = p_stat(path, st)) < 0) {
- giterr_set(GITERR_OS, "failed to stat '%s'", path);
+ git_error_set(GIT_ERROR_OS, "failed to stat '%s'", path);
return error;
}
@@ -1590,7 +1590,7 @@ static int blob_content_to_link(
if (data->can_symlink) {
if ((error = p_symlink(git_buf_cstr(&linktarget), path)) < 0)
- giterr_set(GITERR_OS, "could not create symlink %s", path);
+ git_error_set(GIT_ERROR_OS, "could not create symlink %s", path);
} else {
error = git_futils_fake_symlink(git_buf_cstr(&linktarget), path);
}
@@ -1599,7 +1599,7 @@ static int blob_content_to_link(
data->perfdata.stat_calls++;
if ((error = p_lstat(path, st)) < 0)
- giterr_set(GITERR_CHECKOUT, "could not stat symlink %s", path);
+ git_error_set(GIT_ERROR_CHECKOUT, "could not stat symlink %s", path);
st->st_mode = GIT_FILEMODE_LINK;
}
@@ -1643,8 +1643,8 @@ static int checkout_submodule_update_index(
data->perfdata.stat_calls++;
if (p_stat(fullpath->ptr, &st) < 0) {
- giterr_set(
- GITERR_CHECKOUT, "could not stat submodule %s\n", file->path);
+ git_error_set(
+ GIT_ERROR_CHECKOUT, "could not stat submodule %s\n", file->path);
return GIT_ENOTFOUND;
}
@@ -1675,7 +1675,7 @@ static int checkout_submodule(
* have a .gitmodules - core Git just makes an empty directory
*/
if (error == GIT_ENOTFOUND) {
- giterr_clear();
+ git_error_clear();
return checkout_submodule_update_index(data, file);
}
@@ -1717,7 +1717,7 @@ static int checkout_safe_for_update_only(
return 0;
/* otherwise, stat error and no update */
- giterr_set(GITERR_OS, "failed to stat '%s'", path);
+ git_error_set(GIT_ERROR_OS, "failed to stat '%s'", path);
return -1;
}
@@ -1756,7 +1756,7 @@ static int checkout_write_content(
if ((data->strategy & GIT_CHECKOUT_ALLOW_CONFLICTS) != 0 &&
(error == GIT_ENOTFOUND || error == GIT_EEXISTS))
{
- giterr_clear();
+ git_error_clear();
error = 0;
}
@@ -1863,7 +1863,7 @@ static int checkout_deferred_remove(git_repository *repo, const char *path)
if (error == GIT_ENOTFOUND) {
error = 0;
- giterr_clear();
+ git_error_clear();
}
return error;
@@ -1989,7 +1989,7 @@ static int checkout_path_suffixed(git_buf *path, const char *suffix)
if (i == INT_MAX) {
git_buf_truncate(path, path_len);
- giterr_set(GITERR_CHECKOUT, "could not write '%s': working directory file exists", path->ptr);
+ git_error_set(GIT_ERROR_CHECKOUT, "could not write '%s': working directory file exists", path->ptr);
return GIT_EEXISTS;
}
@@ -2123,7 +2123,7 @@ static int checkout_write_merge(
goto done;
if (result.path == NULL || result.mode == 0) {
- giterr_set(GITERR_CHECKOUT, "could not merge contents of file");
+ git_error_set(GIT_ERROR_CHECKOUT, "could not merge contents of file");
error = GIT_ECONFLICT;
goto done;
}
@@ -2179,7 +2179,7 @@ static int checkout_conflict_add(
int error = git_index_remove(data->index, conflict->path, 0);
if (error == GIT_ENOTFOUND)
- giterr_clear();
+ git_error_clear();
else if (error < 0)
return error;
@@ -2370,7 +2370,7 @@ static int checkout_data_init(
memset(data, 0, sizeof(*data));
if (!repo) {
- giterr_set(GITERR_CHECKOUT, "cannot checkout nothing");
+ git_error_set(GIT_ERROR_CHECKOUT, "cannot checkout nothing");
return -1;
}
@@ -2381,7 +2381,7 @@ static int checkout_data_init(
data->repo = repo;
data->target = target;
- GITERR_CHECK_VERSION(
+ GIT_ERROR_CHECK_VERSION(
proposed, GIT_CHECKOUT_OPTIONS_VERSION, "git_checkout_options");
if (!proposed)
@@ -2424,7 +2424,7 @@ static int checkout_data_init(
*/
if (git_index_has_conflicts(data->index)) {
error = GIT_ECONFLICT;
- giterr_set(GITERR_CHECKOUT,
+ git_error_set(GIT_ERROR_CHECKOUT,
"unresolved conflicts exist in the index");
goto cleanup;
}
@@ -2483,7 +2483,7 @@ static int checkout_data_init(
if (error == GIT_EUNBORNBRANCH) {
error = 0;
- giterr_clear();
+ git_error_clear();
}
if (error < 0)
@@ -2506,7 +2506,7 @@ static int checkout_data_init(
else if (strcmp(conflict_style->value, "diff3") == 0)
data->opts.checkout_strategy |= GIT_CHECKOUT_CONFLICT_STYLE_DIFF3;
else {
- giterr_set(GITERR_CHECKOUT, "unknown style '%s' given for 'merge.conflictstyle'",
+ git_error_set(GIT_ERROR_CHECKOUT, "unknown style '%s' given for 'merge.conflictstyle'",
conflict_style->value);
error = -1;
git_config_entry_free(conflict_style);
@@ -2688,7 +2688,7 @@ int git_checkout_index(
git_iterator *index_i;
if (!index && !repo) {
- giterr_set(GITERR_CHECKOUT,
+ git_error_set(GIT_ERROR_CHECKOUT,
"must provide either repository or index to checkout");
return -1;
}
@@ -2696,7 +2696,7 @@ int git_checkout_index(
if (index && repo &&
git_index_owner(index) &&
git_index_owner(index) != repo) {
- giterr_set(GITERR_CHECKOUT,
+ git_error_set(GIT_ERROR_CHECKOUT,
"index to checkout does not match repository");
return -1;
} else if(index && repo && !git_index_owner(index)) {
@@ -2735,12 +2735,12 @@ int git_checkout_tree(
git_iterator_options iter_opts = GIT_ITERATOR_OPTIONS_INIT;
if (!treeish && !repo) {
- giterr_set(GITERR_CHECKOUT,
+ git_error_set(GIT_ERROR_CHECKOUT,
"must provide either repository or tree to checkout");
return -1;
}
if (treeish && repo && git_object_owner(treeish) != repo) {
- giterr_set(GITERR_CHECKOUT,
+ git_error_set(GIT_ERROR_CHECKOUT,
"object to checkout does not match repository");
return -1;
}
@@ -2750,16 +2750,16 @@ int git_checkout_tree(
if (treeish) {
if (git_object_peel((git_object **)&tree, treeish, GIT_OBJECT_TREE) < 0) {
- giterr_set(
- GITERR_CHECKOUT, "provided object cannot be peeled to a tree");
+ git_error_set(
+ GIT_ERROR_CHECKOUT, "provided object cannot be peeled to a tree");
return -1;
}
}
else {
if ((error = checkout_lookup_head_tree(&tree, repo)) < 0) {
if (error != GIT_EUNBORNBRANCH)
- giterr_set(
- GITERR_CHECKOUT,
+ git_error_set(
+ GIT_ERROR_CHECKOUT,
"HEAD could not be peeled to a tree and no treeish given");
return error;
}