summaryrefslogtreecommitdiff
path: root/src/submodule.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/submodule.c')
-rw-r--r--src/submodule.c86
1 files changed, 43 insertions, 43 deletions
diff --git a/src/submodule.c b/src/submodule.c
index c468a9618..e3ec88554 100644
--- a/src/submodule.c
+++ b/src/submodule.c
@@ -95,7 +95,7 @@ static void submodule_set_lookup_error(int error, const char *name)
if (!error)
return;
- giterr_set(GITERR_SUBMODULE, (error == GIT_ENOTFOUND) ?
+ git_error_set(GIT_ERROR_SUBMODULE, (error == GIT_ENOTFOUND) ?
"no submodule named '%s'" :
"submodule '%s' has not been added yet", name);
}
@@ -114,7 +114,7 @@ static int find_by_path(const git_config_entry *entry, void *payload)
fdot = strchr(entry->name, '.');
ldot = strrchr(entry->name, '.');
data->name = git__strndup(fdot + 1, ldot - fdot - 1);
- GITERR_CHECK_ALLOC(data->name);
+ GIT_ERROR_CHECK_ALLOC(data->name);
}
return 0;
@@ -136,7 +136,7 @@ static int is_path_occupied(bool *occupied, git_repository *repo, const char *pa
if ((error = git_index_find(NULL, index, path)) != GIT_ENOTFOUND) {
if (!error) {
- giterr_set(GITERR_SUBMODULE,
+ git_error_set(GIT_ERROR_SUBMODULE,
"File '%s' already exists in the index", path);
*occupied = true;
}
@@ -151,7 +151,7 @@ static int is_path_occupied(bool *occupied, git_repository *repo, const char *pa
if ((error = git_index_find_prefix(NULL, index, dir.ptr)) != GIT_ENOTFOUND) {
if (!error) {
- giterr_set(GITERR_SUBMODULE,
+ git_error_set(GIT_ERROR_SUBMODULE,
"Directory '%s' already exists in the index", path);
*occupied = true;
}
@@ -214,7 +214,7 @@ static int load_submodule_names(git_strmap **out, git_repository *repo, git_conf
ldot = strrchr(entry->name, '.');
if (git_strmap_exists(names, entry->value)) {
- giterr_set(GITERR_SUBMODULE,
+ git_error_set(GIT_ERROR_SUBMODULE,
"duplicated submodule path '%s'", entry->value);
error = -1;
goto out;
@@ -232,7 +232,7 @@ static int load_submodule_names(git_strmap **out, git_repository *repo, git_conf
git_strmap_insert(names, git__strdup(entry->value), git_buf_detach(&buf), &rval);
if (rval < 0) {
- giterr_set(GITERR_NOMEMORY, "error inserting submodule into hash table");
+ git_error_set(GIT_ERROR_NOMEMORY, "error inserting submodule into hash table");
error = -1;
goto out;
}
@@ -262,7 +262,7 @@ int git_submodule_lookup(
assert(repo && name);
if (repo->is_bare) {
- giterr_set(GITERR_SUBMODULE, "cannot get submodules without a working tree");
+ git_error_set(GIT_ERROR_SUBMODULE, "cannot get submodules without a working tree");
return -1;
}
@@ -551,9 +551,9 @@ int git_submodule__map(git_repository *repo, git_strmap *map)
/* get sources that we will need to check */
if (git_repository_index(&idx, repo) < 0)
- giterr_clear();
+ git_error_clear();
if (git_repository_head_tree(&head, repo) < 0)
- giterr_clear();
+ git_error_clear();
wd = git_repository_workdir(repo);
if (wd && (error = git_buf_joinpath(&path, wd, GIT_MODULES_FILE)) < 0)
@@ -614,7 +614,7 @@ int git_submodule_foreach(
size_t i;
if (repo->is_bare) {
- giterr_set(GITERR_SUBMODULE, "cannot get submodules without a working tree");
+ git_error_set(GIT_ERROR_SUBMODULE, "cannot get submodules without a working tree");
return -1;
}
@@ -641,7 +641,7 @@ int git_submodule_foreach(
git_vector_foreach(&snapshot, i, sm) {
if ((error = callback(sm, sm->name, payload)) != 0) {
- giterr_set_after_callback(error);
+ git_error_set_after_callback(error);
break;
}
}
@@ -730,9 +730,9 @@ int git_submodule_add_setup(
/* see if there is already an entry for this submodule */
if (git_submodule_lookup(NULL, repo, path) < 0)
- giterr_clear();
+ git_error_clear();
else {
- giterr_set(GITERR_SUBMODULE,
+ git_error_set(GIT_ERROR_SUBMODULE,
"attempt to add submodule '%s' that already exists", path);
return GIT_EEXISTS;
}
@@ -743,7 +743,7 @@ int git_submodule_add_setup(
path += strlen(git_repository_workdir(repo));
if (git_path_root(path) >= 0) {
- giterr_set(GITERR_SUBMODULE, "submodule path must be a relative path");
+ git_error_set(GIT_ERROR_SUBMODULE, "submodule path must be a relative path");
error = -1;
goto cleanup;
}
@@ -759,7 +759,7 @@ int git_submodule_add_setup(
/* update .gitmodules */
if (!(mods = open_gitmodules(repo, GITMODULES_CREATE))) {
- giterr_set(GITERR_SUBMODULE,
+ git_error_set(GIT_ERROR_SUBMODULE,
"adding submodules to a bare repository is not supported");
return -1;
}
@@ -880,7 +880,7 @@ int git_submodule_add_to_index(git_submodule *sm, int write_index)
/* read stat information for submodule working directory */
if (p_stat(path.ptr, &st) < 0) {
- giterr_set(GITERR_SUBMODULE,
+ git_error_set(GIT_ERROR_SUBMODULE,
"cannot add submodule without working directory");
error = -1;
goto cleanup;
@@ -893,7 +893,7 @@ int git_submodule_add_to_index(git_submodule *sm, int write_index)
/* calling git_submodule_open will have set sm->wd_oid if possible */
if ((sm->flags & GIT_SUBMODULE_STATUS__WD_OID_VALID) == 0) {
- giterr_set(GITERR_SUBMODULE,
+ git_error_set(GIT_ERROR_SUBMODULE,
"cannot add submodule without HEAD to index");
error = -1;
goto cleanup;
@@ -984,7 +984,7 @@ int git_submodule_resolve_url(git_buf *out, git_repository *repo, const char *ur
} else if (strchr(url, ':') != NULL || url[0] == '/') {
error = git_buf_sets(out, url);
} else {
- giterr_set(GITERR_SUBMODULE, "invalid format for submodule URL");
+ git_error_set(GIT_ERROR_SUBMODULE, "invalid format for submodule URL");
error = -1;
}
@@ -1023,7 +1023,7 @@ static int write_mapped_var(git_repository *repo, const char *name, git_cvar_map
const char *val;
if (git_config_lookup_map_enum(&type, &val, maps, nmaps, ival) < 0) {
- giterr_set(GITERR_SUBMODULE, "invalid value for %s", var);
+ git_error_set(GIT_ERROR_SUBMODULE, "invalid value for %s", var);
return -1;
}
@@ -1086,7 +1086,7 @@ const git_oid *git_submodule_wd_id(git_submodule *submodule)
if (!git_submodule_open_bare(&subrepo, submodule))
git_repository_free(subrepo);
else
- giterr_clear();
+ git_error_clear();
}
if (submodule->flags & GIT_SUBMODULE_STATUS__WD_OID_VALID)
@@ -1227,7 +1227,7 @@ int git_submodule_update(git_submodule *sm, int init, git_submodule_update_optio
if (_update_options)
memcpy(&update_options, _update_options, sizeof(git_submodule_update_options));
- GITERR_CHECK_VERSION(&update_options, GIT_SUBMODULE_UPDATE_OPTIONS_VERSION, "git_submodule_update_options");
+ GIT_ERROR_CHECK_VERSION(&update_options, GIT_SUBMODULE_UPDATE_OPTIONS_VERSION, "git_submodule_update_options");
/* Copy over the remote callbacks */
memcpy(&clone_options.fetch_opts, &update_options.fetch_opts, sizeof(git_fetch_options));
@@ -1258,7 +1258,7 @@ int git_submodule_update(git_submodule *sm, int init, git_submodule_update_optio
goto done;
if (!init) {
- giterr_set(GITERR_SUBMODULE, "submodule is not initialized");
+ git_error_set(GIT_ERROR_SUBMODULE, "submodule is not initialized");
error = GIT_ERROR;
goto done;
}
@@ -1302,7 +1302,7 @@ int git_submodule_update(git_submodule *sm, int init, git_submodule_update_optio
goto done;
if ((oid = git_submodule_index_id(sm)) == NULL) {
- giterr_set(GITERR_SUBMODULE, "could not get ID of submodule in index");
+ git_error_set(GIT_ERROR_SUBMODULE, "could not get ID of submodule in index");
error = -1;
goto done;
}
@@ -1346,7 +1346,7 @@ int git_submodule_init(git_submodule *sm, int overwrite)
git_config *cfg = NULL;
if (!sm->url) {
- giterr_set(GITERR_SUBMODULE,
+ git_error_set(GIT_ERROR_SUBMODULE,
"no URL configured for submodule '%s'", sm->name);
return -1;
}
@@ -1390,7 +1390,7 @@ int git_submodule_sync(git_submodule *sm)
git_repository *smrepo = NULL;
if (!sm->url) {
- giterr_set(GITERR_SUBMODULE,
+ git_error_set(GIT_ERROR_SUBMODULE,
"no URL configured for submodule '%s'", sm->name);
return -1;
}
@@ -1412,7 +1412,7 @@ int git_submodule_sync(git_submodule *sm)
if ((error = git_repository_config__weakptr(&cfg, smrepo)) < 0)
/* return error from reading submodule config */;
else if ((error = lookup_head_remote_key(&remote_name, smrepo)) < 0) {
- giterr_clear();
+ git_error_clear();
error = git_buf_sets(&key, "remote.origin.url");
} else {
error = git_buf_join3(
@@ -1469,7 +1469,7 @@ static int git_submodule__open(
if (!git_reference_name_to_id(&sm->wd_oid, *subrepo, GIT_HEAD_FILE))
sm->flags |= GIT_SUBMODULE_STATUS__WD_OID_VALID;
else
- giterr_clear();
+ git_error_clear();
} else if (git_path_exists(path.ptr)) {
sm->flags |= GIT_SUBMODULE_STATUS__WD_SCANNED |
GIT_SUBMODULE_STATUS_IN_WD;
@@ -1559,7 +1559,7 @@ static int submodule_update_head(git_submodule *submodule)
/* if we can't look up file in current head, then done */
if (git_repository_head_tree(&head, submodule->repo) < 0 ||
git_tree_entry_bypath(&te, head, submodule->path) < 0)
- giterr_clear();
+ git_error_clear();
else
submodule_update_from_head_data(submodule, te->attr, git_tree_entry_id(te));
@@ -1662,12 +1662,12 @@ int git_submodule__status(
if (ign == GIT_SUBMODULE_IGNORE_DIRTY) {
/* git_submodule_open_bare will load WD OID data */
if (git_submodule_open_bare(&smrepo, sm) < 0)
- giterr_clear();
+ git_error_clear();
else
git_repository_free(smrepo);
smrepo = NULL;
} else if (git_submodule_open(&smrepo, sm) < 0) {
- giterr_clear();
+ git_error_clear();
smrepo = NULL;
}
@@ -1725,12 +1725,12 @@ static int submodule_alloc(
git_submodule *sm;
if (!name || !(namelen = strlen(name))) {
- giterr_set(GITERR_SUBMODULE, "invalid submodule name");
+ git_error_set(GIT_ERROR_SUBMODULE, "invalid submodule name");
return -1;
}
sm = git__calloc(1, sizeof(git_submodule));
- GITERR_CHECK_ALLOC(sm);
+ GIT_ERROR_CHECK_ALLOC(sm);
sm->name = sm->path = git__strdup(name);
if (!sm->name) {
@@ -1776,7 +1776,7 @@ void git_submodule_free(git_submodule *sm)
static int submodule_config_error(const char *property, const char *value)
{
- giterr_set(GITERR_INVALID,
+ git_error_set(GIT_ERROR_INVALID,
"invalid value for submodule '%s' property: '%s'", property, value);
return -1;
}
@@ -1867,7 +1867,7 @@ static int submodule_read_config(git_submodule *sm, git_config *cfg)
if (sm->path != sm->name)
git__free(sm->path);
sm->path = git__strdup(value);
- GITERR_CHECK_ALLOC(sm->path);
+ GIT_ERROR_CHECK_ALLOC(sm->path);
}
}
@@ -1880,7 +1880,7 @@ static int submodule_read_config(git_submodule *sm, git_config *cfg)
if (!looks_like_command_line_option(value)) {
in_config = 1;
sm->url = git__strdup(value);
- GITERR_CHECK_ALLOC(sm->url);
+ GIT_ERROR_CHECK_ALLOC(sm->url);
}
} else if (error != GIT_ENOTFOUND) {
goto cleanup;
@@ -1889,7 +1889,7 @@ static int submodule_read_config(git_submodule *sm, git_config *cfg)
if ((error = get_value(&value, cfg, &key, sm->name, "branch")) == 0) {
in_config = 1;
sm->branch = git__strdup(value);
- GITERR_CHECK_ALLOC(sm->branch);
+ GIT_ERROR_CHECK_ALLOC(sm->branch);
} else if (error != GIT_ENOTFOUND) {
goto cleanup;
}
@@ -2091,7 +2091,7 @@ static int lookup_head_remote_key(git_buf *remote_name, git_repository *repo)
* a remote key for the local tracking branch HEAD points to.
**/
if (!git_reference_is_branch(head)) {
- giterr_set(GITERR_INVALID,
+ git_error_set(GIT_ERROR_INVALID,
"HEAD does not refer to a branch.");
error = GIT_ENOTFOUND;
goto done;
@@ -2140,8 +2140,8 @@ static int lookup_default_remote(git_remote **remote, git_repository *repo)
error = git_remote_lookup(remote, repo, "origin");
if (error == GIT_ENOTFOUND)
- giterr_set(
- GITERR_SUBMODULE,
+ git_error_set(
+ GIT_ERROR_SUBMODULE,
"cannot get default remote for submodule - no local tracking "
"branch for HEAD and origin does not exist");
@@ -2160,7 +2160,7 @@ static int get_url_base(git_buf *url, git_repository *repo)
} else if (error != GIT_ENOTFOUND)
goto out;
else
- giterr_clear();
+ git_error_clear();
/* if repository does not have a default remote, use workdir instead */
if (git_repository_is_worktree(repo)) {
@@ -2241,11 +2241,11 @@ static void submodule_get_wd_status(
/* if we don't have an unborn head, check diff with index */
if (git_repository_head_tree(&sm_head, sm_repo) < 0)
- giterr_clear();
+ git_error_clear();
else {
/* perform head to index diff on submodule */
if (git_diff_tree_to_index(&diff, sm_repo, sm_head, index, &opt) < 0)
- giterr_clear();
+ git_error_clear();
else {
if (git_diff_num_deltas(diff) > 0)
*status |= GIT_SUBMODULE_STATUS_WD_INDEX_MODIFIED;
@@ -2258,7 +2258,7 @@ static void submodule_get_wd_status(
/* perform index-to-workdir diff on submodule */
if (git_diff_index_to_workdir(&diff, sm_repo, index, &opt) < 0)
- giterr_clear();
+ git_error_clear();
else {
size_t untracked =
git_diff_num_deltas_of_type(diff, GIT_DELTA_UNTRACKED);