Commit f673e232 by Edward Thomson

git_error: use new names in internal APIs and usage

Move to the `git_error` name in the internal API for error-related
functions.
parent 647dfdb4
...@@ -49,7 +49,7 @@ int git_allocator_setup(git_allocator *allocator) ...@@ -49,7 +49,7 @@ int git_allocator_setup(git_allocator *allocator)
int git_win32_crtdbg_init_allocator(git_allocator *allocator) int git_win32_crtdbg_init_allocator(git_allocator *allocator)
{ {
GIT_UNUSED(allocator); GIT_UNUSED(allocator);
giterr_set(GIT_EINVALID, "crtdbg memory allocator not available"); git_error_set(GIT_EINVALID, "crtdbg memory allocator not available");
return -1; return -1;
} }
#endif #endif
...@@ -31,7 +31,7 @@ static int annotated_commit_init( ...@@ -31,7 +31,7 @@ static int annotated_commit_init(
*out = NULL; *out = NULL;
annotated_commit = git__calloc(1, sizeof(git_annotated_commit)); annotated_commit = git__calloc(1, sizeof(git_annotated_commit));
GITERR_CHECK_ALLOC(annotated_commit); GIT_ERROR_CHECK_ALLOC(annotated_commit);
annotated_commit->type = GIT_ANNOTATED_COMMIT_REAL; annotated_commit->type = GIT_ANNOTATED_COMMIT_REAL;
...@@ -45,7 +45,7 @@ static int annotated_commit_init( ...@@ -45,7 +45,7 @@ static int annotated_commit_init(
description = annotated_commit->id_str; description = annotated_commit->id_str;
annotated_commit->description = git__strdup(description); annotated_commit->description = git__strdup(description);
GITERR_CHECK_ALLOC(annotated_commit->description); GIT_ERROR_CHECK_ALLOC(annotated_commit->description);
done: done:
if (!error) if (!error)
...@@ -140,7 +140,7 @@ int git_annotated_commit_from_ref( ...@@ -140,7 +140,7 @@ int git_annotated_commit_from_ref(
if (!error) { if (!error) {
(*out)->ref_name = git__strdup(git_reference_name(ref)); (*out)->ref_name = git__strdup(git_reference_name(ref));
GITERR_CHECK_ALLOC((*out)->ref_name); GIT_ERROR_CHECK_ALLOC((*out)->ref_name);
} }
git_object_free(peeled); git_object_free(peeled);
...@@ -180,10 +180,10 @@ int git_annotated_commit_from_fetchhead( ...@@ -180,10 +180,10 @@ int git_annotated_commit_from_fetchhead(
return -1; return -1;
(*out)->ref_name = git__strdup(branch_name); (*out)->ref_name = git__strdup(branch_name);
GITERR_CHECK_ALLOC((*out)->ref_name); GIT_ERROR_CHECK_ALLOC((*out)->ref_name);
(*out)->remote_url = git__strdup(remote_url); (*out)->remote_url = git__strdup(remote_url);
GITERR_CHECK_ALLOC((*out)->remote_url); GIT_ERROR_CHECK_ALLOC((*out)->remote_url);
return 0; return 0;
} }
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include "index.h" #include "index.h"
#define apply_err(...) \ #define apply_err(...) \
( giterr_set(GITERR_PATCH, __VA_ARGS__), GIT_EAPPLYFAIL ) ( git_error_set(GIT_ERROR_PATCH, __VA_ARGS__), GIT_EAPPLYFAIL )
typedef struct { typedef struct {
/* The lines that we allocate ourself are allocated out of the pool. /* The lines that we allocate ourself are allocated out of the pool.
...@@ -68,7 +68,7 @@ static int patch_image_init_fromstr( ...@@ -68,7 +68,7 @@ static int patch_image_init_fromstr(
end++; end++;
line = git_pool_mallocz(&out->pool, 1); line = git_pool_mallocz(&out->pool, 1);
GITERR_CHECK_ALLOC(line); GIT_ERROR_CHECK_ALLOC(line);
if (git_vector_insert(&out->lines, line) < 0) if (git_vector_insert(&out->lines, line) < 0)
return -1; return -1;
...@@ -155,7 +155,7 @@ static int update_hunk( ...@@ -155,7 +155,7 @@ static int update_hunk(
&image->lines, linenum, (prelen - postlen)); &image->lines, linenum, (prelen - postlen));
if (error) { if (error) {
giterr_set_oom(); git_error_set_oom();
return -1; return -1;
} }
...@@ -483,7 +483,7 @@ static int apply_one( ...@@ -483,7 +483,7 @@ static int apply_one(
postimage_reader, delta->old_file.path)) == 0) { postimage_reader, delta->old_file.path)) == 0) {
skip_preimage = true; skip_preimage = true;
} else if (error == GIT_ENOTFOUND) { } else if (error == GIT_ENOTFOUND) {
giterr_clear(); git_error_clear();
error = 0; error = 0;
} else { } else {
goto done; goto done;
...@@ -777,7 +777,7 @@ int git_apply( ...@@ -777,7 +777,7 @@ int git_apply(
assert(repo && diff); assert(repo && diff);
GITERR_CHECK_VERSION( GIT_ERROR_CHECK_VERSION(
given_opts, GIT_APPLY_OPTIONS_VERSION, "git_apply_options"); given_opts, GIT_APPLY_OPTIONS_VERSION, "git_apply_options");
if (given_opts) if (given_opts)
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* git_array_t(int) my_ints = GIT_ARRAY_INIT; * git_array_t(int) my_ints = GIT_ARRAY_INIT;
* ... * ...
* int *i = git_array_alloc(my_ints); * int *i = git_array_alloc(my_ints);
* GITERR_CHECK_ALLOC(i); * GIT_ERROR_CHECK_ALLOC(i);
* ... * ...
* git_array_clear(my_ints); * git_array_clear(my_ints);
* *
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#define git_array_clear(a) \ #define git_array_clear(a) \
do { git__free((a).ptr); git_array_init(a); } while (0) do { git__free((a).ptr); git_array_init(a); } while (0)
#define GITERR_CHECK_ARRAY(a) GITERR_CHECK_ALLOC((a).ptr) #define GIT_ERROR_CHECK_ARRAY(a) GIT_ERROR_CHECK_ALLOC((a).ptr)
typedef git_array_t(char) git_array_generic_t; typedef git_array_t(char) git_array_generic_t;
......
...@@ -135,7 +135,7 @@ int git_attr_get_many_with_session( ...@@ -135,7 +135,7 @@ int git_attr_get_many_with_session(
goto cleanup; goto cleanup;
info = git__calloc(num_attr, sizeof(attr_get_many_info)); info = git__calloc(num_attr, sizeof(attr_get_many_info));
GITERR_CHECK_ALLOC(info); GIT_ERROR_CHECK_ALLOC(info);
git_vector_foreach(&files, i, file) { git_vector_foreach(&files, i, file) {
...@@ -233,7 +233,7 @@ int git_attr_foreach( ...@@ -233,7 +233,7 @@ int git_attr_foreach(
error = callback(assign->name, assign->value, payload); error = callback(assign->name, assign->value, payload);
if (error) { if (error) {
giterr_set_after_callback(error); git_error_set_after_callback(error);
goto cleanup; goto cleanup;
} }
} }
...@@ -277,7 +277,7 @@ static int system_attr_file( ...@@ -277,7 +277,7 @@ static int system_attr_file(
error = git_sysdir_find_system_file(out, GIT_ATTR_FILE_SYSTEM); error = git_sysdir_find_system_file(out, GIT_ATTR_FILE_SYSTEM);
if (error == GIT_ENOTFOUND) if (error == GIT_ENOTFOUND)
giterr_clear(); git_error_clear();
return error; return error;
} }
...@@ -286,7 +286,7 @@ static int system_attr_file( ...@@ -286,7 +286,7 @@ static int system_attr_file(
error = git_sysdir_find_system_file(&attr_session->sysdir, GIT_ATTR_FILE_SYSTEM); error = git_sysdir_find_system_file(&attr_session->sysdir, GIT_ATTR_FILE_SYSTEM);
if (error == GIT_ENOTFOUND) if (error == GIT_ENOTFOUND)
giterr_clear(); git_error_clear();
else if (error) else if (error)
return error; return error;
...@@ -377,12 +377,12 @@ int git_attr_add_macro( ...@@ -377,12 +377,12 @@ int git_attr_add_macro(
return error; return error;
macro = git__calloc(1, sizeof(git_attr_rule)); macro = git__calloc(1, sizeof(git_attr_rule));
GITERR_CHECK_ALLOC(macro); GIT_ERROR_CHECK_ALLOC(macro);
pool = &git_repository_attr_cache(repo)->pool; pool = &git_repository_attr_cache(repo)->pool;
macro->match.pattern = git_pool_strdup(pool, name); macro->match.pattern = git_pool_strdup(pool, name);
GITERR_CHECK_ALLOC(macro->match.pattern); GIT_ERROR_CHECK_ALLOC(macro->match.pattern);
macro->match.length = strlen(macro->match.pattern); macro->match.length = strlen(macro->match.pattern);
macro->match.flags = GIT_ATTR_FNMATCH_MACRO; macro->match.flags = GIT_ATTR_FNMATCH_MACRO;
...@@ -532,7 +532,7 @@ static int collect_attr_files( ...@@ -532,7 +532,7 @@ static int collect_attr_files(
info.flags = flags; info.flags = flags;
info.workdir = workdir; info.workdir = workdir;
if (git_repository_index__weakptr(&info.index, repo) < 0) if (git_repository_index__weakptr(&info.index, repo) < 0)
giterr_clear(); /* no error even if there is no index */ git_error_clear(); /* no error even if there is no index */
info.files = files; info.files = files;
if (!strcmp(dir.ptr, ".")) if (!strcmp(dir.ptr, "."))
......
...@@ -34,10 +34,10 @@ int git_attr_file__new( ...@@ -34,10 +34,10 @@ int git_attr_file__new(
git_attr_file_source source) git_attr_file_source source)
{ {
git_attr_file *attrs = git__calloc(1, sizeof(git_attr_file)); git_attr_file *attrs = git__calloc(1, sizeof(git_attr_file));
GITERR_CHECK_ALLOC(attrs); GIT_ERROR_CHECK_ALLOC(attrs);
if (git_mutex_init(&attrs->lock) < 0) { if (git_mutex_init(&attrs->lock) < 0) {
giterr_set(GITERR_OS, "failed to initialize lock"); git_error_set(GIT_ERROR_OS, "failed to initialize lock");
git__free(attrs); git__free(attrs);
return -1; return -1;
} }
...@@ -56,7 +56,7 @@ int git_attr_file__clear_rules(git_attr_file *file, bool need_lock) ...@@ -56,7 +56,7 @@ int git_attr_file__clear_rules(git_attr_file *file, bool need_lock)
git_attr_rule *rule; git_attr_rule *rule;
if (need_lock && git_mutex_lock(&file->lock) < 0) { if (need_lock && git_mutex_lock(&file->lock) < 0) {
giterr_set(GITERR_OS, "failed to lock attribute file"); git_error_set(GIT_ERROR_OS, "failed to lock attribute file");
return -1; return -1;
} }
...@@ -147,7 +147,7 @@ int git_attr_file__load( ...@@ -147,7 +147,7 @@ int git_attr_file__load(
break; break;
} }
default: default:
giterr_set(GITERR_INVALID, "unknown file source %d", source); git_error_set(GIT_ERROR_INVALID, "unknown file source %d", source);
return -1; return -1;
} }
...@@ -219,7 +219,7 @@ int git_attr_file__out_of_date( ...@@ -219,7 +219,7 @@ int git_attr_file__out_of_date(
} }
default: default:
giterr_set(GITERR_INVALID, "invalid file type %d", file->source); git_error_set(GIT_ERROR_INVALID, "invalid file type %d", file->source);
return -1; return -1;
} }
} }
...@@ -245,7 +245,7 @@ int git_attr_file__parse_buffer( ...@@ -245,7 +245,7 @@ int git_attr_file__parse_buffer(
context = attrs->entry->path; context = attrs->entry->path;
if (git_mutex_lock(&attrs->lock) < 0) { if (git_mutex_lock(&attrs->lock) < 0) {
giterr_set(GITERR_OS, "failed to lock attribute file"); git_error_set(GIT_ERROR_OS, "failed to lock attribute file");
return -1; return -1;
} }
...@@ -751,7 +751,7 @@ int git_attr_assignment__parse( ...@@ -751,7 +751,7 @@ int git_attr_assignment__parse(
/* allocate assign if needed */ /* allocate assign if needed */
if (!assign) { if (!assign) {
assign = git__calloc(1, sizeof(git_attr_assignment)); assign = git__calloc(1, sizeof(git_attr_assignment));
GITERR_CHECK_ALLOC(assign); GIT_ERROR_CHECK_ALLOC(assign);
GIT_REFCOUNT_INC(assign); GIT_REFCOUNT_INC(assign);
} }
...@@ -785,7 +785,7 @@ int git_attr_assignment__parse( ...@@ -785,7 +785,7 @@ int git_attr_assignment__parse(
/* allocate permanent storage for name */ /* allocate permanent storage for name */
assign->name = git_pool_strndup(pool, name_start, scan - name_start); assign->name = git_pool_strndup(pool, name_start, scan - name_start);
GITERR_CHECK_ALLOC(assign->name); GIT_ERROR_CHECK_ALLOC(assign->name);
/* if there is an equals sign, find the value */ /* if there is an equals sign, find the value */
if (*scan == '=') { if (*scan == '=') {
...@@ -794,7 +794,7 @@ int git_attr_assignment__parse( ...@@ -794,7 +794,7 @@ int git_attr_assignment__parse(
/* if we found a value, allocate permanent storage for it */ /* if we found a value, allocate permanent storage for it */
if (scan > value_start) { if (scan > value_start) {
assign->value = git_pool_strndup(pool, value_start, scan - value_start); assign->value = git_pool_strndup(pool, value_start, scan - value_start);
GITERR_CHECK_ALLOC(assign->value); GIT_ERROR_CHECK_ALLOC(assign->value);
} }
} }
......
...@@ -18,7 +18,7 @@ GIT_INLINE(int) attr_cache_lock(git_attr_cache *cache) ...@@ -18,7 +18,7 @@ GIT_INLINE(int) attr_cache_lock(git_attr_cache *cache)
GIT_UNUSED(cache); /* avoid warning if threading is off */ GIT_UNUSED(cache); /* avoid warning if threading is off */
if (git_mutex_lock(&cache->lock) < 0) { if (git_mutex_lock(&cache->lock) < 0) {
giterr_set(GITERR_OS, "unable to get attr cache lock"); git_error_set(GIT_ERROR_OS, "unable to get attr cache lock");
return -1; return -1;
} }
return 0; return 0;
...@@ -60,7 +60,7 @@ int git_attr_cache__alloc_file_entry( ...@@ -60,7 +60,7 @@ int git_attr_cache__alloc_file_entry(
} }
ce = git_pool_mallocz(pool, (uint32_t)cachesize); ce = git_pool_mallocz(pool, (uint32_t)cachesize);
GITERR_CHECK_ALLOC(ce); GIT_ERROR_CHECK_ALLOC(ce);
if (baselen) { if (baselen) {
memcpy(ce->fullpath, base, baselen); memcpy(ce->fullpath, base, baselen);
...@@ -250,7 +250,7 @@ int git_attr_cache__get( ...@@ -250,7 +250,7 @@ int git_attr_cache__get(
} }
/* no error if file simply doesn't exist */ /* no error if file simply doesn't exist */
if (error == GIT_ENOTFOUND) { if (error == GIT_ENOTFOUND) {
giterr_clear(); git_error_clear();
error = 0; error = 0;
} }
} }
...@@ -374,11 +374,11 @@ int git_attr_cache__init(git_repository *repo) ...@@ -374,11 +374,11 @@ int git_attr_cache__init(git_repository *repo)
return 0; return 0;
cache = git__calloc(1, sizeof(git_attr_cache)); cache = git__calloc(1, sizeof(git_attr_cache));
GITERR_CHECK_ALLOC(cache); GIT_ERROR_CHECK_ALLOC(cache);
/* set up lock */ /* set up lock */
if (git_mutex_init(&cache->lock) < 0) { if (git_mutex_init(&cache->lock) < 0) {
giterr_set(GITERR_OS, "unable to initialize lock for attr cache"); git_error_set(GIT_ERROR_OS, "unable to initialize lock for attr cache");
git__free(cache); git__free(cache);
return -1; return -1;
} }
...@@ -443,7 +443,7 @@ int git_attr_cache__insert_macro(git_repository *repo, git_attr_rule *macro) ...@@ -443,7 +443,7 @@ int git_attr_cache__insert_macro(git_repository *repo, git_attr_rule *macro)
return 0; return 0;
if (attr_cache_lock(cache) < 0) { if (attr_cache_lock(cache) < 0) {
giterr_set(GITERR_OS, "unable to get attr cache lock"); git_error_set(GIT_ERROR_OS, "unable to get attr cache lock");
error = -1; error = -1;
} else { } else {
git_strmap_insert(macros, macro->match.pattern, macro, &error); git_strmap_insert(macros, macro->match.pattern, macro, &error);
......
...@@ -272,7 +272,7 @@ static int index_blob_lines(git_blame *blame) ...@@ -272,7 +272,7 @@ static int index_blob_lines(git_blame *blame)
while (len--) { while (len--) {
if (bol) { if (bol) {
i = git_array_alloc(blame->line_index); i = git_array_alloc(blame->line_index);
GITERR_CHECK_ALLOC(i); GIT_ERROR_CHECK_ALLOC(i);
*i = buf - blame->final_buf; *i = buf - blame->final_buf;
bol = 0; bol = 0;
} }
...@@ -282,7 +282,7 @@ static int index_blob_lines(git_blame *blame) ...@@ -282,7 +282,7 @@ static int index_blob_lines(git_blame *blame)
} }
} }
i = git_array_alloc(blame->line_index); i = git_array_alloc(blame->line_index);
GITERR_CHECK_ALLOC(i); GIT_ERROR_CHECK_ALLOC(i);
*i = buf - blame->final_buf; *i = buf - blame->final_buf;
blame->num_lines = num + incomplete; blame->num_lines = num + incomplete;
return blame->num_lines; return blame->num_lines;
...@@ -334,7 +334,7 @@ static int blame_internal(git_blame *blame) ...@@ -334,7 +334,7 @@ static int blame_internal(git_blame *blame)
blame->final_buf_size = git_blob_rawsize(blame->final_blob); blame->final_buf_size = git_blob_rawsize(blame->final_blob);
ent = git__calloc(1, sizeof(git_blame__entry)); ent = git__calloc(1, sizeof(git_blame__entry));
GITERR_CHECK_ALLOC(ent); GIT_ERROR_CHECK_ALLOC(ent);
ent->num_lines = index_blob_lines(blame); ent->num_lines = index_blob_lines(blame);
ent->lno = blame->options.min_line - 1; ent->lno = blame->options.min_line - 1;
...@@ -381,7 +381,7 @@ int git_blame_file( ...@@ -381,7 +381,7 @@ int git_blame_file(
goto on_error; goto on_error;
blame = git_blame__alloc(repo, normOptions, path); blame = git_blame__alloc(repo, normOptions, path);
GITERR_CHECK_ALLOC(blame); GIT_ERROR_CHECK_ALLOC(blame);
if ((error = load_blob(blame)) < 0) if ((error = load_blob(blame)) < 0)
goto on_error; goto on_error;
...@@ -423,14 +423,14 @@ static int buffer_hunk_cb( ...@@ -423,14 +423,14 @@ static int buffer_hunk_cb(
if (!blame->current_hunk) { if (!blame->current_hunk) {
/* Line added at the end of the file */ /* Line added at the end of the file */
blame->current_hunk = new_hunk(wedge_line, 0, wedge_line, blame->path); blame->current_hunk = new_hunk(wedge_line, 0, wedge_line, blame->path);
GITERR_CHECK_ALLOC(blame->current_hunk); GIT_ERROR_CHECK_ALLOC(blame->current_hunk);
git_vector_insert(&blame->hunks, blame->current_hunk); git_vector_insert(&blame->hunks, blame->current_hunk);
} else if (!hunk_starts_at_or_after_line(blame->current_hunk, wedge_line)){ } else if (!hunk_starts_at_or_after_line(blame->current_hunk, wedge_line)){
/* If this hunk doesn't start between existing hunks, split a hunk up so it does */ /* If this hunk doesn't start between existing hunks, split a hunk up so it does */
blame->current_hunk = split_hunk_in_vector(&blame->hunks, blame->current_hunk, blame->current_hunk = split_hunk_in_vector(&blame->hunks, blame->current_hunk,
wedge_line - blame->current_hunk->orig_start_line_number, true); wedge_line - blame->current_hunk->orig_start_line_number, true);
GITERR_CHECK_ALLOC(blame->current_hunk); GIT_ERROR_CHECK_ALLOC(blame->current_hunk);
} }
return 0; return 0;
...@@ -459,7 +459,7 @@ static int buffer_line_cb( ...@@ -459,7 +459,7 @@ static int buffer_line_cb(
/* Create a new buffer-blame hunk with this line */ /* Create a new buffer-blame hunk with this line */
shift_hunks_by(&blame->hunks, blame->current_diff_line, 1); shift_hunks_by(&blame->hunks, blame->current_diff_line, 1);
blame->current_hunk = new_hunk(blame->current_diff_line, 1, 0, blame->path); blame->current_hunk = new_hunk(blame->current_diff_line, 1, 0, blame->path);
GITERR_CHECK_ALLOC(blame->current_hunk); GIT_ERROR_CHECK_ALLOC(blame->current_hunk);
git_vector_insert_sorted(&blame->hunks, blame->current_hunk, NULL); git_vector_insert_sorted(&blame->hunks, blame->current_hunk, NULL);
} }
...@@ -500,12 +500,12 @@ int git_blame_buffer( ...@@ -500,12 +500,12 @@ int git_blame_buffer(
assert(out && reference && buffer && buffer_len); assert(out && reference && buffer && buffer_len);
blame = git_blame__alloc(reference->repository, reference->options, reference->path); blame = git_blame__alloc(reference->repository, reference->options, reference->path);
GITERR_CHECK_ALLOC(blame); GIT_ERROR_CHECK_ALLOC(blame);
/* Duplicate all of the hunk structures in the reference blame */ /* Duplicate all of the hunk structures in the reference blame */
git_vector_foreach(&reference->hunks, i, hunk) { git_vector_foreach(&reference->hunks, i, hunk) {
git_blame_hunk *h = dup_hunk(hunk); git_blame_hunk *h = dup_hunk(hunk);
GITERR_CHECK_ALLOC(h); GIT_ERROR_CHECK_ALLOC(h);
git_vector_insert(&blame->hunks, h); git_vector_insert(&blame->hunks, h);
} }
......
...@@ -46,10 +46,10 @@ static int make_origin(git_blame__origin **out, git_commit *commit, const char * ...@@ -46,10 +46,10 @@ static int make_origin(git_blame__origin **out, git_commit *commit, const char *
path, GIT_OBJECT_BLOB)) < 0) path, GIT_OBJECT_BLOB)) < 0)
return error; return error;
GITERR_CHECK_ALLOC_ADD(&alloc_len, sizeof(*o), path_len); GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, sizeof(*o), path_len);
GITERR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, 1); GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, 1);
o = git__calloc(1, alloc_len); o = git__calloc(1, alloc_len);
GITERR_CHECK_ALLOC(o); GIT_ERROR_CHECK_ALLOC(o);
o->commit = commit; o->commit = commit;
o->blob = (git_blob *) blob; o->blob = (git_blob *) blob;
...@@ -365,7 +365,7 @@ static int diff_hunks(mmfile_t file_a, mmfile_t file_b, void *cb_data) ...@@ -365,7 +365,7 @@ static int diff_hunks(mmfile_t file_a, mmfile_t file_b, void *cb_data)
if (file_a.size > GIT_XDIFF_MAX_SIZE || if (file_a.size > GIT_XDIFF_MAX_SIZE ||
file_b.size > GIT_XDIFF_MAX_SIZE) { file_b.size > GIT_XDIFF_MAX_SIZE) {
giterr_set(GITERR_INVALID, "file too large to blame"); git_error_set(GIT_ERROR_INVALID, "file too large to blame");
return -1; return -1;
} }
...@@ -522,7 +522,7 @@ static int pass_blame(git_blame *blame, git_blame__origin *origin, uint32_t opt) ...@@ -522,7 +522,7 @@ static int pass_blame(git_blame *blame, git_blame__origin *origin, uint32_t opt)
memset(sg_buf, 0, sizeof(sg_buf)); memset(sg_buf, 0, sizeof(sg_buf));
else { else {
sg_origin = git__calloc(num_parents, sizeof(*sg_origin)); sg_origin = git__calloc(num_parents, sizeof(*sg_origin));
GITERR_CHECK_ALLOC(sg_origin); GIT_ERROR_CHECK_ALLOC(sg_origin);
} }
for (i=0; i<num_parents; i++) { for (i=0; i<num_parents; i++) {
......
...@@ -116,7 +116,7 @@ static int write_file_stream( ...@@ -116,7 +116,7 @@ static int write_file_stream(
p_close(fd); p_close(fd);
if (written != file_size || read_len < 0) { if (written != file_size || read_len < 0) {
giterr_set(GITERR_OS, "failed to read file into stream"); git_error_set(GIT_ERROR_OS, "failed to read file into stream");
error = -1; error = -1;
} }
...@@ -158,11 +158,11 @@ static int write_symlink( ...@@ -158,11 +158,11 @@ static int write_symlink(
int error; int error;
link_data = git__malloc(link_size); link_data = git__malloc(link_size);
GITERR_CHECK_ALLOC(link_data); GIT_ERROR_CHECK_ALLOC(link_data);
read_len = p_readlink(path, link_data, link_size); read_len = p_readlink(path, link_data, link_size);
if (read_len != (ssize_t)link_size) { if (read_len != (ssize_t)link_size) {
giterr_set(GITERR_OS, "failed to create blob: cannot read symlink '%s'", path); git_error_set(GIT_ERROR_OS, "failed to create blob: cannot read symlink '%s'", path);
git__free(link_data); git__free(link_data);
return -1; return -1;
} }
...@@ -206,7 +206,7 @@ int git_blob__create_from_paths( ...@@ -206,7 +206,7 @@ int git_blob__create_from_paths(
goto done; goto done;
if (S_ISDIR(st.st_mode)) { if (S_ISDIR(st.st_mode)) {
giterr_set(GITERR_ODB, "cannot create blob from '%s': it is a directory", content_path); git_error_set(GIT_ERROR_ODB, "cannot create blob from '%s': it is a directory", content_path);
error = GIT_EDIRECTORY; error = GIT_EDIRECTORY;
goto done; goto done;
} }
...@@ -334,11 +334,11 @@ int git_blob_create_fromstream(git_writestream **out, git_repository *repo, cons ...@@ -334,11 +334,11 @@ int git_blob_create_fromstream(git_writestream **out, git_repository *repo, cons
assert(out && repo); assert(out && repo);
stream = git__calloc(1, sizeof(blob_writestream)); stream = git__calloc(1, sizeof(blob_writestream));
GITERR_CHECK_ALLOC(stream); GIT_ERROR_CHECK_ALLOC(stream);
if (hintpath) { if (hintpath) {
stream->hintpath = git__strdup(hintpath); stream->hintpath = git__strdup(hintpath);
GITERR_CHECK_ALLOC(stream->hintpath); GIT_ERROR_CHECK_ALLOC(stream->hintpath);
} }
stream->repo = repo; stream->repo = repo;
......
...@@ -34,8 +34,8 @@ static int retrieve_branch_reference( ...@@ -34,8 +34,8 @@ static int retrieve_branch_reference(
if ((error = git_buf_joinpath(&ref_name, prefix, branch_name)) < 0) if ((error = git_buf_joinpath(&ref_name, prefix, branch_name)) < 0)
/* OOM */; /* OOM */;
else if ((error = git_reference_lookup(&branch, repo, ref_name.ptr)) < 0) else if ((error = git_reference_lookup(&branch, repo, ref_name.ptr)) < 0)
giterr_set( git_error_set(
GITERR_REFERENCE, "cannot locate %s branch '%s'", GIT_ERROR_REFERENCE, "cannot locate %s branch '%s'",
is_remote ? "remote-tracking" : "local", branch_name); is_remote ? "remote-tracking" : "local", branch_name);
*branch_reference_out = branch; /* will be NULL on error */ *branch_reference_out = branch; /* will be NULL on error */
...@@ -46,8 +46,8 @@ static int retrieve_branch_reference( ...@@ -46,8 +46,8 @@ static int retrieve_branch_reference(
static int not_a_local_branch(const char *reference_name) static int not_a_local_branch(const char *reference_name)
{ {
giterr_set( git_error_set(
GITERR_INVALID, GIT_ERROR_INVALID,
"reference '%s' is not a local branch.", reference_name); "reference '%s' is not a local branch.", reference_name);
return -1; return -1;
} }
...@@ -71,7 +71,7 @@ static int create_branch( ...@@ -71,7 +71,7 @@ static int create_branch(
assert(git_object_owner((const git_object *)commit) == repository); assert(git_object_owner((const git_object *)commit) == repository);
if (!git__strcmp(branch_name, "HEAD")) { if (!git__strcmp(branch_name, "HEAD")) {
giterr_set(GITERR_REFERENCE, "'HEAD' is not a valid branch name"); git_error_set(GIT_ERROR_REFERENCE, "'HEAD' is not a valid branch name");
error = -1; error = -1;
goto cleanup; goto cleanup;
} }
...@@ -88,7 +88,7 @@ static int create_branch( ...@@ -88,7 +88,7 @@ static int create_branch(
} }
if (is_unmovable_head && force) { if (is_unmovable_head && force) {
giterr_set(GITERR_REFERENCE, "cannot force update branch '%s' as it is " git_error_set(GIT_ERROR_REFERENCE, "cannot force update branch '%s' as it is "
"the current HEAD of the repository.", branch_name); "the current HEAD of the repository.", branch_name);
error = -1; error = -1;
goto cleanup; goto cleanup;
...@@ -168,7 +168,7 @@ int git_branch_delete(git_reference *branch) ...@@ -168,7 +168,7 @@ int git_branch_delete(git_reference *branch)
assert(branch); assert(branch);
if (!git_reference_is_branch(branch) && !git_reference_is_remote(branch)) { if (!git_reference_is_branch(branch) && !git_reference_is_remote(branch)) {
giterr_set(GITERR_INVALID, "reference '%s' is not a valid branch.", git_error_set(GIT_ERROR_INVALID, "reference '%s' is not a valid branch.",
git_reference_name(branch)); git_reference_name(branch));
return GIT_ENOTFOUND; return GIT_ENOTFOUND;
} }
...@@ -177,13 +177,13 @@ int git_branch_delete(git_reference *branch) ...@@ -177,13 +177,13 @@ int git_branch_delete(git_reference *branch)
return is_head; return is_head;
if (is_head) { if (is_head) {
giterr_set(GITERR_REFERENCE, "cannot delete branch '%s' as it is " git_error_set(GIT_ERROR_REFERENCE, "cannot delete branch '%s' as it is "
"the current HEAD of the repository.", git_reference_name(branch)); "the current HEAD of the repository.", git_reference_name(branch));
return -1; return -1;
} }
if (git_reference_is_branch(branch) && git_branch_is_checked_out(branch)) { if (git_reference_is_branch(branch) && git_branch_is_checked_out(branch)) {
giterr_set(GITERR_REFERENCE, "Cannot delete branch '%s' as it is " git_error_set(GIT_ERROR_REFERENCE, "Cannot delete branch '%s' as it is "
"the current HEAD of a linked repository.", git_reference_name(branch)); "the current HEAD of a linked repository.", git_reference_name(branch));
return -1; return -1;
} }
...@@ -243,7 +243,7 @@ int git_branch_iterator_new( ...@@ -243,7 +243,7 @@ int git_branch_iterator_new(
branch_iter *iter; branch_iter *iter;
iter = git__calloc(1, sizeof(branch_iter)); iter = git__calloc(1, sizeof(branch_iter));
GITERR_CHECK_ALLOC(iter); GIT_ERROR_CHECK_ALLOC(iter);
iter->flags = list_flags; iter->flags = list_flags;
...@@ -344,7 +344,7 @@ int git_branch_name( ...@@ -344,7 +344,7 @@ int git_branch_name(
} else if (git_reference_is_remote(ref)) { } else if (git_reference_is_remote(ref)) {
branch_name += strlen(GIT_REFS_REMOTES_DIR); branch_name += strlen(GIT_REFS_REMOTES_DIR);
} else { } else {
giterr_set(GITERR_INVALID, git_error_set(GIT_ERROR_INVALID,
"reference '%s' is neither a local nor a remote branch.", ref->name); "reference '%s' is neither a local nor a remote branch.", ref->name);
return -1; return -1;
} }
...@@ -402,7 +402,7 @@ int git_branch_upstream_name( ...@@ -402,7 +402,7 @@ int git_branch_upstream_name(
goto cleanup; goto cleanup;
if (git_buf_len(&remote_name) == 0 || git_buf_len(&merge_name) == 0) { if (git_buf_len(&remote_name) == 0 || git_buf_len(&merge_name) == 0) {
giterr_set(GITERR_REFERENCE, git_error_set(GIT_ERROR_REFERENCE,
"branch '%s' does not have an upstream", refname); "branch '%s' does not have an upstream", refname);
error = GIT_ENOTFOUND; error = GIT_ENOTFOUND;
goto cleanup; goto cleanup;
...@@ -452,7 +452,7 @@ int git_branch_upstream_remote(git_buf *buf, git_repository *repo, const char *r ...@@ -452,7 +452,7 @@ int git_branch_upstream_remote(git_buf *buf, git_repository *repo, const char *r
return error; return error;
if (git_buf_len(buf) == 0) { if (git_buf_len(buf) == 0) {
giterr_set(GITERR_REFERENCE, "branch '%s' does not have an upstream remote", refname); git_error_set(GIT_ERROR_REFERENCE, "branch '%s' does not have an upstream remote", refname);
error = GIT_ENOTFOUND; error = GIT_ENOTFOUND;
git_buf_clear(buf); git_buf_clear(buf);
} }
...@@ -475,7 +475,7 @@ int git_branch_remote_name(git_buf *buf, git_repository *repo, const char *refna ...@@ -475,7 +475,7 @@ int git_branch_remote_name(git_buf *buf, git_repository *repo, const char *refna
/* Verify that this is a remote branch */ /* Verify that this is a remote branch */
if (!git_reference__is_remote(refname)) { if (!git_reference__is_remote(refname)) {
giterr_set(GITERR_INVALID, "reference '%s' is not a remote branch.", git_error_set(GIT_ERROR_INVALID, "reference '%s' is not a remote branch.",
refname); refname);
error = GIT_ERROR; error = GIT_ERROR;
goto cleanup; goto cleanup;
...@@ -501,7 +501,7 @@ int git_branch_remote_name(git_buf *buf, git_repository *repo, const char *refna ...@@ -501,7 +501,7 @@ int git_branch_remote_name(git_buf *buf, git_repository *repo, const char *refna
} else { } else {
git_remote_free(remote); git_remote_free(remote);
giterr_set(GITERR_REFERENCE, git_error_set(GIT_ERROR_REFERENCE,
"reference '%s' is ambiguous", refname); "reference '%s' is ambiguous", refname);
error = GIT_EAMBIGUOUS; error = GIT_EAMBIGUOUS;
goto cleanup; goto cleanup;
...@@ -515,7 +515,7 @@ int git_branch_remote_name(git_buf *buf, git_repository *repo, const char *refna ...@@ -515,7 +515,7 @@ int git_branch_remote_name(git_buf *buf, git_repository *repo, const char *refna
git_buf_clear(buf); git_buf_clear(buf);
error = git_buf_puts(buf, remote_name); error = git_buf_puts(buf, remote_name);
} else { } else {
giterr_set(GITERR_REFERENCE, git_error_set(GIT_ERROR_REFERENCE,
"could not determine remote for '%s'", refname); "could not determine remote for '%s'", refname);
error = GIT_ENOTFOUND; error = GIT_ENOTFOUND;
} }
...@@ -604,7 +604,7 @@ int git_branch_set_upstream(git_reference *branch, const char *upstream_name) ...@@ -604,7 +604,7 @@ int git_branch_set_upstream(git_reference *branch, const char *upstream_name)
else if (git_branch_lookup(&upstream, repo, upstream_name, GIT_BRANCH_REMOTE) == 0) else if (git_branch_lookup(&upstream, repo, upstream_name, GIT_BRANCH_REMOTE) == 0)
local = 0; local = 0;
else { else {
giterr_set(GITERR_REFERENCE, git_error_set(GIT_ERROR_REFERENCE,
"cannot set upstream for branch '%s'", shortname); "cannot set upstream for branch '%s'", shortname);
return GIT_ENOTFOUND; return GIT_ENOTFOUND;
} }
......
...@@ -29,7 +29,7 @@ int git_buf_text_puts_escaped( ...@@ -29,7 +29,7 @@ int git_buf_text_puts_escaped(
scan += count; scan += count;
} }
GITERR_CHECK_ALLOC_ADD(&alloclen, total, 1); GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, total, 1);
if (git_buf_grow_by(buf, alloclen) < 0) if (git_buf_grow_by(buf, alloclen) < 0)
return -1; return -1;
...@@ -75,7 +75,7 @@ int git_buf_text_crlf_to_lf(git_buf *tgt, const git_buf *src) ...@@ -75,7 +75,7 @@ int git_buf_text_crlf_to_lf(git_buf *tgt, const git_buf *src)
return git_buf_set(tgt, src->ptr, src->size); return git_buf_set(tgt, src->ptr, src->size);
/* reduce reallocs while in the loop */ /* reduce reallocs while in the loop */
GITERR_CHECK_ALLOC_ADD(&new_size, src->size, 1); GIT_ERROR_CHECK_ALLOC_ADD(&new_size, src->size, 1);
if (git_buf_grow(tgt, new_size) < 0) if (git_buf_grow(tgt, new_size) < 0)
return -1; return -1;
...@@ -122,8 +122,8 @@ int git_buf_text_lf_to_crlf(git_buf *tgt, const git_buf *src) ...@@ -122,8 +122,8 @@ int git_buf_text_lf_to_crlf(git_buf *tgt, const git_buf *src)
return git_buf_set(tgt, src->ptr, src->size); return git_buf_set(tgt, src->ptr, src->size);
/* attempt to reduce reallocs while in the loop */ /* attempt to reduce reallocs while in the loop */
GITERR_CHECK_ALLOC_ADD(&alloclen, src->size, src->size >> 4); GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, src->size, src->size >> 4);
GITERR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1); GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1);
if (git_buf_grow(tgt, alloclen) < 0) if (git_buf_grow(tgt, alloclen) < 0)
return -1; return -1;
tgt->size = 0; tgt->size = 0;
...@@ -135,7 +135,7 @@ int git_buf_text_lf_to_crlf(git_buf *tgt, const git_buf *src) ...@@ -135,7 +135,7 @@ int git_buf_text_lf_to_crlf(git_buf *tgt, const git_buf *src)
if (copylen && next[-1] == '\r') if (copylen && next[-1] == '\r')
copylen--; copylen--;
GITERR_CHECK_ALLOC_ADD(&alloclen, copylen, 3); GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, copylen, 3);
if (git_buf_grow_by(tgt, alloclen) < 0) if (git_buf_grow_by(tgt, alloclen) < 0)
return -1; return -1;
......
...@@ -43,7 +43,7 @@ int git_buf_try_grow( ...@@ -43,7 +43,7 @@ int git_buf_try_grow(
return -1; return -1;
if (buf->asize == 0 && buf->size != 0) { if (buf->asize == 0 && buf->size != 0) {
giterr_set(GITERR_INVALID, "cannot grow a borrowed buffer"); git_error_set(GIT_ERROR_INVALID, "cannot grow a borrowed buffer");
return GIT_EINVALID; return GIT_EINVALID;
} }
...@@ -73,7 +73,7 @@ int git_buf_try_grow( ...@@ -73,7 +73,7 @@ int git_buf_try_grow(
if (mark_oom) if (mark_oom)
buf->ptr = git_buf__oom; buf->ptr = git_buf__oom;
giterr_set_oom(); git_error_set_oom();
return -1; return -1;
} }
...@@ -161,7 +161,7 @@ int git_buf_set(git_buf *buf, const void *data, size_t len) ...@@ -161,7 +161,7 @@ int git_buf_set(git_buf *buf, const void *data, size_t len)
git_buf_clear(buf); git_buf_clear(buf);
} else { } else {
if (data != buf->ptr) { if (data != buf->ptr) {
GITERR_CHECK_ALLOC_ADD(&alloclen, len, 1); GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, len, 1);
ENSURE_SIZE(buf, alloclen); ENSURE_SIZE(buf, alloclen);
memmove(buf->ptr, data, len); memmove(buf->ptr, data, len);
} }
...@@ -192,7 +192,7 @@ int git_buf_sets(git_buf *buf, const char *string) ...@@ -192,7 +192,7 @@ int git_buf_sets(git_buf *buf, const char *string)
int git_buf_putc(git_buf *buf, char c) int git_buf_putc(git_buf *buf, char c)
{ {
size_t new_size; size_t new_size;
GITERR_CHECK_ALLOC_ADD(&new_size, buf->size, 2); GIT_ERROR_CHECK_ALLOC_ADD(&new_size, buf->size, 2);
ENSURE_SIZE(buf, new_size); ENSURE_SIZE(buf, new_size);
buf->ptr[buf->size++] = c; buf->ptr[buf->size++] = c;
buf->ptr[buf->size] = '\0'; buf->ptr[buf->size] = '\0';
...@@ -202,8 +202,8 @@ int git_buf_putc(git_buf *buf, char c) ...@@ -202,8 +202,8 @@ int git_buf_putc(git_buf *buf, char c)
int git_buf_putcn(git_buf *buf, char c, size_t len) int git_buf_putcn(git_buf *buf, char c, size_t len)
{ {
size_t new_size; size_t new_size;
GITERR_CHECK_ALLOC_ADD(&new_size, buf->size, len); GIT_ERROR_CHECK_ALLOC_ADD(&new_size, buf->size, len);
GITERR_CHECK_ALLOC_ADD(&new_size, new_size, 1); GIT_ERROR_CHECK_ALLOC_ADD(&new_size, new_size, 1);
ENSURE_SIZE(buf, new_size); ENSURE_SIZE(buf, new_size);
memset(buf->ptr + buf->size, c, len); memset(buf->ptr + buf->size, c, len);
buf->size += len; buf->size += len;
...@@ -218,8 +218,8 @@ int git_buf_put(git_buf *buf, const char *data, size_t len) ...@@ -218,8 +218,8 @@ int git_buf_put(git_buf *buf, const char *data, size_t len)
assert(data); assert(data);
GITERR_CHECK_ALLOC_ADD(&new_size, buf->size, len); GIT_ERROR_CHECK_ALLOC_ADD(&new_size, buf->size, len);
GITERR_CHECK_ALLOC_ADD(&new_size, new_size, 1); GIT_ERROR_CHECK_ALLOC_ADD(&new_size, new_size, 1);
ENSURE_SIZE(buf, new_size); ENSURE_SIZE(buf, new_size);
memmove(buf->ptr + buf->size, data, len); memmove(buf->ptr + buf->size, data, len);
buf->size += len; buf->size += len;
...@@ -244,9 +244,9 @@ int git_buf_encode_base64(git_buf *buf, const char *data, size_t len) ...@@ -244,9 +244,9 @@ int git_buf_encode_base64(git_buf *buf, const char *data, size_t len)
const uint8_t *read = (const uint8_t *)data; const uint8_t *read = (const uint8_t *)data;
size_t blocks = (len / 3) + !!extra, alloclen; size_t blocks = (len / 3) + !!extra, alloclen;
GITERR_CHECK_ALLOC_ADD(&blocks, blocks, 1); GIT_ERROR_CHECK_ALLOC_ADD(&blocks, blocks, 1);
GITERR_CHECK_ALLOC_MULTIPLY(&alloclen, blocks, 4); GIT_ERROR_CHECK_ALLOC_MULTIPLY(&alloclen, blocks, 4);
GITERR_CHECK_ALLOC_ADD(&alloclen, alloclen, buf->size); GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, alloclen, buf->size);
ENSURE_SIZE(buf, alloclen); ENSURE_SIZE(buf, alloclen);
write = (uint8_t *)&buf->ptr[buf->size]; write = (uint8_t *)&buf->ptr[buf->size];
...@@ -306,13 +306,13 @@ int git_buf_decode_base64(git_buf *buf, const char *base64, size_t len) ...@@ -306,13 +306,13 @@ int git_buf_decode_base64(git_buf *buf, const char *base64, size_t len)
size_t orig_size = buf->size, new_size; size_t orig_size = buf->size, new_size;
if (len % 4) { if (len % 4) {
giterr_set(GITERR_INVALID, "invalid base64 input"); git_error_set(GIT_ERROR_INVALID, "invalid base64 input");
return -1; return -1;
} }
assert(len % 4 == 0); assert(len % 4 == 0);
GITERR_CHECK_ALLOC_ADD(&new_size, (len / 4 * 3), buf->size); GIT_ERROR_CHECK_ALLOC_ADD(&new_size, (len / 4 * 3), buf->size);
GITERR_CHECK_ALLOC_ADD(&new_size, new_size, 1); GIT_ERROR_CHECK_ALLOC_ADD(&new_size, new_size, 1);
ENSURE_SIZE(buf, new_size); ENSURE_SIZE(buf, new_size);
for (i = 0; i < len; i += 4) { for (i = 0; i < len; i += 4) {
...@@ -323,7 +323,7 @@ int git_buf_decode_base64(git_buf *buf, const char *base64, size_t len) ...@@ -323,7 +323,7 @@ int git_buf_decode_base64(git_buf *buf, const char *base64, size_t len)
buf->size = orig_size; buf->size = orig_size;
buf->ptr[buf->size] = '\0'; buf->ptr[buf->size] = '\0';
giterr_set(GITERR_INVALID, "invalid base64 input"); git_error_set(GIT_ERROR_INVALID, "invalid base64 input");
return -1; return -1;
} }
...@@ -343,9 +343,9 @@ int git_buf_encode_base85(git_buf *buf, const char *data, size_t len) ...@@ -343,9 +343,9 @@ int git_buf_encode_base85(git_buf *buf, const char *data, size_t len)
{ {
size_t blocks = (len / 4) + !!(len % 4), alloclen; size_t blocks = (len / 4) + !!(len % 4), alloclen;
GITERR_CHECK_ALLOC_MULTIPLY(&alloclen, blocks, 5); GIT_ERROR_CHECK_ALLOC_MULTIPLY(&alloclen, blocks, 5);
GITERR_CHECK_ALLOC_ADD(&alloclen, alloclen, buf->size); GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, alloclen, buf->size);
GITERR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1); GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1);
ENSURE_SIZE(buf, alloclen); ENSURE_SIZE(buf, alloclen);
...@@ -408,12 +408,12 @@ int git_buf_decode_base85( ...@@ -408,12 +408,12 @@ int git_buf_decode_base85(
if (base85_len % 5 || if (base85_len % 5 ||
output_len > base85_len * 4 / 5) { output_len > base85_len * 4 / 5) {
giterr_set(GITERR_INVALID, "invalid base85 input"); git_error_set(GIT_ERROR_INVALID, "invalid base85 input");
return -1; return -1;
} }
GITERR_CHECK_ALLOC_ADD(&new_size, output_len, buf->size); GIT_ERROR_CHECK_ALLOC_ADD(&new_size, output_len, buf->size);
GITERR_CHECK_ALLOC_ADD(&new_size, new_size, 1); GIT_ERROR_CHECK_ALLOC_ADD(&new_size, new_size, 1);
ENSURE_SIZE(buf, new_size); ENSURE_SIZE(buf, new_size);
while (output_len) { while (output_len) {
...@@ -456,7 +456,7 @@ on_error: ...@@ -456,7 +456,7 @@ on_error:
buf->size = orig_size; buf->size = orig_size;
buf->ptr[buf->size] = '\0'; buf->ptr[buf->size] = '\0';
giterr_set(GITERR_INVALID, "invalid base85 input"); git_error_set(GIT_ERROR_INVALID, "invalid base85 input");
return -1; return -1;
} }
...@@ -469,8 +469,8 @@ int git_buf_decode_percent( ...@@ -469,8 +469,8 @@ int git_buf_decode_percent(
{ {
size_t str_pos, new_size; size_t str_pos, new_size;
GITERR_CHECK_ALLOC_ADD(&new_size, buf->size, str_len); GIT_ERROR_CHECK_ALLOC_ADD(&new_size, buf->size, str_len);
GITERR_CHECK_ALLOC_ADD(&new_size, new_size, 1); GIT_ERROR_CHECK_ALLOC_ADD(&new_size, new_size, 1);
ENSURE_SIZE(buf, new_size); ENSURE_SIZE(buf, new_size);
for (str_pos = 0; str_pos < str_len; buf->size++, str_pos++) { for (str_pos = 0; str_pos < str_len; buf->size++, str_pos++) {
...@@ -495,8 +495,8 @@ int git_buf_vprintf(git_buf *buf, const char *format, va_list ap) ...@@ -495,8 +495,8 @@ int git_buf_vprintf(git_buf *buf, const char *format, va_list ap)
size_t expected_size, new_size; size_t expected_size, new_size;
int len; int len;
GITERR_CHECK_ALLOC_MULTIPLY(&expected_size, strlen(format), 2); GIT_ERROR_CHECK_ALLOC_MULTIPLY(&expected_size, strlen(format), 2);
GITERR_CHECK_ALLOC_ADD(&expected_size, expected_size, buf->size); GIT_ERROR_CHECK_ALLOC_ADD(&expected_size, expected_size, buf->size);
ENSURE_SIZE(buf, expected_size); ENSURE_SIZE(buf, expected_size);
while (1) { while (1) {
...@@ -522,8 +522,8 @@ int git_buf_vprintf(git_buf *buf, const char *format, va_list ap) ...@@ -522,8 +522,8 @@ int git_buf_vprintf(git_buf *buf, const char *format, va_list ap)
break; break;
} }
GITERR_CHECK_ALLOC_ADD(&new_size, buf->size, len); GIT_ERROR_CHECK_ALLOC_ADD(&new_size, buf->size, len);
GITERR_CHECK_ALLOC_ADD(&new_size, new_size, 1); GIT_ERROR_CHECK_ALLOC_ADD(&new_size, new_size, 1);
ENSURE_SIZE(buf, new_size); ENSURE_SIZE(buf, new_size);
} }
...@@ -667,10 +667,10 @@ int git_buf_join_n(git_buf *buf, char separator, int nbuf, ...) ...@@ -667,10 +667,10 @@ int git_buf_join_n(git_buf *buf, char separator, int nbuf, ...)
segment_len = strlen(segment); segment_len = strlen(segment);
GITERR_CHECK_ALLOC_ADD(&total_size, total_size, segment_len); GIT_ERROR_CHECK_ALLOC_ADD(&total_size, total_size, segment_len);
if (segment_len == 0 || segment[segment_len - 1] != separator) if (segment_len == 0 || segment[segment_len - 1] != separator)
GITERR_CHECK_ALLOC_ADD(&total_size, total_size, 1); GIT_ERROR_CHECK_ALLOC_ADD(&total_size, total_size, 1);
} }
va_end(ap); va_end(ap);
...@@ -678,7 +678,7 @@ int git_buf_join_n(git_buf *buf, char separator, int nbuf, ...) ...@@ -678,7 +678,7 @@ int git_buf_join_n(git_buf *buf, char separator, int nbuf, ...)
if (total_size == 0) if (total_size == 0)
return 0; return 0;
GITERR_CHECK_ALLOC_ADD(&total_size, total_size, 1); GIT_ERROR_CHECK_ALLOC_ADD(&total_size, total_size, 1);
if (git_buf_grow_by(buf, total_size) < 0) if (git_buf_grow_by(buf, total_size) < 0)
return -1; return -1;
...@@ -758,9 +758,9 @@ int git_buf_join( ...@@ -758,9 +758,9 @@ int git_buf_join(
if (str_a >= buf->ptr && str_a < buf->ptr + buf->size) if (str_a >= buf->ptr && str_a < buf->ptr + buf->size)
offset_a = str_a - buf->ptr; offset_a = str_a - buf->ptr;
GITERR_CHECK_ALLOC_ADD(&alloc_len, strlen_a, strlen_b); GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, strlen_a, strlen_b);
GITERR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, need_sep); GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, need_sep);
GITERR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, 1); GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, 1);
ENSURE_SIZE(buf, alloc_len); ENSURE_SIZE(buf, alloc_len);
/* fix up internal pointers */ /* fix up internal pointers */
...@@ -810,11 +810,11 @@ int git_buf_join3( ...@@ -810,11 +810,11 @@ int git_buf_join3(
sep_b = (str_b[len_b - 1] != separator); sep_b = (str_b[len_b - 1] != separator);
} }
GITERR_CHECK_ALLOC_ADD(&len_total, len_a, sep_a); GIT_ERROR_CHECK_ALLOC_ADD(&len_total, len_a, sep_a);
GITERR_CHECK_ALLOC_ADD(&len_total, len_total, len_b); GIT_ERROR_CHECK_ALLOC_ADD(&len_total, len_total, len_b);
GITERR_CHECK_ALLOC_ADD(&len_total, len_total, sep_b); GIT_ERROR_CHECK_ALLOC_ADD(&len_total, len_total, sep_b);
GITERR_CHECK_ALLOC_ADD(&len_total, len_total, len_c); GIT_ERROR_CHECK_ALLOC_ADD(&len_total, len_total, len_c);
GITERR_CHECK_ALLOC_ADD(&len_total, len_total, 1); GIT_ERROR_CHECK_ALLOC_ADD(&len_total, len_total, 1);
ENSURE_SIZE(buf, len_total); ENSURE_SIZE(buf, len_total);
tgt = buf->ptr; tgt = buf->ptr;
...@@ -877,8 +877,8 @@ int git_buf_splice( ...@@ -877,8 +877,8 @@ int git_buf_splice(
/* Ported from git.git /* Ported from git.git
* https://github.com/git/git/blob/16eed7c/strbuf.c#L159-176 * https://github.com/git/git/blob/16eed7c/strbuf.c#L159-176
*/ */
GITERR_CHECK_ALLOC_ADD(&new_size, (buf->size - nb_to_remove), nb_to_insert); GIT_ERROR_CHECK_ALLOC_ADD(&new_size, (buf->size - nb_to_remove), nb_to_insert);
GITERR_CHECK_ALLOC_ADD(&alloc_size, new_size, 1); GIT_ERROR_CHECK_ALLOC_ADD(&alloc_size, new_size, 1);
ENSURE_SIZE(buf, alloc_size); ENSURE_SIZE(buf, alloc_size);
memmove(splice_loc + nb_to_insert, memmove(splice_loc + nb_to_insert,
...@@ -995,14 +995,14 @@ int git_buf_unquote(git_buf *buf) ...@@ -995,14 +995,14 @@ int git_buf_unquote(git_buf *buf)
/* \xyz digits convert to the char*/ /* \xyz digits convert to the char*/
case '0': case '1': case '2': case '3': case '0': case '1': case '2': case '3':
if (j == buf->size-3) { if (j == buf->size-3) {
giterr_set(GITERR_INVALID, git_error_set(GIT_ERROR_INVALID,
"truncated quoted character \\%c", ch); "truncated quoted character \\%c", ch);
return -1; return -1;
} }
if (buf->ptr[j+1] < '0' || buf->ptr[j+1] > '7' || if (buf->ptr[j+1] < '0' || buf->ptr[j+1] > '7' ||
buf->ptr[j+2] < '0' || buf->ptr[j+2] > '7') { buf->ptr[j+2] < '0' || buf->ptr[j+2] > '7') {
giterr_set(GITERR_INVALID, git_error_set(GIT_ERROR_INVALID,
"truncated quoted character \\%c%c%c", "truncated quoted character \\%c%c%c",
buf->ptr[j], buf->ptr[j+1], buf->ptr[j+2]); buf->ptr[j], buf->ptr[j+1], buf->ptr[j+2]);
return -1; return -1;
...@@ -1015,7 +1015,7 @@ int git_buf_unquote(git_buf *buf) ...@@ -1015,7 +1015,7 @@ int git_buf_unquote(git_buf *buf)
break; break;
default: default:
giterr_set(GITERR_INVALID, "invalid quoted character \\%c", ch); git_error_set(GIT_ERROR_INVALID, "invalid quoted character \\%c", ch);
return -1; return -1;
} }
} }
...@@ -1029,6 +1029,6 @@ int git_buf_unquote(git_buf *buf) ...@@ -1029,6 +1029,6 @@ int git_buf_unquote(git_buf *buf)
return 0; return 0;
invalid: invalid:
giterr_set(GITERR_INVALID, "invalid quoted line"); git_error_set(GIT_ERROR_INVALID, "invalid quoted line");
return -1; return -1;
} }
...@@ -33,7 +33,7 @@ static size_t git_cache__max_object_size[8] = { ...@@ -33,7 +33,7 @@ static size_t git_cache__max_object_size[8] = {
int git_cache_set_max_object_size(git_object_t type, size_t size) int git_cache_set_max_object_size(git_object_t type, size_t size)
{ {
if (type < 0 || (size_t)type >= ARRAY_SIZE(git_cache__max_object_size)) { if (type < 0 || (size_t)type >= ARRAY_SIZE(git_cache__max_object_size)) {
giterr_set(GITERR_INVALID, "type out of range"); git_error_set(GIT_ERROR_INVALID, "type out of range");
return -1; return -1;
} }
...@@ -66,9 +66,9 @@ int git_cache_init(git_cache *cache) ...@@ -66,9 +66,9 @@ int git_cache_init(git_cache *cache)
{ {
memset(cache, 0, sizeof(*cache)); memset(cache, 0, sizeof(*cache));
cache->map = git_oidmap_alloc(); cache->map = git_oidmap_alloc();
GITERR_CHECK_ALLOC(cache->map); GIT_ERROR_CHECK_ALLOC(cache->map);
if (git_rwlock_init(&cache->lock)) { if (git_rwlock_init(&cache->lock)) {
giterr_set(GITERR_OS, "failed to initialize cache rwlock"); git_error_set(GIT_ERROR_OS, "failed to initialize cache rwlock");
return -1; return -1;
} }
return 0; return 0;
......
...@@ -108,7 +108,7 @@ static int cherrypick_seterr(git_commit *commit, const char *fmt) ...@@ -108,7 +108,7 @@ static int cherrypick_seterr(git_commit *commit, const char *fmt)
{ {
char commit_oidstr[GIT_OID_HEXSZ + 1]; char commit_oidstr[GIT_OID_HEXSZ + 1];
giterr_set(GITERR_CHERRYPICK, fmt, git_error_set(GIT_ERROR_CHERRYPICK, fmt,
git_oid_tostr(commit_oidstr, GIT_OID_HEXSZ + 1, git_commit_id(commit))); git_oid_tostr(commit_oidstr, GIT_OID_HEXSZ + 1, git_commit_id(commit)));
return -1; return -1;
...@@ -179,7 +179,7 @@ int git_cherrypick( ...@@ -179,7 +179,7 @@ int git_cherrypick(
assert(repo && commit); assert(repo && commit);
GITERR_CHECK_VERSION(given_opts, GIT_CHERRYPICK_OPTIONS_VERSION, "git_cherrypick_options"); GIT_ERROR_CHECK_VERSION(given_opts, GIT_CHERRYPICK_OPTIONS_VERSION, "git_cherrypick_options");
if ((error = git_repository__ensure_not_bare(repo, "cherry-pick")) < 0) if ((error = git_repository__ensure_not_bare(repo, "cherry-pick")) < 0)
return error; return error;
......
...@@ -176,7 +176,7 @@ static int update_head_to_remote( ...@@ -176,7 +176,7 @@ static int update_head_to_remote(
refspec = git_remote__matching_refspec(remote, git_buf_cstr(&branch)); refspec = git_remote__matching_refspec(remote, git_buf_cstr(&branch));
if (refspec == NULL) { if (refspec == NULL) {
giterr_set(GITERR_NET, "the remote's default branch does not fit the refspec configuration"); git_error_set(GIT_ERROR_NET, "the remote's default branch does not fit the refspec configuration");
error = GIT_EINVALIDSPEC; error = GIT_EINVALIDSPEC;
goto cleanup; goto cleanup;
} }
...@@ -332,7 +332,7 @@ static int clone_into(git_repository *repo, git_remote *_remote, const git_fetch ...@@ -332,7 +332,7 @@ static int clone_into(git_repository *repo, git_remote *_remote, const git_fetch
assert(repo && _remote); assert(repo && _remote);
if (!git_repository_is_empty(repo)) { if (!git_repository_is_empty(repo)) {
giterr_set(GITERR_INVALID, "the repository is not empty"); git_error_set(GIT_ERROR_INVALID, "the repository is not empty");
return -1; return -1;
} }
...@@ -400,11 +400,11 @@ int git_clone( ...@@ -400,11 +400,11 @@ int git_clone(
if (_options) if (_options)
memcpy(&options, _options, sizeof(git_clone_options)); memcpy(&options, _options, sizeof(git_clone_options));
GITERR_CHECK_VERSION(&options, GIT_CLONE_OPTIONS_VERSION, "git_clone_options"); GIT_ERROR_CHECK_VERSION(&options, GIT_CLONE_OPTIONS_VERSION, "git_clone_options");
/* Only clone to a new directory or an empty directory */ /* Only clone to a new directory or an empty directory */
if (git_path_exists(local_path) && !git_path_is_empty_dir(local_path)) { if (git_path_exists(local_path) && !git_path_is_empty_dir(local_path)) {
giterr_set(GITERR_INVALID, git_error_set(GIT_ERROR_INVALID,
"'%s' exists and is not an empty directory", local_path); "'%s' exists and is not an empty directory", local_path);
return GIT_EEXISTS; return GIT_EEXISTS;
} }
...@@ -441,14 +441,14 @@ int git_clone( ...@@ -441,14 +441,14 @@ int git_clone(
if (error != 0) { if (error != 0) {
git_error_state last_error = {0}; git_error_state last_error = {0};
giterr_state_capture(&last_error, error); git_error_state_capture(&last_error, error);
git_repository_free(repo); git_repository_free(repo);
repo = NULL; repo = NULL;
(void)git_futils_rmdir_r(local_path, NULL, rmdir_flags); (void)git_futils_rmdir_r(local_path, NULL, rmdir_flags);
giterr_state_restore(&last_error); git_error_state_restore(&last_error);
} }
*out = repo; *out = repo;
...@@ -496,7 +496,7 @@ static int clone_local_into(git_repository *repo, git_remote *remote, const git_ ...@@ -496,7 +496,7 @@ static int clone_local_into(git_repository *repo, git_remote *remote, const git_
assert(repo && remote); assert(repo && remote);
if (!git_repository_is_empty(repo)) { if (!git_repository_is_empty(repo)) {
giterr_set(GITERR_INVALID, "the repository is not empty"); git_error_set(GIT_ERROR_INVALID, "the repository is not empty");
return -1; return -1;
} }
......
...@@ -99,14 +99,14 @@ static int validate_tree_and_parents(git_array_oid_t *parents, git_repository *r ...@@ -99,14 +99,14 @@ static int validate_tree_and_parents(git_array_oid_t *parents, git_repository *r
} }
parent_cpy = git_array_alloc(*parents); parent_cpy = git_array_alloc(*parents);
GITERR_CHECK_ALLOC(parent_cpy); GIT_ERROR_CHECK_ALLOC(parent_cpy);
git_oid_cpy(parent_cpy, parent); git_oid_cpy(parent_cpy, parent);
i++; i++;
} }
if (current_id && (parents->size == 0 || git_oid_cmp(current_id, git_array_get(*parents, 0)))) { if (current_id && (parents->size == 0 || git_oid_cmp(current_id, git_array_get(*parents, 0)))) {
giterr_set(GITERR_OBJECT, "failed to create commit: current tip is not the first parent"); git_error_set(GIT_ERROR_OBJECT, "failed to create commit: current tip is not the first parent");
error = GIT_EMODIFIED; error = GIT_EMODIFIED;
goto on_error; goto on_error;
} }
...@@ -143,7 +143,7 @@ static int git_commit__create_internal( ...@@ -143,7 +143,7 @@ static int git_commit__create_internal(
if (error < 0 && error != GIT_ENOTFOUND) if (error < 0 && error != GIT_ENOTFOUND)
return error; return error;
} }
giterr_clear(); git_error_clear();
if (ref) if (ref)
current_id = git_reference_target(ref); current_id = git_reference_target(ref);
...@@ -351,7 +351,7 @@ int git_commit_amend( ...@@ -351,7 +351,7 @@ int git_commit_amend(
if (!tree) { if (!tree) {
git_tree *old_tree; git_tree *old_tree;
GITERR_CHECK_ERROR( git_commit_tree(&old_tree, commit_to_amend) ); GIT_ERROR_CHECK_ERROR( git_commit_tree(&old_tree, commit_to_amend) );
git_oid_cpy(&tree_id, git_tree_id(old_tree)); git_oid_cpy(&tree_id, git_tree_id(old_tree));
git_tree_free(old_tree); git_tree_free(old_tree);
} else { } else {
...@@ -365,7 +365,7 @@ int git_commit_amend( ...@@ -365,7 +365,7 @@ int git_commit_amend(
if (git_oid_cmp(git_commit_id(commit_to_amend), git_reference_target(ref))) { if (git_oid_cmp(git_commit_id(commit_to_amend), git_reference_target(ref))) {
git_reference_free(ref); git_reference_free(ref);
giterr_set(GITERR_REFERENCE, "commit to amend is not the tip of the given branch"); git_error_set(GIT_ERROR_REFERENCE, "commit to amend is not the tip of the given branch");
return -1; return -1;
} }
} }
...@@ -396,7 +396,7 @@ int git_commit__parse_raw(void *_commit, const char *data, size_t size) ...@@ -396,7 +396,7 @@ int git_commit__parse_raw(void *_commit, const char *data, size_t size)
/* Allocate for one, which will allow not to realloc 90% of the time */ /* Allocate for one, which will allow not to realloc 90% of the time */
git_array_init_to_size(commit->parent_ids, 1); git_array_init_to_size(commit->parent_ids, 1);
GITERR_CHECK_ARRAY(commit->parent_ids); GIT_ERROR_CHECK_ARRAY(commit->parent_ids);
/* The tree is always the first field */ /* The tree is always the first field */
if (git_oid__parse(&commit->tree_id, &buffer, buffer_end, "tree ") < 0) if (git_oid__parse(&commit->tree_id, &buffer, buffer_end, "tree ") < 0)
...@@ -408,13 +408,13 @@ int git_commit__parse_raw(void *_commit, const char *data, size_t size) ...@@ -408,13 +408,13 @@ int git_commit__parse_raw(void *_commit, const char *data, size_t size)
while (git_oid__parse(&parent_id, &buffer, buffer_end, "parent ") == 0) { while (git_oid__parse(&parent_id, &buffer, buffer_end, "parent ") == 0) {
git_oid *new_id = git_array_alloc(commit->parent_ids); git_oid *new_id = git_array_alloc(commit->parent_ids);
GITERR_CHECK_ALLOC(new_id); GIT_ERROR_CHECK_ALLOC(new_id);
git_oid_cpy(new_id, &parent_id); git_oid_cpy(new_id, &parent_id);
} }
commit->author = git__malloc(sizeof(git_signature)); commit->author = git__malloc(sizeof(git_signature));
GITERR_CHECK_ALLOC(commit->author); GIT_ERROR_CHECK_ALLOC(commit->author);
if (git_signature__parse(commit->author, &buffer, buffer_end, "author ", '\n') < 0) if (git_signature__parse(commit->author, &buffer, buffer_end, "author ", '\n') < 0)
return -1; return -1;
...@@ -430,7 +430,7 @@ int git_commit__parse_raw(void *_commit, const char *data, size_t size) ...@@ -430,7 +430,7 @@ int git_commit__parse_raw(void *_commit, const char *data, size_t size)
/* Always parse the committer; we need the commit time */ /* Always parse the committer; we need the commit time */
commit->committer = git__malloc(sizeof(git_signature)); commit->committer = git__malloc(sizeof(git_signature));
GITERR_CHECK_ALLOC(commit->committer); GIT_ERROR_CHECK_ALLOC(commit->committer);
if (git_signature__parse(commit->committer, &buffer, buffer_end, "committer ", '\n') < 0) if (git_signature__parse(commit->committer, &buffer, buffer_end, "committer ", '\n') < 0)
return -1; return -1;
...@@ -448,7 +448,7 @@ int git_commit__parse_raw(void *_commit, const char *data, size_t size) ...@@ -448,7 +448,7 @@ int git_commit__parse_raw(void *_commit, const char *data, size_t size)
buffer += strlen("encoding "); buffer += strlen("encoding ");
commit->message_encoding = git__strndup(buffer, eoln - buffer); commit->message_encoding = git__strndup(buffer, eoln - buffer);
GITERR_CHECK_ALLOC(commit->message_encoding); GIT_ERROR_CHECK_ALLOC(commit->message_encoding);
} }
if (eoln < buffer_end && *eoln == '\n') if (eoln < buffer_end && *eoln == '\n')
...@@ -458,7 +458,7 @@ int git_commit__parse_raw(void *_commit, const char *data, size_t size) ...@@ -458,7 +458,7 @@ int git_commit__parse_raw(void *_commit, const char *data, size_t size)
header_len = buffer - buffer_start; header_len = buffer - buffer_start;
commit->raw_header = git__strndup(buffer_start, header_len); commit->raw_header = git__strndup(buffer_start, header_len);
GITERR_CHECK_ALLOC(commit->raw_header); GIT_ERROR_CHECK_ALLOC(commit->raw_header);
/* point "buffer" to data after header, +1 for the final LF */ /* point "buffer" to data after header, +1 for the final LF */
buffer = buffer_start + header_len + 1; buffer = buffer_start + header_len + 1;
...@@ -468,12 +468,12 @@ int git_commit__parse_raw(void *_commit, const char *data, size_t size) ...@@ -468,12 +468,12 @@ int git_commit__parse_raw(void *_commit, const char *data, size_t size)
commit->raw_message = git__strndup(buffer, buffer_end - buffer); commit->raw_message = git__strndup(buffer, buffer_end - buffer);
else else
commit->raw_message = git__strdup(""); commit->raw_message = git__strdup("");
GITERR_CHECK_ALLOC(commit->raw_message); GIT_ERROR_CHECK_ALLOC(commit->raw_message);
return 0; return 0;
bad_buffer: bad_buffer:
giterr_set(GITERR_OBJECT, "failed to parse bad commit object"); git_error_set(GIT_ERROR_OBJECT, "failed to parse bad commit object");
return -1; return -1;
} }
...@@ -610,7 +610,7 @@ int git_commit_parent( ...@@ -610,7 +610,7 @@ int git_commit_parent(
parent_id = git_commit_parent_id(commit, n); parent_id = git_commit_parent_id(commit, n);
if (parent_id == NULL) { if (parent_id == NULL) {
giterr_set(GITERR_INVALID, "parent %u does not exist", n); git_error_set(GIT_ERROR_INVALID, "parent %u does not exist", n);
return GIT_ENOTFOUND; return GIT_ENOTFOUND;
} }
...@@ -699,14 +699,14 @@ int git_commit_header_field(git_buf *out, const git_commit *commit, const char * ...@@ -699,14 +699,14 @@ int git_commit_header_field(git_buf *out, const git_commit *commit, const char *
return 0; return 0;
} }
giterr_set(GITERR_OBJECT, "no such field '%s'", field); git_error_set(GIT_ERROR_OBJECT, "no such field '%s'", field);
return GIT_ENOTFOUND; return GIT_ENOTFOUND;
malformed: malformed:
giterr_set(GITERR_OBJECT, "malformed header"); git_error_set(GIT_ERROR_OBJECT, "malformed header");
return -1; return -1;
oom: oom:
giterr_set_oom(); git_error_set_oom();
return -1; return -1;
} }
...@@ -731,7 +731,7 @@ int git_commit_extract_signature(git_buf *signature, git_buf *signed_data, git_r ...@@ -731,7 +731,7 @@ int git_commit_extract_signature(git_buf *signature, git_buf *signed_data, git_r
return error; return error;
if (obj->cached.type != GIT_OBJECT_COMMIT) { if (obj->cached.type != GIT_OBJECT_COMMIT) {
giterr_set(GITERR_INVALID, "the requested type does not match the type in ODB"); git_error_set(GIT_ERROR_INVALID, "the requested type does not match the type in ODB");
error = GIT_ENOTFOUND; error = GIT_ENOTFOUND;
goto cleanup; goto cleanup;
} }
...@@ -783,16 +783,16 @@ int git_commit_extract_signature(git_buf *signature, git_buf *signed_data, git_r ...@@ -783,16 +783,16 @@ int git_commit_extract_signature(git_buf *signature, git_buf *signed_data, git_r
return error; return error;
} }
giterr_set(GITERR_OBJECT, "this commit is not signed"); git_error_set(GIT_ERROR_OBJECT, "this commit is not signed");
error = GIT_ENOTFOUND; error = GIT_ENOTFOUND;
goto cleanup; goto cleanup;
malformed: malformed:
giterr_set(GITERR_OBJECT, "malformed header"); git_error_set(GIT_ERROR_OBJECT, "malformed header");
error = -1; error = -1;
goto cleanup; goto cleanup;
oom: oom:
giterr_set_oom(); git_error_set_oom();
error = -1; error = -1;
goto cleanup; goto cleanup;
...@@ -872,7 +872,7 @@ int git_commit_create_with_signature( ...@@ -872,7 +872,7 @@ int git_commit_create_with_signature(
/* We start by identifying the end of the commit header */ /* We start by identifying the end of the commit header */
header_end = strstr(commit_content, "\n\n"); header_end = strstr(commit_content, "\n\n");
if (!header_end) { if (!header_end) {
giterr_set(GITERR_INVALID, "malformed commit contents"); git_error_set(GIT_ERROR_INVALID, "malformed commit contents");
return -1; return -1;
} }
......
...@@ -61,7 +61,7 @@ static int commit_error(git_commit_list_node *commit, const char *msg) ...@@ -61,7 +61,7 @@ static int commit_error(git_commit_list_node *commit, const char *msg)
git_oid_fmt(commit_oid, &commit->oid); git_oid_fmt(commit_oid, &commit->oid);
commit_oid[GIT_OID_HEXSZ] = '\0'; commit_oid[GIT_OID_HEXSZ] = '\0';
giterr_set(GITERR_ODB, "failed to parse commit %s - %s", commit_oid, msg); git_error_set(GIT_ERROR_ODB, "failed to parse commit %s - %s", commit_oid, msg);
return -1; return -1;
} }
...@@ -126,7 +126,7 @@ static int commit_quick_parse( ...@@ -126,7 +126,7 @@ static int commit_quick_parse(
} }
commit->parents = alloc_parents(walk, commit, parents); commit->parents = alloc_parents(walk, commit, parents);
GITERR_CHECK_ALLOC(commit->parents); GIT_ERROR_CHECK_ALLOC(commit->parents);
buffer = parents_start; buffer = parents_start;
for (i = 0; i < parents; ++i) { for (i = 0; i < parents; ++i) {
...@@ -193,7 +193,7 @@ int git_commit_list_parse(git_revwalk *walk, git_commit_list_node *commit) ...@@ -193,7 +193,7 @@ int git_commit_list_parse(git_revwalk *walk, git_commit_list_node *commit)
return error; return error;
if (obj->cached.type != GIT_OBJECT_COMMIT) { if (obj->cached.type != GIT_OBJECT_COMMIT) {
giterr_set(GITERR_INVALID, "object is no commit object"); git_error_set(GIT_ERROR_INVALID, "object is no commit object");
error = -1; error = -1;
} else } else
error = commit_quick_parse( error = commit_quick_parse(
......
...@@ -89,30 +89,30 @@ ...@@ -89,30 +89,30 @@
/** /**
* Check a pointer allocation result, returning -1 if it failed. * Check a pointer allocation result, returning -1 if it failed.
*/ */
#define GITERR_CHECK_ALLOC(ptr) if (ptr == NULL) { return -1; } #define GIT_ERROR_CHECK_ALLOC(ptr) if (ptr == NULL) { return -1; }
/** /**
* Check a buffer allocation result, returning -1 if it failed. * Check a buffer allocation result, returning -1 if it failed.
*/ */
#define GITERR_CHECK_ALLOC_BUF(buf) if ((void *)(buf) == NULL || git_buf_oom(buf)) { return -1; } #define GIT_ERROR_CHECK_ALLOC_BUF(buf) if ((void *)(buf) == NULL || git_buf_oom(buf)) { return -1; }
/** /**
* Check a return value and propagate result if non-zero. * Check a return value and propagate result if non-zero.
*/ */
#define GITERR_CHECK_ERROR(code) \ #define GIT_ERROR_CHECK_ERROR(code) \
do { int _err = (code); if (_err) return _err; } while (0) do { int _err = (code); if (_err) return _err; } while (0)
/** /**
* Set the error message for this thread, formatting as needed. * Set the error message for this thread, formatting as needed.
*/ */
void giterr_set(int error_class, const char *string, ...) GIT_FORMAT_PRINTF(2, 3); void git_error_set(int error_class, const char *string, ...) GIT_FORMAT_PRINTF(2, 3);
/** /**
* Set the error message for a regex failure, using the internal regex * Set the error message for a regex failure, using the internal regex
* error code lookup and return a libgit error code. * error code lookup and return a libgit error code.
*/ */
int giterr_set_regex(const regex_t *regex, int error_code); int git_error_set_regex(const regex_t *regex, int error_code);
/** /**
* Set error message for user callback if needed. * Set error message for user callback if needed.
...@@ -122,35 +122,35 @@ int giterr_set_regex(const regex_t *regex, int error_code); ...@@ -122,35 +122,35 @@ int giterr_set_regex(const regex_t *regex, int error_code);
* *
* @return This always returns the `error_code` parameter. * @return This always returns the `error_code` parameter.
*/ */
GIT_INLINE(int) giterr_set_after_callback_function( GIT_INLINE(int) git_error_set_after_callback_function(
int error_code, const char *action) int error_code, const char *action)
{ {
if (error_code) { if (error_code) {
const git_error *e = giterr_last(); const git_error *e = git_error_last();
if (!e || !e->message) if (!e || !e->message)
giterr_set(e ? e->klass : GITERR_CALLBACK, git_error_set(e ? e->klass : GIT_ERROR_CALLBACK,
"%s callback returned %d", action, error_code); "%s callback returned %d", action, error_code);
} }
return error_code; return error_code;
} }
#ifdef GIT_WIN32 #ifdef GIT_WIN32
#define giterr_set_after_callback(code) \ #define git_error_set_after_callback(code) \
giterr_set_after_callback_function((code), __FUNCTION__) git_error_set_after_callback_function((code), __FUNCTION__)
#else #else
#define giterr_set_after_callback(code) \ #define git_error_set_after_callback(code) \
giterr_set_after_callback_function((code), __func__) git_error_set_after_callback_function((code), __func__)
#endif #endif
/** /**
* Gets the system error code for this thread. * Gets the system error code for this thread.
*/ */
int giterr_system_last(void); int git_error_system_last(void);
/** /**
* Sets the system error code for this thread. * Sets the system error code for this thread.
*/ */
void giterr_system_set(int code); void git_error_system_set(int code);
/** /**
* Structure to preserve libgit2 error state * Structure to preserve libgit2 error state
...@@ -166,20 +166,20 @@ typedef struct { ...@@ -166,20 +166,20 @@ typedef struct {
* If `error_code` is zero, this does not clear the current error state. * If `error_code` is zero, this does not clear the current error state.
* You must either restore this error state, or free it. * You must either restore this error state, or free it.
*/ */
extern int giterr_state_capture(git_error_state *state, int error_code); extern int git_error_state_capture(git_error_state *state, int error_code);
/** /**
* Restore error state to a previous value, returning saved error code. * Restore error state to a previous value, returning saved error code.
*/ */
extern int giterr_state_restore(git_error_state *state); extern int git_error_state_restore(git_error_state *state);
/** Free an error state. */ /** Free an error state. */
extern void giterr_state_free(git_error_state *state); extern void git_error_state_free(git_error_state *state);
/** /**
* Check a versioned structure for validity * Check a versioned structure for validity
*/ */
GIT_INLINE(int) giterr__check_version(const void *structure, unsigned int expected_max, const char *name) GIT_INLINE(int) git_error__check_version(const void *structure, unsigned int expected_max, const char *name)
{ {
unsigned int actual; unsigned int actual;
...@@ -190,10 +190,10 @@ GIT_INLINE(int) giterr__check_version(const void *structure, unsigned int expect ...@@ -190,10 +190,10 @@ GIT_INLINE(int) giterr__check_version(const void *structure, unsigned int expect
if (actual > 0 && actual <= expected_max) if (actual > 0 && actual <= expected_max)
return 0; return 0;
giterr_set(GITERR_INVALID, "invalid version %d on %s", actual, name); git_error_set(GIT_ERROR_INVALID, "invalid version %d on %s", actual, name);
return -1; return -1;
} }
#define GITERR_CHECK_VERSION(S,V,N) if (giterr__check_version(S,V,N) < 0) return -1 #define GIT_ERROR_CHECK_VERSION(S,V,N) if (git_error__check_version(S,V,N) < 0) return -1
/** /**
* Initialize a structure with a version. * Initialize a structure with a version.
...@@ -207,42 +207,42 @@ GIT_INLINE(void) git__init_structure(void *structure, size_t len, unsigned int v ...@@ -207,42 +207,42 @@ GIT_INLINE(void) git__init_structure(void *structure, size_t len, unsigned int v
#define GIT_INIT_STRUCTURE_FROM_TEMPLATE(PTR,VERSION,TYPE,TPL) do { \ #define GIT_INIT_STRUCTURE_FROM_TEMPLATE(PTR,VERSION,TYPE,TPL) do { \
TYPE _tmpl = TPL; \ TYPE _tmpl = TPL; \
GITERR_CHECK_VERSION(&(VERSION), _tmpl.version, #TYPE); \ GIT_ERROR_CHECK_VERSION(&(VERSION), _tmpl.version, #TYPE); \
memcpy((PTR), &_tmpl, sizeof(_tmpl)); } while (0) memcpy((PTR), &_tmpl, sizeof(_tmpl)); } while (0)
/** Check for additive overflow, setting an error if would occur. */ /** Check for additive overflow, setting an error if would occur. */
#define GIT_ADD_SIZET_OVERFLOW(out, one, two) \ #define GIT_ADD_SIZET_OVERFLOW(out, one, two) \
(git__add_sizet_overflow(out, one, two) ? (giterr_set_oom(), 1) : 0) (git__add_sizet_overflow(out, one, two) ? (git_error_set_oom(), 1) : 0)
/** Check for additive overflow, setting an error if would occur. */ /** Check for additive overflow, setting an error if would occur. */
#define GIT_MULTIPLY_SIZET_OVERFLOW(out, nelem, elsize) \ #define GIT_MULTIPLY_SIZET_OVERFLOW(out, nelem, elsize) \
(git__multiply_sizet_overflow(out, nelem, elsize) ? (giterr_set_oom(), 1) : 0) (git__multiply_sizet_overflow(out, nelem, elsize) ? (git_error_set_oom(), 1) : 0)
/** Check for additive overflow, failing if it would occur. */ /** Check for additive overflow, failing if it would occur. */
#define GITERR_CHECK_ALLOC_ADD(out, one, two) \ #define GIT_ERROR_CHECK_ALLOC_ADD(out, one, two) \
if (GIT_ADD_SIZET_OVERFLOW(out, one, two)) { return -1; } if (GIT_ADD_SIZET_OVERFLOW(out, one, two)) { return -1; }
#define GITERR_CHECK_ALLOC_ADD3(out, one, two, three) \ #define GIT_ERROR_CHECK_ALLOC_ADD3(out, one, two, three) \
if (GIT_ADD_SIZET_OVERFLOW(out, one, two) || \ if (GIT_ADD_SIZET_OVERFLOW(out, one, two) || \
GIT_ADD_SIZET_OVERFLOW(out, *(out), three)) { return -1; } GIT_ADD_SIZET_OVERFLOW(out, *(out), three)) { return -1; }
#define GITERR_CHECK_ALLOC_ADD4(out, one, two, three, four) \ #define GIT_ERROR_CHECK_ALLOC_ADD4(out, one, two, three, four) \
if (GIT_ADD_SIZET_OVERFLOW(out, one, two) || \ if (GIT_ADD_SIZET_OVERFLOW(out, one, two) || \
GIT_ADD_SIZET_OVERFLOW(out, *(out), three) || \ GIT_ADD_SIZET_OVERFLOW(out, *(out), three) || \
GIT_ADD_SIZET_OVERFLOW(out, *(out), four)) { return -1; } GIT_ADD_SIZET_OVERFLOW(out, *(out), four)) { return -1; }
#define GITERR_CHECK_ALLOC_ADD5(out, one, two, three, four, five) \ #define GIT_ERROR_CHECK_ALLOC_ADD5(out, one, two, three, four, five) \
if (GIT_ADD_SIZET_OVERFLOW(out, one, two) || \ if (GIT_ADD_SIZET_OVERFLOW(out, one, two) || \
GIT_ADD_SIZET_OVERFLOW(out, *(out), three) || \ GIT_ADD_SIZET_OVERFLOW(out, *(out), three) || \
GIT_ADD_SIZET_OVERFLOW(out, *(out), four) || \ GIT_ADD_SIZET_OVERFLOW(out, *(out), four) || \
GIT_ADD_SIZET_OVERFLOW(out, *(out), five)) { return -1; } GIT_ADD_SIZET_OVERFLOW(out, *(out), five)) { return -1; }
/** Check for multiplicative overflow, failing if it would occur. */ /** Check for multiplicative overflow, failing if it would occur. */
#define GITERR_CHECK_ALLOC_MULTIPLY(out, nelem, elsize) \ #define GIT_ERROR_CHECK_ALLOC_MULTIPLY(out, nelem, elsize) \
if (GIT_MULTIPLY_SIZET_OVERFLOW(out, nelem, elsize)) { return -1; } if (GIT_MULTIPLY_SIZET_OVERFLOW(out, nelem, elsize)) { return -1; }
/* NOTE: other giterr functions are in the public errors.h header file */ /* NOTE: other git_error functions are in the public errors.h header file */
#include "util.h" #include "util.h"
......
...@@ -81,7 +81,7 @@ int git_config_new(git_config **out) ...@@ -81,7 +81,7 @@ int git_config_new(git_config **out)
git_config *cfg; git_config *cfg;
cfg = git__malloc(sizeof(git_config)); cfg = git__malloc(sizeof(git_config));
GITERR_CHECK_ALLOC(cfg); GIT_ERROR_CHECK_ALLOC(cfg);
memset(cfg, 0x0, sizeof(git_config)); memset(cfg, 0x0, sizeof(git_config));
...@@ -110,7 +110,7 @@ int git_config_add_file_ondisk( ...@@ -110,7 +110,7 @@ int git_config_add_file_ondisk(
res = p_stat(path, &st); res = p_stat(path, &st);
if (res < 0 && errno != ENOENT && errno != ENOTDIR) { if (res < 0 && errno != ENOENT && errno != ENOTDIR) {
giterr_set(GITERR_CONFIG, "failed to stat '%s'", path); git_error_set(GIT_ERROR_CONFIG, "failed to stat '%s'", path);
return -1; return -1;
} }
...@@ -203,7 +203,7 @@ static int find_backend_by_level( ...@@ -203,7 +203,7 @@ static int find_backend_by_level(
} }
if (pos == -1) { if (pos == -1) {
giterr_set(GITERR_CONFIG, git_error_set(GIT_ERROR_CONFIG,
"no configuration exists for the given level '%i'", (int)level); "no configuration exists for the given level '%i'", (int)level);
return GIT_ENOTFOUND; return GIT_ENOTFOUND;
} }
...@@ -219,7 +219,7 @@ static int duplicate_level(void **old_raw, void *new_raw) ...@@ -219,7 +219,7 @@ static int duplicate_level(void **old_raw, void *new_raw)
GIT_UNUSED(new_raw); GIT_UNUSED(new_raw);
giterr_set(GITERR_CONFIG, "there already exists a configuration for the given level (%i)", (int)(*old)->level); git_error_set(GIT_ERROR_CONFIG, "there already exists a configuration for the given level (%i)", (int)(*old)->level);
return GIT_EEXISTS; return GIT_EEXISTS;
} }
...@@ -316,13 +316,13 @@ int git_config_add_backend( ...@@ -316,13 +316,13 @@ int git_config_add_backend(
assert(cfg && backend); assert(cfg && backend);
GITERR_CHECK_VERSION(backend, GIT_CONFIG_BACKEND_VERSION, "git_config_backend"); GIT_ERROR_CHECK_VERSION(backend, GIT_CONFIG_BACKEND_VERSION, "git_config_backend");
if ((result = backend->open(backend, level, repo)) < 0) if ((result = backend->open(backend, level, repo)) < 0)
return result; return result;
internal = git__malloc(sizeof(backend_internal)); internal = git__malloc(sizeof(backend_internal));
GITERR_CHECK_ALLOC(internal); GIT_ERROR_CHECK_ALLOC(internal);
memset(internal, 0x0, sizeof(backend_internal)); memset(internal, 0x0, sizeof(backend_internal));
...@@ -456,7 +456,7 @@ int git_config_iterator_new(git_config_iterator **out, const git_config *cfg) ...@@ -456,7 +456,7 @@ int git_config_iterator_new(git_config_iterator **out, const git_config *cfg)
all_iter *iter; all_iter *iter;
iter = git__calloc(1, sizeof(all_iter)); iter = git__calloc(1, sizeof(all_iter));
GITERR_CHECK_ALLOC(iter); GIT_ERROR_CHECK_ALLOC(iter);
iter->parent.free = all_iter_free; iter->parent.free = all_iter_free;
iter->parent.next = all_iter_next; iter->parent.next = all_iter_next;
...@@ -478,10 +478,10 @@ int git_config_iterator_glob_new(git_config_iterator **out, const git_config *cf ...@@ -478,10 +478,10 @@ int git_config_iterator_glob_new(git_config_iterator **out, const git_config *cf
return git_config_iterator_new(out, cfg); return git_config_iterator_new(out, cfg);
iter = git__calloc(1, sizeof(all_iter)); iter = git__calloc(1, sizeof(all_iter));
GITERR_CHECK_ALLOC(iter); GIT_ERROR_CHECK_ALLOC(iter);
if ((result = p_regcomp(&iter->regex, regexp, REG_EXTENDED)) != 0) { if ((result = p_regcomp(&iter->regex, regexp, REG_EXTENDED)) != 0) {
giterr_set_regex(&iter->regex, result); git_error_set_regex(&iter->regex, result);
git__free(iter); git__free(iter);
return -1; return -1;
} }
...@@ -517,7 +517,7 @@ int git_config_backend_foreach_match( ...@@ -517,7 +517,7 @@ int git_config_backend_foreach_match(
if (regexp != NULL) { if (regexp != NULL) {
if ((error = p_regcomp(&regex, regexp, REG_EXTENDED)) != 0) { if ((error = p_regcomp(&regex, regexp, REG_EXTENDED)) != 0) {
giterr_set_regex(&regex, error); git_error_set_regex(&regex, error);
regfree(&regex); regfree(&regex);
return -1; return -1;
} }
...@@ -535,7 +535,7 @@ int git_config_backend_foreach_match( ...@@ -535,7 +535,7 @@ int git_config_backend_foreach_match(
/* abort iterator on non-zero return value */ /* abort iterator on non-zero return value */
if ((error = cb(entry, payload)) != 0) { if ((error = cb(entry, payload)) != 0) {
giterr_set_after_callback(error); git_error_set_after_callback(error);
break; break;
} }
} }
...@@ -563,7 +563,7 @@ int git_config_foreach_match( ...@@ -563,7 +563,7 @@ int git_config_foreach_match(
while (!(error = git_config_next(&entry, iter))) { while (!(error = git_config_next(&entry, iter))) {
if ((error = cb(entry, payload)) != 0) { if ((error = cb(entry, payload)) != 0) {
giterr_set_after_callback(error); git_error_set_after_callback(error);
break; break;
} }
} }
...@@ -599,7 +599,7 @@ static int get_backend_for_use(git_config_backend **out, ...@@ -599,7 +599,7 @@ static int get_backend_for_use(git_config_backend **out,
*out = NULL; *out = NULL;
if (git_vector_length(&cfg->backends) == 0) { if (git_vector_length(&cfg->backends) == 0) {
giterr_set(GITERR_CONFIG, git_error_set(GIT_ERROR_CONFIG,
"cannot %s value for '%s' when no config backends exist", "cannot %s value for '%s' when no config backends exist",
uses[use], name); uses[use], name);
return GIT_ENOTFOUND; return GIT_ENOTFOUND;
...@@ -612,7 +612,7 @@ static int get_backend_for_use(git_config_backend **out, ...@@ -612,7 +612,7 @@ static int get_backend_for_use(git_config_backend **out,
} }
} }
giterr_set(GITERR_CONFIG, git_error_set(GIT_ERROR_CONFIG,
"cannot %s value for '%s' when all config backends are readonly", "cannot %s value for '%s' when all config backends are readonly",
uses[use], name); uses[use], name);
return GIT_ENOTFOUND; return GIT_ENOTFOUND;
...@@ -651,7 +651,7 @@ int git_config_set_string(git_config *cfg, const char *name, const char *value) ...@@ -651,7 +651,7 @@ int git_config_set_string(git_config *cfg, const char *name, const char *value)
git_config_backend *backend; git_config_backend *backend;
if (!value) { if (!value) {
giterr_set(GITERR_CONFIG, "the value to set cannot be NULL"); git_error_set(GIT_ERROR_CONFIG, "the value to set cannot be NULL");
return -1; return -1;
} }
...@@ -703,7 +703,7 @@ int git_config__update_entry( ...@@ -703,7 +703,7 @@ int git_config__update_entry(
static int config_error_notfound(const char *name) static int config_error_notfound(const char *name)
{ {
giterr_set(GITERR_CONFIG, "config value '%s' was not found", name); git_error_set(GIT_ERROR_CONFIG, "config value '%s' was not found", name);
return GIT_ENOTFOUND; return GIT_ENOTFOUND;
} }
...@@ -750,7 +750,7 @@ cleanup: ...@@ -750,7 +750,7 @@ cleanup:
if (res == GIT_ENOTFOUND) if (res == GIT_ENOTFOUND)
res = (want_errors > GET_ALL_ERRORS) ? 0 : config_error_notfound(name); res = (want_errors > GET_ALL_ERRORS) ? 0 : config_error_notfound(name);
else if (res && (want_errors == GET_NO_ERRORS)) { else if (res && (want_errors == GET_NO_ERRORS)) {
giterr_clear(); git_error_clear();
res = 0; res = 0;
} }
...@@ -871,7 +871,7 @@ int git_config_get_string( ...@@ -871,7 +871,7 @@ int git_config_get_string(
int ret; int ret;
if (!is_readonly(cfg)) { if (!is_readonly(cfg)) {
giterr_set(GITERR_CONFIG, "get_string called on a live config object"); git_error_set(GIT_ERROR_CONFIG, "get_string called on a live config object");
return -1; return -1;
} }
...@@ -925,7 +925,7 @@ int git_config__get_bool_force( ...@@ -925,7 +925,7 @@ int git_config__get_bool_force(
get_entry(&entry, cfg, key, false, GET_NO_ERRORS); get_entry(&entry, cfg, key, false, GET_NO_ERRORS);
if (entry && git_config_parse_bool(&val, entry->value) < 0) if (entry && git_config_parse_bool(&val, entry->value) < 0)
giterr_clear(); git_error_clear();
git_config_entry_free(entry); git_config_entry_free(entry);
return val; return val;
...@@ -940,7 +940,7 @@ int git_config__get_int_force( ...@@ -940,7 +940,7 @@ int git_config__get_int_force(
get_entry(&entry, cfg, key, false, GET_NO_ERRORS); get_entry(&entry, cfg, key, false, GET_NO_ERRORS);
if (entry && git_config_parse_int32(&val, entry->value) < 0) if (entry && git_config_parse_int32(&val, entry->value) < 0)
giterr_clear(); git_error_clear();
git_config_entry_free(entry); git_config_entry_free(entry);
return (int)val; return (int)val;
...@@ -962,7 +962,7 @@ int git_config_get_multivar_foreach( ...@@ -962,7 +962,7 @@ int git_config_get_multivar_foreach(
found = 1; found = 1;
if ((err = cb(entry, payload)) != 0) { if ((err = cb(entry, payload)) != 0) {
giterr_set_after_callback(err); git_error_set_after_callback(err);
break; break;
} }
} }
...@@ -1026,7 +1026,7 @@ int git_config_multivar_iterator_new(git_config_iterator **out, const git_config ...@@ -1026,7 +1026,7 @@ int git_config_multivar_iterator_new(git_config_iterator **out, const git_config
return error; return error;
iter = git__calloc(1, sizeof(multivar_iter)); iter = git__calloc(1, sizeof(multivar_iter));
GITERR_CHECK_ALLOC(iter); GIT_ERROR_CHECK_ALLOC(iter);
if ((error = git_config__normalize_name(name, &iter->name)) < 0) if ((error = git_config__normalize_name(name, &iter->name)) < 0)
goto on_error; goto on_error;
...@@ -1034,7 +1034,7 @@ int git_config_multivar_iterator_new(git_config_iterator **out, const git_config ...@@ -1034,7 +1034,7 @@ int git_config_multivar_iterator_new(git_config_iterator **out, const git_config
if (regexp != NULL) { if (regexp != NULL) {
error = p_regcomp(&iter->regex, regexp, REG_EXTENDED); error = p_regcomp(&iter->regex, regexp, REG_EXTENDED);
if (error != 0) { if (error != 0) {
giterr_set_regex(&iter->regex, error); git_error_set_regex(&iter->regex, error);
error = -1; error = -1;
regfree(&iter->regex); regfree(&iter->regex);
goto on_error; goto on_error;
...@@ -1188,7 +1188,7 @@ int git_config_lock(git_transaction **out, git_config *cfg) ...@@ -1188,7 +1188,7 @@ int git_config_lock(git_transaction **out, git_config *cfg)
internal = git_vector_get(&cfg->backends, 0); internal = git_vector_get(&cfg->backends, 0);
if (!internal || !internal->backend) { if (!internal || !internal->backend) {
giterr_set(GITERR_CONFIG, "cannot lock; the config has no backends"); git_error_set(GIT_ERROR_CONFIG, "cannot lock; the config has no backends");
return -1; return -1;
} }
backend = internal->backend; backend = internal->backend;
...@@ -1208,7 +1208,7 @@ int git_config_unlock(git_config *cfg, int commit) ...@@ -1208,7 +1208,7 @@ int git_config_unlock(git_config *cfg, int commit)
internal = git_vector_get(&cfg->backends, 0); internal = git_vector_get(&cfg->backends, 0);
if (!internal || !internal->backend) { if (!internal || !internal->backend) {
giterr_set(GITERR_CONFIG, "cannot lock; the config has no backends"); git_error_set(GIT_ERROR_CONFIG, "cannot lock; the config has no backends");
return -1; return -1;
} }
...@@ -1263,7 +1263,7 @@ int git_config_lookup_map_value( ...@@ -1263,7 +1263,7 @@ int git_config_lookup_map_value(
} }
fail_parse: fail_parse:
giterr_set(GITERR_CONFIG, "failed to map '%s'", value); git_error_set(GIT_ERROR_CONFIG, "failed to map '%s'", value);
return -1; return -1;
} }
...@@ -1283,7 +1283,7 @@ int git_config_lookup_map_enum(git_cvar_t *type_out, const char **str_out, ...@@ -1283,7 +1283,7 @@ int git_config_lookup_map_enum(git_cvar_t *type_out, const char **str_out,
return 0; return 0;
} }
giterr_set(GITERR_CONFIG, "invalid enum value"); git_error_set(GIT_ERROR_CONFIG, "invalid enum value");
return GIT_ENOTFOUND; return GIT_ENOTFOUND;
} }
...@@ -1297,7 +1297,7 @@ int git_config_parse_bool(int *out, const char *value) ...@@ -1297,7 +1297,7 @@ int git_config_parse_bool(int *out, const char *value)
return 0; return 0;
} }
giterr_set(GITERR_CONFIG, "failed to parse '%s' as a boolean value", value); git_error_set(GIT_ERROR_CONFIG, "failed to parse '%s' as a boolean value", value);
return -1; return -1;
} }
...@@ -1340,7 +1340,7 @@ int git_config_parse_int64(int64_t *out, const char *value) ...@@ -1340,7 +1340,7 @@ int git_config_parse_int64(int64_t *out, const char *value)
} }
fail_parse: fail_parse:
giterr_set(GITERR_CONFIG, "failed to parse '%s' as an integer", value ? value : "(null)"); git_error_set(GIT_ERROR_CONFIG, "failed to parse '%s' as an integer", value ? value : "(null)");
return -1; return -1;
} }
...@@ -1360,7 +1360,7 @@ int git_config_parse_int32(int32_t *out, const char *value) ...@@ -1360,7 +1360,7 @@ int git_config_parse_int32(int32_t *out, const char *value)
return 0; return 0;
fail_parse: fail_parse:
giterr_set(GITERR_CONFIG, "failed to parse '%s' as a 32-bit integer", value ? value : "(null)"); git_error_set(GIT_ERROR_CONFIG, "failed to parse '%s' as a 32-bit integer", value ? value : "(null)");
return -1; return -1;
} }
...@@ -1372,7 +1372,7 @@ int git_config_parse_path(git_buf *out, const char *value) ...@@ -1372,7 +1372,7 @@ int git_config_parse_path(git_buf *out, const char *value)
if (value[0] == '~') { if (value[0] == '~') {
if (value[1] != '\0' && value[1] != '/') { if (value[1] != '\0' && value[1] != '/') {
giterr_set(GITERR_CONFIG, "retrieving a homedir by name is not supported"); git_error_set(GIT_ERROR_CONFIG, "retrieving a homedir by name is not supported");
return -1; return -1;
} }
...@@ -1414,7 +1414,7 @@ int git_config__normalize_name(const char *in, char **out) ...@@ -1414,7 +1414,7 @@ int git_config__normalize_name(const char *in, char **out)
assert(in && out); assert(in && out);
name = git__strdup(in); name = git__strdup(in);
GITERR_CHECK_ALLOC(name); GIT_ERROR_CHECK_ALLOC(name);
fdot = strchr(name, '.'); fdot = strchr(name, '.');
ldot = strrchr(name, '.'); ldot = strrchr(name, '.');
...@@ -1437,7 +1437,7 @@ int git_config__normalize_name(const char *in, char **out) ...@@ -1437,7 +1437,7 @@ int git_config__normalize_name(const char *in, char **out)
invalid: invalid:
git__free(name); git__free(name);
giterr_set(GITERR_CONFIG, "invalid config item name '%s'", in); git_error_set(GIT_ERROR_CONFIG, "invalid config item name '%s'", in);
return GIT_EINVALIDSPEC; return GIT_EINVALIDSPEC;
} }
...@@ -1498,8 +1498,8 @@ int git_config_rename_section( ...@@ -1498,8 +1498,8 @@ int git_config_rename_section(
if (new_section_name != NULL && if (new_section_name != NULL &&
(error = normalize_section(replace.ptr, strchr(replace.ptr, '.'))) < 0) (error = normalize_section(replace.ptr, strchr(replace.ptr, '.'))) < 0)
{ {
giterr_set( git_error_set(
GITERR_CONFIG, "invalid config section '%s'", new_section_name); GIT_ERROR_CONFIG, "invalid config section '%s'", new_section_name);
goto cleanup; goto cleanup;
} }
......
...@@ -56,7 +56,7 @@ int git_config_entries_new(git_config_entries **out) ...@@ -56,7 +56,7 @@ int git_config_entries_new(git_config_entries **out)
int error; int error;
entries = git__calloc(1, sizeof(git_config_entries)); entries = git__calloc(1, sizeof(git_config_entries));
GITERR_CHECK_ALLOC(entries); GIT_ERROR_CHECK_ALLOC(entries);
GIT_REFCOUNT_INC(entries); GIT_REFCOUNT_INC(entries);
if ((error = git_strmap_alloc(&entries->map)) < 0) if ((error = git_strmap_alloc(&entries->map)) < 0)
...@@ -81,10 +81,10 @@ int git_config_entries_dup(git_config_entries **out, git_config_entries *entries ...@@ -81,10 +81,10 @@ int git_config_entries_dup(git_config_entries **out, git_config_entries *entries
dup = git__calloc(1, sizeof(git_config_entry)); dup = git__calloc(1, sizeof(git_config_entry));
dup->name = git__strdup(head->entry->name); dup->name = git__strdup(head->entry->name);
GITERR_CHECK_ALLOC(dup->name); GIT_ERROR_CHECK_ALLOC(dup->name);
if (head->entry->value) { if (head->entry->value) {
dup->value = git__strdup(head->entry->value); dup->value = git__strdup(head->entry->value);
GITERR_CHECK_ALLOC(dup->value); GIT_ERROR_CHECK_ALLOC(dup->value);
} }
dup->level = head->entry->level; dup->level = head->entry->level;
dup->include_depth = head->entry->include_depth; dup->include_depth = head->entry->include_depth;
...@@ -136,7 +136,7 @@ int git_config_entries_append(git_config_entries *entries, git_config_entry *ent ...@@ -136,7 +136,7 @@ int git_config_entries_append(git_config_entries *entries, git_config_entry *ent
size_t pos; size_t pos;
var = git__calloc(1, sizeof(config_entry_list)); var = git__calloc(1, sizeof(config_entry_list));
GITERR_CHECK_ALLOC(var); GIT_ERROR_CHECK_ALLOC(var);
var->entry = entry; var->entry = entry;
pos = git_strmap_lookup_index(entries->map, entry->name); pos = git_strmap_lookup_index(entries->map, entry->name);
...@@ -162,7 +162,7 @@ int git_config_entries_append(git_config_entries *entries, git_config_entry *ent ...@@ -162,7 +162,7 @@ int git_config_entries_append(git_config_entries *entries, git_config_entry *ent
} }
var = git__calloc(1, sizeof(config_entry_list)); var = git__calloc(1, sizeof(config_entry_list));
GITERR_CHECK_ALLOC(var); GIT_ERROR_CHECK_ALLOC(var);
var->entry = entry; var->entry = entry;
config_entry_list_append(&entries->list, var); config_entry_list_append(&entries->list, var);
...@@ -205,12 +205,12 @@ int git_config_entries_get_unique(git_config_entry **out, git_config_entries *en ...@@ -205,12 +205,12 @@ int git_config_entries_get_unique(git_config_entry **out, git_config_entries *en
return error; return error;
if (entry->next != NULL) { if (entry->next != NULL) {
giterr_set(GITERR_CONFIG, "entry is not unique due to being a multivar"); git_error_set(GIT_ERROR_CONFIG, "entry is not unique due to being a multivar");
return -1; return -1;
} }
if (entry->entry->include_depth) { if (entry->entry->include_depth) {
giterr_set(GITERR_CONFIG, "entry is not unique due to being included"); git_error_set(GIT_ERROR_CONFIG, "entry is not unique due to being included");
return -1; return -1;
} }
...@@ -246,7 +246,7 @@ int git_config_entries_iterator_new(git_config_iterator **out, git_config_entrie ...@@ -246,7 +246,7 @@ int git_config_entries_iterator_new(git_config_iterator **out, git_config_entrie
config_entries_iterator *it; config_entries_iterator *it;
it = git__calloc(1, sizeof(config_entries_iterator)); it = git__calloc(1, sizeof(config_entries_iterator));
GITERR_CHECK_ALLOC(it); GIT_ERROR_CHECK_ALLOC(it);
it->parent.next = config_iterator_next; it->parent.next = config_iterator_next;
it->parent.free = config_iterator_free; it->parent.free = config_iterator_free;
it->head = entries->list; it->head = entries->list;
......
...@@ -69,7 +69,7 @@ static int config_snapshot(git_config_backend **out, git_config_backend *in); ...@@ -69,7 +69,7 @@ static int config_snapshot(git_config_backend **out, git_config_backend *in);
static int config_error_readonly(void) static int config_error_readonly(void)
{ {
giterr_set(GITERR_CONFIG, "this backend is read-only"); git_error_set(GIT_ERROR_CONFIG, "this backend is read-only");
return -1; return -1;
} }
...@@ -83,7 +83,7 @@ static git_config_entries *diskfile_entries_take(diskfile_header *h) ...@@ -83,7 +83,7 @@ static git_config_entries *diskfile_entries_take(diskfile_header *h)
git_config_entries *entries; git_config_entries *entries;
if (git_mutex_lock(&h->values_mutex) < 0) { if (git_mutex_lock(&h->values_mutex) < 0) {
giterr_set(GITERR_OS, "failed to lock config backend"); git_error_set(GIT_ERROR_OS, "failed to lock config backend");
return NULL; return NULL;
} }
...@@ -196,7 +196,7 @@ static int config_refresh(git_config_backend *cfg) ...@@ -196,7 +196,7 @@ static int config_refresh(git_config_backend *cfg)
goto out; goto out;
if ((error = git_mutex_lock(&b->header.values_mutex)) < 0) { if ((error = git_mutex_lock(&b->header.values_mutex)) < 0) {
giterr_set(GITERR_OS, "failed to lock config backend"); git_error_set(GIT_ERROR_OS, "failed to lock config backend");
goto out; goto out;
} }
...@@ -274,7 +274,7 @@ static int config_set(git_config_backend *cfg, const char *name, const char *val ...@@ -274,7 +274,7 @@ static int config_set(git_config_backend *cfg, const char *name, const char *val
/* No early returns due to sanity checks, let's write it out and refresh */ /* No early returns due to sanity checks, let's write it out and refresh */
if (value) { if (value) {
esc_value = escape_value(value); esc_value = escape_value(value);
GITERR_CHECK_ALLOC(esc_value); GIT_ERROR_CHECK_ALLOC(esc_value);
} }
if ((error = config_write(b, name, key, NULL, esc_value)) < 0) if ((error = config_write(b, name, key, NULL, esc_value)) < 0)
...@@ -339,7 +339,7 @@ static int config_set_multivar( ...@@ -339,7 +339,7 @@ static int config_set_multivar(
result = p_regcomp(&preg, regexp, REG_EXTENDED); result = p_regcomp(&preg, regexp, REG_EXTENDED);
if (result != 0) { if (result != 0) {
giterr_set_regex(&preg, result); git_error_set_regex(&preg, result);
result = -1; result = -1;
goto out; goto out;
} }
...@@ -374,7 +374,7 @@ static int config_delete(git_config_backend *cfg, const char *name) ...@@ -374,7 +374,7 @@ static int config_delete(git_config_backend *cfg, const char *name)
/* Check whether we'd be modifying an included or multivar key */ /* Check whether we'd be modifying an included or multivar key */
if ((error = git_config_entries_get_unique(&entry, entries, key)) < 0) { if ((error = git_config_entries_get_unique(&entry, entries, key)) < 0) {
if (error == GIT_ENOTFOUND) if (error == GIT_ENOTFOUND)
giterr_set(GITERR_CONFIG, "could not find key '%s' to delete", name); git_error_set(GIT_ERROR_CONFIG, "could not find key '%s' to delete", name);
goto out; goto out;
} }
...@@ -409,12 +409,12 @@ static int config_delete_multivar(git_config_backend *cfg, const char *name, con ...@@ -409,12 +409,12 @@ static int config_delete_multivar(git_config_backend *cfg, const char *name, con
if ((result = git_config_entries_get(&entry, entries, key)) < 0) { if ((result = git_config_entries_get(&entry, entries, key)) < 0) {
if (result == GIT_ENOTFOUND) if (result == GIT_ENOTFOUND)
giterr_set(GITERR_CONFIG, "could not find key '%s' to delete", name); git_error_set(GIT_ERROR_CONFIG, "could not find key '%s' to delete", name);
goto out; goto out;
} }
if ((result = p_regcomp(&preg, regexp, REG_EXTENDED)) != 0) { if ((result = p_regcomp(&preg, regexp, REG_EXTENDED)) != 0) {
giterr_set_regex(&preg, result); git_error_set_regex(&preg, result);
result = -1; result = -1;
goto out; goto out;
} }
...@@ -473,13 +473,13 @@ int git_config_backend_from_file(git_config_backend **out, const char *path) ...@@ -473,13 +473,13 @@ int git_config_backend_from_file(git_config_backend **out, const char *path)
diskfile_backend *backend; diskfile_backend *backend;
backend = git__calloc(1, sizeof(diskfile_backend)); backend = git__calloc(1, sizeof(diskfile_backend));
GITERR_CHECK_ALLOC(backend); GIT_ERROR_CHECK_ALLOC(backend);
backend->header.parent.version = GIT_CONFIG_BACKEND_VERSION; backend->header.parent.version = GIT_CONFIG_BACKEND_VERSION;
git_mutex_init(&backend->header.values_mutex); git_mutex_init(&backend->header.values_mutex);
backend->file.path = git__strdup(path); backend->file.path = git__strdup(path);
GITERR_CHECK_ALLOC(backend->file.path); GIT_ERROR_CHECK_ALLOC(backend->file.path);
git_array_init(backend->file.includes); git_array_init(backend->file.includes);
backend->header.parent.open = config_open; backend->header.parent.open = config_open;
...@@ -590,7 +590,7 @@ static int config_snapshot(git_config_backend **out, git_config_backend *in) ...@@ -590,7 +590,7 @@ static int config_snapshot(git_config_backend **out, git_config_backend *in)
diskfile_readonly_backend *backend; diskfile_readonly_backend *backend;
backend = git__calloc(1, sizeof(diskfile_readonly_backend)); backend = git__calloc(1, sizeof(diskfile_readonly_backend));
GITERR_CHECK_ALLOC(backend); GIT_ERROR_CHECK_ALLOC(backend);
backend->header.parent.version = GIT_CONFIG_BACKEND_VERSION; backend->header.parent.version = GIT_CONFIG_BACKEND_VERSION;
git_mutex_init(&backend->header.values_mutex); git_mutex_init(&backend->header.values_mutex);
...@@ -686,7 +686,7 @@ static int parse_include(git_config_parser *reader, ...@@ -686,7 +686,7 @@ static int parse_include(git_config_parser *reader,
include, parse_data->level, parse_data->depth+1); include, parse_data->level, parse_data->depth+1);
if (result == GIT_ENOTFOUND) { if (result == GIT_ENOTFOUND) {
giterr_clear(); git_error_clear();
result = 0; result = 0;
} }
...@@ -828,7 +828,7 @@ static int read_on_variable( ...@@ -828,7 +828,7 @@ static int read_on_variable(
return -1; return -1;
entry = git__calloc(1, sizeof(git_config_entry)); entry = git__calloc(1, sizeof(git_config_entry));
GITERR_CHECK_ALLOC(entry); GIT_ERROR_CHECK_ALLOC(entry);
entry->name = git_buf_detach(&buf); entry->name = git_buf_detach(&buf);
entry->value = var_value ? git__strdup(var_value) : NULL; entry->value = var_value ? git__strdup(var_value) : NULL;
entry->level = parse_data->level; entry->level = parse_data->level;
...@@ -863,7 +863,7 @@ static int config_read( ...@@ -863,7 +863,7 @@ static int config_read(
int error; int error;
if (depth >= MAX_INCLUDE_DEPTH) { if (depth >= MAX_INCLUDE_DEPTH) {
giterr_set(GITERR_CONFIG, "maximum config include depth reached"); git_error_set(GIT_ERROR_CONFIG, "maximum config include depth reached");
return -1; return -1;
} }
...@@ -911,7 +911,7 @@ static int write_section(git_buf *fbuf, const char *key) ...@@ -911,7 +911,7 @@ static int write_section(git_buf *fbuf, const char *key)
char *escaped; char *escaped;
git_buf_put(&buf, key, dot - key); git_buf_put(&buf, key, dot - key);
escaped = escape_value(dot + 1); escaped = escape_value(dot + 1);
GITERR_CHECK_ALLOC(escaped); GIT_ERROR_CHECK_ALLOC(escaped);
git_buf_printf(&buf, " \"%s\"", escaped); git_buf_printf(&buf, " \"%s\"", escaped);
git__free(escaped); git__free(escaped);
} }
...@@ -1156,12 +1156,12 @@ static int config_write(diskfile_backend *cfg, const char *orig_key, const char ...@@ -1156,12 +1156,12 @@ static int config_write(diskfile_backend *cfg, const char *orig_key, const char
ldot = strrchr(key, '.'); ldot = strrchr(key, '.');
name = ldot + 1; name = ldot + 1;
section = git__strndup(key, ldot - key); section = git__strndup(key, ldot - key);
GITERR_CHECK_ALLOC(section); GIT_ERROR_CHECK_ALLOC(section);
ldot = strrchr(orig_key, '.'); ldot = strrchr(orig_key, '.');
orig_name = ldot + 1; orig_name = ldot + 1;
orig_section = git__strndup(orig_key, ldot - orig_key); orig_section = git__strndup(orig_key, ldot - orig_key);
GITERR_CHECK_ALLOC(orig_section); GIT_ERROR_CHECK_ALLOC(orig_section);
write_data.buf = &buf; write_data.buf = &buf;
git_buf_init(&write_data.buffered_comment, 0); git_buf_init(&write_data.buffered_comment, 0);
......
...@@ -24,7 +24,7 @@ typedef struct { ...@@ -24,7 +24,7 @@ typedef struct {
static int config_error_readonly(void) static int config_error_readonly(void)
{ {
giterr_set(GITERR_CONFIG, "this backend is read-only"); git_error_set(GIT_ERROR_CONFIG, "this backend is read-only");
return -1; return -1;
} }
...@@ -63,7 +63,7 @@ static int read_variable_cb( ...@@ -63,7 +63,7 @@ static int read_variable_cb(
return -1; return -1;
entry = git__calloc(1, sizeof(git_config_entry)); entry = git__calloc(1, sizeof(git_config_entry));
GITERR_CHECK_ALLOC(entry); GIT_ERROR_CHECK_ALLOC(entry);
entry->name = git_buf_detach(&buf); entry->name = git_buf_detach(&buf);
entry->value = var_value ? git__strdup(var_value) : NULL; entry->value = var_value ? git__strdup(var_value) : NULL;
entry->level = parse_data->level; entry->level = parse_data->level;
...@@ -170,7 +170,7 @@ static int config_memory_snapshot(git_config_backend **out, git_config_backend * ...@@ -170,7 +170,7 @@ static int config_memory_snapshot(git_config_backend **out, git_config_backend *
{ {
GIT_UNUSED(out); GIT_UNUSED(out);
GIT_UNUSED(backend); GIT_UNUSED(backend);
giterr_set(GITERR_CONFIG, "this backend does not support snapshots"); git_error_set(GIT_ERROR_CONFIG, "this backend does not support snapshots");
return -1; return -1;
} }
...@@ -191,7 +191,7 @@ int git_config_backend_from_string(git_config_backend **out, const char *cfg, si ...@@ -191,7 +191,7 @@ int git_config_backend_from_string(git_config_backend **out, const char *cfg, si
config_memory_backend *backend; config_memory_backend *backend;
backend = git__calloc(1, sizeof(config_memory_backend)); backend = git__calloc(1, sizeof(config_memory_backend));
GITERR_CHECK_ALLOC(backend); GIT_ERROR_CHECK_ALLOC(backend);
if (git_config_entries_new(&backend->entries) < 0) { if (git_config_entries_new(&backend->entries) < 0) {
git__free(backend); git__free(backend);
......
...@@ -17,7 +17,7 @@ const char *git_config_escaped = "\n\t\b\"\\"; ...@@ -17,7 +17,7 @@ const char *git_config_escaped = "\n\t\b\"\\";
static void set_parse_error(git_config_parser *reader, int col, const char *error_str) static void set_parse_error(git_config_parser *reader, int col, const char *error_str)
{ {
const char *file = reader->file ? reader->file->path : "in-memory"; const char *file = reader->file ? reader->file->path : "in-memory";
giterr_set(GITERR_CONFIG, "failed to parse config file: %s (in %s:%"PRIuZ", column %d)", git_error_set(GIT_ERROR_CONFIG, "failed to parse config file: %s (in %s:%"PRIuZ", column %d)",
error_str, file, reader->ctx.line_num, col); error_str, file, reader->ctx.line_num, col);
} }
...@@ -87,8 +87,8 @@ static int parse_section_header_ext(git_config_parser *reader, const char *line, ...@@ -87,8 +87,8 @@ static int parse_section_header_ext(git_config_parser *reader, const char *line,
goto end_error; goto end_error;
} }
GITERR_CHECK_ALLOC_ADD(&alloc_len, base_name_len, quoted_len); GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, base_name_len, quoted_len);
GITERR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, 2); GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, 2);
if (git_buf_grow(&buf, alloc_len) < 0 || if (git_buf_grow(&buf, alloc_len) < 0 ||
git_buf_printf(&buf, "%s.", base_name) < 0) git_buf_printf(&buf, "%s.", base_name) < 0)
...@@ -169,9 +169,9 @@ static int parse_section_header(git_config_parser *reader, char **section_out) ...@@ -169,9 +169,9 @@ static int parse_section_header(git_config_parser *reader, char **section_out)
return -1; return -1;
} }
GITERR_CHECK_ALLOC_ADD(&line_len, (size_t)(name_end - line), 1); GIT_ERROR_CHECK_ALLOC_ADD(&line_len, (size_t)(name_end - line), 1);
name = git__malloc(line_len); name = git__malloc(line_len);
GITERR_CHECK_ALLOC(name); GIT_ERROR_CHECK_ALLOC(name);
name_length = 0; name_length = 0;
pos = 0; pos = 0;
...@@ -304,7 +304,7 @@ static int unescape_line( ...@@ -304,7 +304,7 @@ static int unescape_line(
*fixed++ = git_config_escaped[esc - git_config_escapes]; *fixed++ = git_config_escaped[esc - git_config_escapes];
} else { } else {
git__free(str); git__free(str);
giterr_set(GITERR_CONFIG, "invalid escape at %s", ptr); git_error_set(GIT_ERROR_CONFIG, "invalid escape at %s", ptr);
return -1; return -1;
} }
} }
...@@ -330,7 +330,7 @@ static int parse_multiline_variable(git_config_parser *reader, git_buf *value, i ...@@ -330,7 +330,7 @@ static int parse_multiline_variable(git_config_parser *reader, git_buf *value, i
/* Check that the next line exists */ /* Check that the next line exists */
git_parse_advance_line(&reader->ctx); git_parse_advance_line(&reader->ctx);
line = git__strndup(reader->ctx.line, reader->ctx.line_len); line = git__strndup(reader->ctx.line, reader->ctx.line_len);
GITERR_CHECK_ALLOC(line); GIT_ERROR_CHECK_ALLOC(line);
/* /*
* We've reached the end of the file, there is no continuation. * We've reached the end of the file, there is no continuation.
...@@ -420,7 +420,7 @@ static int parse_variable(git_config_parser *reader, char **var_name, char **var ...@@ -420,7 +420,7 @@ static int parse_variable(git_config_parser *reader, char **var_name, char **var
git_parse_advance_ws(&reader->ctx); git_parse_advance_ws(&reader->ctx);
line = git__strndup(reader->ctx.line, reader->ctx.line_len); line = git__strndup(reader->ctx.line, reader->ctx.line_len);
GITERR_CHECK_ALLOC(line); GIT_ERROR_CHECK_ALLOC(line);
quote_count = strip_comments(line, 0); quote_count = strip_comments(line, 0);
......
...@@ -85,7 +85,7 @@ static int has_cr_in_index(const git_filter_source *src) ...@@ -85,7 +85,7 @@ static int has_cr_in_index(const git_filter_source *src)
return false; return false;
if (git_repository_index__weakptr(&index, repo) < 0) { if (git_repository_index__weakptr(&index, repo) < 0) {
giterr_clear(); git_error_clear();
return false; return false;
} }
...@@ -170,12 +170,12 @@ GIT_INLINE(int) check_safecrlf( ...@@ -170,12 +170,12 @@ GIT_INLINE(int) check_safecrlf(
/* TODO: issue a warning when available */ /* TODO: issue a warning when available */
} else { } else {
if (filename && *filename) if (filename && *filename)
giterr_set( git_error_set(
GITERR_FILTER, "CRLF would be replaced by LF in '%s'", GIT_ERROR_FILTER, "CRLF would be replaced by LF in '%s'",
filename); filename);
else else
giterr_set( git_error_set(
GITERR_FILTER, "CRLF would be replaced by LF"); GIT_ERROR_FILTER, "CRLF would be replaced by LF");
return -1; return -1;
} }
...@@ -190,12 +190,12 @@ GIT_INLINE(int) check_safecrlf( ...@@ -190,12 +190,12 @@ GIT_INLINE(int) check_safecrlf(
/* TODO: issue a warning when available */ /* TODO: issue a warning when available */
} else { } else {
if (filename && *filename) if (filename && *filename)
giterr_set( git_error_set(
GITERR_FILTER, "LF would be replaced by CRLF in '%s'", GIT_ERROR_FILTER, "LF would be replaced by CRLF in '%s'",
filename); filename);
else else
giterr_set( git_error_set(
GITERR_FILTER, "LF would be replaced by CRLF"); GIT_ERROR_FILTER, "LF would be replaced by CRLF");
return -1; return -1;
} }
...@@ -360,7 +360,7 @@ static int crlf_check( ...@@ -360,7 +360,7 @@ static int crlf_check(
return GIT_PASSTHROUGH; return GIT_PASSTHROUGH;
*payload = git__malloc(sizeof(ca)); *payload = git__malloc(sizeof(ca));
GITERR_CHECK_ALLOC(*payload); GIT_ERROR_CHECK_ALLOC(*payload);
memcpy(*payload, &ca, sizeof(ca)); memcpy(*payload, &ca, sizeof(ca));
return 0; return 0;
......
...@@ -124,19 +124,19 @@ static int lookup_index_alloc( ...@@ -124,19 +124,19 @@ static int lookup_index_alloc(
{ {
size_t entries_len, hash_len, index_len; size_t entries_len, hash_len, index_len;
GITERR_CHECK_ALLOC_MULTIPLY(&entries_len, entries, sizeof(struct index_entry)); GIT_ERROR_CHECK_ALLOC_MULTIPLY(&entries_len, entries, sizeof(struct index_entry));
GITERR_CHECK_ALLOC_MULTIPLY(&hash_len, hash_count, sizeof(struct index_entry *)); GIT_ERROR_CHECK_ALLOC_MULTIPLY(&hash_len, hash_count, sizeof(struct index_entry *));
GITERR_CHECK_ALLOC_ADD(&index_len, sizeof(struct git_delta_index), entries_len); GIT_ERROR_CHECK_ALLOC_ADD(&index_len, sizeof(struct git_delta_index), entries_len);
GITERR_CHECK_ALLOC_ADD(&index_len, index_len, hash_len); GIT_ERROR_CHECK_ALLOC_ADD(&index_len, index_len, hash_len);
if (!git__is_ulong(index_len)) { if (!git__is_ulong(index_len)) {
giterr_set(GITERR_NOMEMORY, "overly large delta"); git_error_set(GIT_ERROR_NOMEMORY, "overly large delta");
return -1; return -1;
} }
*out = git__malloc(index_len); *out = git__malloc(index_len);
GITERR_CHECK_ALLOC(*out); GIT_ERROR_CHECK_ALLOC(*out);
*out_len = index_len; *out_len = index_len;
return 0; return 0;
...@@ -291,7 +291,7 @@ int git_delta_create_from_index( ...@@ -291,7 +291,7 @@ int git_delta_create_from_index(
if (max_size && bufsize >= max_size) if (max_size && bufsize >= max_size)
bufsize = (unsigned int)(max_size + MAX_OP_SIZE + 1); bufsize = (unsigned int)(max_size + MAX_OP_SIZE + 1);
buf = git__malloc(bufsize); buf = git__malloc(bufsize);
GITERR_CHECK_ALLOC(buf); GIT_ERROR_CHECK_ALLOC(buf);
/* store reference buffer size */ /* store reference buffer size */
i = index->src_size; i = index->src_size;
...@@ -438,7 +438,7 @@ int git_delta_create_from_index( ...@@ -438,7 +438,7 @@ int git_delta_create_from_index(
buf[bufpos - inscnt - 1] = inscnt; buf[bufpos - inscnt - 1] = inscnt;
if (max_size && bufpos > max_size) { if (max_size && bufpos > max_size) {
giterr_set(GITERR_NOMEMORY, "delta would be larger than maximum size"); git_error_set(GIT_ERROR_NOMEMORY, "delta would be larger than maximum size");
git__free(buf); git__free(buf);
return GIT_EBUFS; return GIT_EBUFS;
} }
...@@ -466,7 +466,7 @@ static int hdr_sz( ...@@ -466,7 +466,7 @@ static int hdr_sz(
do { do {
if (d == end) { if (d == end) {
giterr_set(GITERR_INVALID, "truncated delta"); git_error_set(GIT_ERROR_INVALID, "truncated delta");
return -1; return -1;
} }
...@@ -545,18 +545,18 @@ int git_delta_apply( ...@@ -545,18 +545,18 @@ int git_delta_apply(
* base object, resulting in data corruption or segfault. * base object, resulting in data corruption or segfault.
*/ */
if ((hdr_sz(&base_sz, &delta, delta_end) < 0) || (base_sz != base_len)) { if ((hdr_sz(&base_sz, &delta, delta_end) < 0) || (base_sz != base_len)) {
giterr_set(GITERR_INVALID, "failed to apply delta: base size does not match given data"); git_error_set(GIT_ERROR_INVALID, "failed to apply delta: base size does not match given data");
return -1; return -1;
} }
if (hdr_sz(&res_sz, &delta, delta_end) < 0) { if (hdr_sz(&res_sz, &delta, delta_end) < 0) {
giterr_set(GITERR_INVALID, "failed to apply delta: base size does not match given data"); git_error_set(GIT_ERROR_INVALID, "failed to apply delta: base size does not match given data");
return -1; return -1;
} }
GITERR_CHECK_ALLOC_ADD(&alloc_sz, res_sz, 1); GIT_ERROR_CHECK_ALLOC_ADD(&alloc_sz, res_sz, 1);
res_dp = git__malloc(alloc_sz); res_dp = git__malloc(alloc_sz);
GITERR_CHECK_ALLOC(res_dp); GIT_ERROR_CHECK_ALLOC(res_dp);
res_dp[res_sz] = '\0'; res_dp[res_sz] = '\0';
*out = res_dp; *out = res_dp;
...@@ -616,6 +616,6 @@ fail: ...@@ -616,6 +616,6 @@ fail:
*out = NULL; *out = NULL;
*out_len = 0; *out_len = 0;
giterr_set(GITERR_INVALID, "failed to apply delta"); git_error_set(GIT_ERROR_INVALID, "failed to apply delta");
return -1; return -1;
} }
...@@ -108,7 +108,7 @@ static int add_to_known_names( ...@@ -108,7 +108,7 @@ static int add_to_known_names(
if (replace_name(&tag, repo, e, prio, sha1)) { if (replace_name(&tag, repo, e, prio, sha1)) {
if (!found) { if (!found) {
e = git__malloc(sizeof(struct commit_name)); e = git__malloc(sizeof(struct commit_name));
GITERR_CHECK_ALLOC(e); GIT_ERROR_CHECK_ALLOC(e);
e->path = NULL; e->path = NULL;
e->tag = NULL; e->tag = NULL;
...@@ -191,7 +191,7 @@ static int commit_name_dup(struct commit_name **out, struct commit_name *in) ...@@ -191,7 +191,7 @@ static int commit_name_dup(struct commit_name **out, struct commit_name *in)
struct commit_name *name; struct commit_name *name;
name = git__malloc(sizeof(struct commit_name)); name = git__malloc(sizeof(struct commit_name));
GITERR_CHECK_ALLOC(name); GIT_ERROR_CHECK_ALLOC(name);
memcpy(name, in, sizeof(struct commit_name)); memcpy(name, in, sizeof(struct commit_name));
name->tag = NULL; name->tag = NULL;
...@@ -201,7 +201,7 @@ static int commit_name_dup(struct commit_name **out, struct commit_name *in) ...@@ -201,7 +201,7 @@ static int commit_name_dup(struct commit_name **out, struct commit_name *in)
return -1; return -1;
name->path = git__strdup(in->path); name->path = git__strdup(in->path);
GITERR_CHECK_ALLOC(name->path); GIT_ERROR_CHECK_ALLOC(name->path);
*out = name; *out = name;
return 0; return 0;
...@@ -267,7 +267,7 @@ static int possible_tag_dup(struct possible_tag **out, struct possible_tag *in) ...@@ -267,7 +267,7 @@ static int possible_tag_dup(struct possible_tag **out, struct possible_tag *in)
int error; int error;
tag = git__malloc(sizeof(struct possible_tag)); tag = git__malloc(sizeof(struct possible_tag));
GITERR_CHECK_ALLOC(tag); GIT_ERROR_CHECK_ALLOC(tag);
memcpy(tag, in, sizeof(struct possible_tag)); memcpy(tag, in, sizeof(struct possible_tag));
tag->name = NULL; tag->name = NULL;
...@@ -335,14 +335,14 @@ static int display_name(git_buf *buf, git_repository *repo, struct commit_name * ...@@ -335,14 +335,14 @@ static int display_name(git_buf *buf, git_repository *repo, struct commit_name *
{ {
if (n->prio == 2 && !n->tag) { if (n->prio == 2 && !n->tag) {
if (git_tag_lookup(&n->tag, repo, &n->sha1) < 0) { if (git_tag_lookup(&n->tag, repo, &n->sha1) < 0) {
giterr_set(GITERR_TAG, "annotated tag '%s' not available", n->path); git_error_set(GIT_ERROR_TAG, "annotated tag '%s' not available", n->path);
return -1; return -1;
} }
} }
if (n->tag && !n->name_checked) { if (n->tag && !n->name_checked) {
if (!git_tag_name(n->tag)) { if (!git_tag_name(n->tag)) {
giterr_set(GITERR_TAG, "annotated tag '%s' has no embedded name", n->path); git_error_set(GIT_ERROR_TAG, "annotated tag '%s' has no embedded name", n->path);
return -1; return -1;
} }
...@@ -425,7 +425,7 @@ static int describe_not_found(const git_oid *oid, const char *message_format) { ...@@ -425,7 +425,7 @@ static int describe_not_found(const git_oid *oid, const char *message_format) {
char oid_str[GIT_OID_HEXSZ + 1]; char oid_str[GIT_OID_HEXSZ + 1];
git_oid_tostr(oid_str, sizeof(oid_str), oid); git_oid_tostr(oid_str, sizeof(oid_str), oid);
giterr_set(GITERR_DESCRIBE, message_format, oid_str); git_error_set(GIT_ERROR_DESCRIBE, message_format, oid_str);
return GIT_ENOTFOUND; return GIT_ENOTFOUND;
} }
...@@ -504,7 +504,7 @@ static int describe( ...@@ -504,7 +504,7 @@ static int describe(
unannotated_cnt++; unannotated_cnt++;
} else if (match_cnt < data->opts->max_candidates_tags) { } else if (match_cnt < data->opts->max_candidates_tags) {
struct possible_tag *t = git__malloc(sizeof(struct commit_name)); struct possible_tag *t = git__malloc(sizeof(struct commit_name));
GITERR_CHECK_ALLOC(t); GIT_ERROR_CHECK_ALLOC(t);
if ((error = git_vector_insert(&all_matches, t)) < 0) if ((error = git_vector_insert(&all_matches, t)) < 0)
goto cleanup; goto cleanup;
...@@ -667,7 +667,7 @@ int git_describe_commit( ...@@ -667,7 +667,7 @@ int git_describe_commit(
assert(committish); assert(committish);
data.result = git__calloc(1, sizeof(git_describe_result)); data.result = git__calloc(1, sizeof(git_describe_result));
GITERR_CHECK_ALLOC(data.result); GIT_ERROR_CHECK_ALLOC(data.result);
data.result->repo = git_object_owner(committish); data.result->repo = git_object_owner(committish);
data.repo = git_object_owner(committish); data.repo = git_object_owner(committish);
...@@ -675,14 +675,14 @@ int git_describe_commit( ...@@ -675,14 +675,14 @@ int git_describe_commit(
if ((error = normalize_options(&normalized, opts)) < 0) if ((error = normalize_options(&normalized, opts)) < 0)
return error; return error;
GITERR_CHECK_VERSION( GIT_ERROR_CHECK_VERSION(
&normalized, &normalized,
GIT_DESCRIBE_OPTIONS_VERSION, GIT_DESCRIBE_OPTIONS_VERSION,
"git_describe_options"); "git_describe_options");
data.opts = &normalized; data.opts = &normalized;
data.names = git_oidmap_alloc(); data.names = git_oidmap_alloc();
GITERR_CHECK_ALLOC(data.names); GIT_ERROR_CHECK_ALLOC(data.names);
/** TODO: contains to be implemented */ /** TODO: contains to be implemented */
...@@ -695,7 +695,7 @@ int git_describe_commit( ...@@ -695,7 +695,7 @@ int git_describe_commit(
goto cleanup; goto cleanup;
if (git_oidmap_size(data.names) == 0 && !opts->show_commit_oid_as_fallback) { if (git_oidmap_size(data.names) == 0 && !opts->show_commit_oid_as_fallback) {
giterr_set(GITERR_DESCRIBE, "cannot describe - " git_error_set(GIT_ERROR_DESCRIBE, "cannot describe - "
"no reference found, cannot describe anything."); "no reference found, cannot describe anything.");
error = -1; error = -1;
goto cleanup; goto cleanup;
...@@ -786,14 +786,14 @@ int git_describe_format(git_buf *out, const git_describe_result *result, const g ...@@ -786,14 +786,14 @@ int git_describe_format(git_buf *out, const git_describe_result *result, const g
assert(out && result); assert(out && result);
GITERR_CHECK_VERSION(given, GIT_DESCRIBE_FORMAT_OPTIONS_VERSION, "git_describe_format_options"); GIT_ERROR_CHECK_VERSION(given, GIT_DESCRIBE_FORMAT_OPTIONS_VERSION, "git_describe_format_options");
normalize_format_options(&opts, given); normalize_format_options(&opts, given);
git_buf_sanitize(out); git_buf_sanitize(out);
if (opts.always_use_long_format && opts.abbreviated_size == 0) { if (opts.always_use_long_format && opts.abbreviated_size == 0) {
giterr_set(GITERR_DESCRIBE, "cannot describe - " git_error_set(GIT_ERROR_DESCRIBE, "cannot describe - "
"'always_use_long_format' is incompatible with a zero" "'always_use_long_format' is incompatible with a zero"
"'abbreviated_size'"); "'abbreviated_size'");
return -1; return -1;
......
...@@ -114,7 +114,7 @@ int git_diff_is_sorted_icase(const git_diff *diff) ...@@ -114,7 +114,7 @@ int git_diff_is_sorted_icase(const git_diff *diff)
int git_diff_get_perfdata(git_diff_perfdata *out, const git_diff *diff) int git_diff_get_perfdata(git_diff_perfdata *out, const git_diff *diff)
{ {
assert(out); assert(out);
GITERR_CHECK_VERSION(out, GIT_DIFF_PERFDATA_VERSION, "git_diff_perfdata"); GIT_ERROR_CHECK_VERSION(out, GIT_DIFF_PERFDATA_VERSION, "git_diff_perfdata");
out->stat_calls = diff->perf.stat_calls; out->stat_calls = diff->perf.stat_calls;
out->oid_calculations = diff->perf.oid_calculations; out->oid_calculations = diff->perf.oid_calculations;
return 0; return 0;
...@@ -251,7 +251,7 @@ int git_diff_format_email( ...@@ -251,7 +251,7 @@ int git_diff_format_email(
assert(out && diff && opts); assert(out && diff && opts);
assert(opts->summary && opts->id && opts->author); assert(opts->summary && opts->id && opts->author);
GITERR_CHECK_VERSION(opts, GIT_ERROR_CHECK_VERSION(opts,
GIT_DIFF_FORMAT_EMAIL_OPTIONS_VERSION, GIT_DIFF_FORMAT_EMAIL_OPTIONS_VERSION,
"git_format_email_options"); "git_format_email_options");
...@@ -260,14 +260,14 @@ int git_diff_format_email( ...@@ -260,14 +260,14 @@ int git_diff_format_email(
if (!ignore_marker) { if (!ignore_marker) {
if (opts->patch_no > opts->total_patches) { if (opts->patch_no > opts->total_patches) {
giterr_set(GITERR_INVALID, git_error_set(GIT_ERROR_INVALID,
"patch %"PRIuZ" out of range. max %"PRIuZ, "patch %"PRIuZ" out of range. max %"PRIuZ,
opts->patch_no, opts->total_patches); opts->patch_no, opts->total_patches);
return -1; return -1;
} }
if (opts->patch_no == 0) { if (opts->patch_no == 0) {
giterr_set(GITERR_INVALID, git_error_set(GIT_ERROR_INVALID,
"invalid patch no %"PRIuZ". should be >0", opts->patch_no); "invalid patch no %"PRIuZ". should be >0", opts->patch_no);
return -1; return -1;
} }
...@@ -280,14 +280,14 @@ int git_diff_format_email( ...@@ -280,14 +280,14 @@ int git_diff_format_email(
size_t offset = 0; size_t offset = 0;
if ((offset = (loc - opts->summary)) == 0) { if ((offset = (loc - opts->summary)) == 0) {
giterr_set(GITERR_INVALID, "summary is empty"); git_error_set(GIT_ERROR_INVALID, "summary is empty");
error = -1; error = -1;
goto on_error; goto on_error;
} }
GITERR_CHECK_ALLOC_ADD(&allocsize, offset, 1); GIT_ERROR_CHECK_ALLOC_ADD(&allocsize, offset, 1);
summary = git__calloc(allocsize, sizeof(char)); summary = git__calloc(allocsize, sizeof(char));
GITERR_CHECK_ALLOC(summary); GIT_ERROR_CHECK_ALLOC(summary);
strncpy(summary, opts->summary, offset); strncpy(summary, opts->summary, offset);
} }
...@@ -466,7 +466,7 @@ static int line_cb( ...@@ -466,7 +466,7 @@ static int line_cb(
case GIT_DIFF_LINE_CONTEXT: case GIT_DIFF_LINE_CONTEXT:
break; break;
default: default:
giterr_set(GITERR_PATCH, "invalid line origin for patch"); git_error_set(GIT_ERROR_PATCH, "invalid line origin for patch");
return -1; return -1;
} }
...@@ -493,7 +493,7 @@ int git_diff_patchid(git_oid *out, git_diff *diff, git_diff_patchid_options *opt ...@@ -493,7 +493,7 @@ int git_diff_patchid(git_oid *out, git_diff *diff, git_diff_patchid_options *opt
struct patch_id_args args; struct patch_id_args args;
int error; int error;
GITERR_CHECK_VERSION( GIT_ERROR_CHECK_VERSION(
opts, GIT_DIFF_PATCHID_OPTIONS_VERSION, "git_diff_patchid_options"); opts, GIT_DIFF_PATCHID_OPTIONS_VERSION, "git_diff_patchid_options");
memset(&args, 0, sizeof(args)); memset(&args, 0, sizeof(args));
......
...@@ -149,7 +149,7 @@ static git_diff_driver_registry *git_repository_driver_registry( ...@@ -149,7 +149,7 @@ static git_diff_driver_registry *git_repository_driver_registry(
} }
if (!repo->diff_drivers) if (!repo->diff_drivers)
giterr_set(GITERR_REPOSITORY, "unable to create diff driver registry"); git_error_set(GIT_ERROR_REPOSITORY, "unable to create diff driver registry");
return repo->diff_drivers; return repo->diff_drivers;
} }
...@@ -162,11 +162,11 @@ static int diff_driver_alloc( ...@@ -162,11 +162,11 @@ static int diff_driver_alloc(
namelen = strlen(name), namelen = strlen(name),
alloclen; alloclen;
GITERR_CHECK_ALLOC_ADD(&alloclen, driverlen, namelen); GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, driverlen, namelen);
GITERR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1); GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1);
driver = git__calloc(1, alloclen); driver = git__calloc(1, alloclen);
GITERR_CHECK_ALLOC(driver); GIT_ERROR_CHECK_ALLOC(driver);
memcpy(driver->name, name, namelen); memcpy(driver->name, name, namelen);
...@@ -211,7 +211,7 @@ static int git_diff_driver_builtin( ...@@ -211,7 +211,7 @@ static int git_diff_driver_builtin(
(error = p_regcomp( (error = p_regcomp(
&drv->word_pattern, ddef->words, ddef->flags | REG_EXTENDED))) &drv->word_pattern, ddef->words, ddef->flags | REG_EXTENDED)))
{ {
error = giterr_set_regex(&drv->word_pattern, error); error = git_error_set_regex(&drv->word_pattern, error);
goto done; goto done;
} }
...@@ -256,7 +256,7 @@ static int git_diff_driver_load( ...@@ -256,7 +256,7 @@ static int git_diff_driver_load(
/* if you can't read config for repo, just use default driver */ /* if you can't read config for repo, just use default driver */
if (git_repository_config_snapshot(&cfg, repo) < 0) { if (git_repository_config_snapshot(&cfg, repo) < 0) {
giterr_clear(); git_error_clear();
goto done; goto done;
} }
...@@ -287,7 +287,7 @@ static int git_diff_driver_load( ...@@ -287,7 +287,7 @@ static int git_diff_driver_load(
cfg, name.ptr, NULL, diff_driver_xfuncname, drv)) < 0) { cfg, name.ptr, NULL, diff_driver_xfuncname, drv)) < 0) {
if (error != GIT_ENOTFOUND) if (error != GIT_ENOTFOUND)
goto done; goto done;
giterr_clear(); /* no diff.<driver>.xfuncname, so just continue */ git_error_clear(); /* no diff.<driver>.xfuncname, so just continue */
} }
git_buf_truncate(&name, namelen + strlen("diff..")); git_buf_truncate(&name, namelen + strlen("diff.."));
...@@ -296,7 +296,7 @@ static int git_diff_driver_load( ...@@ -296,7 +296,7 @@ static int git_diff_driver_load(
cfg, name.ptr, NULL, diff_driver_funcname, drv)) < 0) { cfg, name.ptr, NULL, diff_driver_funcname, drv)) < 0) {
if (error != GIT_ENOTFOUND) if (error != GIT_ENOTFOUND)
goto done; goto done;
giterr_clear(); /* no diff.<driver>.funcname, so just continue */ git_error_clear(); /* no diff.<driver>.funcname, so just continue */
} }
/* if we found any patterns, set driver type to use correct callback */ /* if we found any patterns, set driver type to use correct callback */
...@@ -315,7 +315,7 @@ static int git_diff_driver_load( ...@@ -315,7 +315,7 @@ static int git_diff_driver_load(
found_driver = true; found_driver = true;
else { else {
/* TODO: warn about bad regex instead of failure */ /* TODO: warn about bad regex instead of failure */
error = giterr_set_regex(&drv->word_pattern, error); error = git_error_set_regex(&drv->word_pattern, error);
goto done; goto done;
} }
...@@ -379,7 +379,7 @@ int git_diff_driver_lookup( ...@@ -379,7 +379,7 @@ int git_diff_driver_lookup(
else if ((error = git_diff_driver_load(out, repo, values[0])) < 0) { else if ((error = git_diff_driver_load(out, repo, values[0])) < 0) {
if (error == GIT_ENOTFOUND) { if (error == GIT_ENOTFOUND) {
error = 0; error = 0;
giterr_clear(); git_error_clear();
} }
} }
......
...@@ -188,7 +188,7 @@ static int diff_file_content_commit_to_str( ...@@ -188,7 +188,7 @@ static int diff_file_content_commit_to_str(
if ((error = git_submodule_lookup(&sm, fc->repo, fc->file->path)) < 0) { if ((error = git_submodule_lookup(&sm, fc->repo, fc->file->path)) < 0) {
/* GIT_EEXISTS means a "submodule" that has not been git added */ /* GIT_EEXISTS means a "submodule" that has not been git added */
if (error == GIT_EEXISTS) { if (error == GIT_EEXISTS) {
giterr_clear(); git_error_clear();
error = 0; error = 0;
} }
return error; return error;
...@@ -303,13 +303,13 @@ static int diff_file_content_load_workdir_symlink( ...@@ -303,13 +303,13 @@ static int diff_file_content_load_workdir_symlink(
alloc_len = (ssize_t)(fc->file->size * 2) + 1; alloc_len = (ssize_t)(fc->file->size * 2) + 1;
fc->map.data = git__calloc(alloc_len, sizeof(char)); fc->map.data = git__calloc(alloc_len, sizeof(char));
GITERR_CHECK_ALLOC(fc->map.data); GIT_ERROR_CHECK_ALLOC(fc->map.data);
fc->flags |= GIT_DIFF_FLAG__FREE_DATA; fc->flags |= GIT_DIFF_FLAG__FREE_DATA;
read_len = p_readlink(git_buf_cstr(path), fc->map.data, alloc_len); read_len = p_readlink(git_buf_cstr(path), fc->map.data, alloc_len);
if (read_len < 0) { if (read_len < 0) {
giterr_set(GITERR_OS, "failed to read symlink '%s'", fc->file->path); git_error_set(GIT_ERROR_OS, "failed to read symlink '%s'", fc->file->path);
return -1; return -1;
} }
...@@ -352,7 +352,7 @@ static int diff_file_content_load_workdir_file( ...@@ -352,7 +352,7 @@ static int diff_file_content_load_workdir_file(
} }
/* if mmap failed, fall through to try readbuffer below */ /* if mmap failed, fall through to try readbuffer below */
giterr_clear(); git_error_clear();
} }
if (!(error = git_futils_readbuffer_fd(&raw, fd, (size_t)fc->file->size))) { if (!(error = git_futils_readbuffer_fd(&raw, fd, (size_t)fc->file->size))) {
......
...@@ -81,7 +81,7 @@ static int diff_insert_delta( ...@@ -81,7 +81,7 @@ static int diff_insert_delta(
if (error > 0) /* positive value means to skip this delta */ if (error > 0) /* positive value means to skip this delta */
return 0; return 0;
else /* negative value means to cancel diff */ else /* negative value means to cancel diff */
return giterr_set_after_callback_function(error, "git_diff"); return git_error_set_after_callback_function(error, "git_diff");
} }
} }
...@@ -157,7 +157,7 @@ static int diff_delta__from_one( ...@@ -157,7 +157,7 @@ static int diff_delta__from_one(
return 0; return 0;
delta = diff_delta__alloc(diff, status, entry->path); delta = diff_delta__alloc(diff, status, entry->path);
GITERR_CHECK_ALLOC(delta); GIT_ERROR_CHECK_ALLOC(delta);
/* This fn is just for single-sided diffs */ /* This fn is just for single-sided diffs */
assert(status != GIT_DELTA_MODIFIED); assert(status != GIT_DELTA_MODIFIED);
...@@ -220,7 +220,7 @@ static int diff_delta__from_two( ...@@ -220,7 +220,7 @@ static int diff_delta__from_two(
} }
delta = diff_delta__alloc(diff, status, canonical_path); delta = diff_delta__alloc(diff, status, canonical_path);
GITERR_CHECK_ALLOC(delta); GIT_ERROR_CHECK_ALLOC(delta);
delta->nfiles = 2; delta->nfiles = 2;
if (!git_index_entry_is_conflict(old_entry)) { if (!git_index_entry_is_conflict(old_entry)) {
...@@ -517,7 +517,7 @@ static int diff_generated_apply_options( ...@@ -517,7 +517,7 @@ static int diff_generated_apply_options(
if (entry && git_submodule_parse_ignore( if (entry && git_submodule_parse_ignore(
&diff->base.opts.ignore_submodules, entry->value) < 0) &diff->base.opts.ignore_submodules, entry->value) < 0)
giterr_clear(); git_error_clear();
git_config_entry_free(entry); git_config_entry_free(entry);
} }
...@@ -622,13 +622,13 @@ int git_diff__oid_for_entry( ...@@ -622,13 +622,13 @@ int git_diff__oid_for_entry(
/* if submodule lookup failed probably just in an intermediate /* if submodule lookup failed probably just in an intermediate
* state where some init hasn't happened, so ignore the error * state where some init hasn't happened, so ignore the error
*/ */
giterr_clear(); git_error_clear();
} }
} else if (S_ISLNK(mode)) { } else if (S_ISLNK(mode)) {
error = git_odb__hashlink(out, full_path.ptr); error = git_odb__hashlink(out, full_path.ptr);
diff->base.perf.oid_calculations++; diff->base.perf.oid_calculations++;
} else if (!git__is_sizet(entry.file_size)) { } else if (!git__is_sizet(entry.file_size)) {
giterr_set(GITERR_OS, "file size overflow (for 32-bits) on '%s'", git_error_set(GIT_ERROR_OS, "file size overflow (for 32-bits) on '%s'",
entry.path); entry.path);
error = -1; error = -1;
} else if (!(error = git_filter_list_load(&fl, } else if (!(error = git_filter_list_load(&fl,
...@@ -700,7 +700,7 @@ static int maybe_modified_submodule( ...@@ -700,7 +700,7 @@ static int maybe_modified_submodule(
/* GIT_EEXISTS means dir with .git in it was found - ignore it */ /* GIT_EEXISTS means dir with .git in it was found - ignore it */
if (error == GIT_EEXISTS) { if (error == GIT_EEXISTS) {
giterr_clear(); git_error_clear();
error = 0; error = 0;
} }
return error; return error;
...@@ -1060,7 +1060,7 @@ static int handle_unmatched_new_item( ...@@ -1060,7 +1060,7 @@ static int handle_unmatched_new_item(
/* if directory is empty, can't advance into it, so skip it */ /* if directory is empty, can't advance into it, so skip it */
if (error == GIT_ENOTFOUND) { if (error == GIT_ENOTFOUND) {
giterr_clear(); git_error_clear();
error = iterator_advance(&info->nitem, info->new_iter); error = iterator_advance(&info->nitem, info->new_iter);
} }
...@@ -1082,7 +1082,7 @@ static int handle_unmatched_new_item( ...@@ -1082,7 +1082,7 @@ static int handle_unmatched_new_item(
else if (nitem->mode == GIT_FILEMODE_COMMIT) { else if (nitem->mode == GIT_FILEMODE_COMMIT) {
/* ignore things that are not actual submodules */ /* ignore things that are not actual submodules */
if (git_submodule_lookup(NULL, info->repo, nitem->path) != 0) { if (git_submodule_lookup(NULL, info->repo, nitem->path) != 0) {
giterr_clear(); git_error_clear();
delta_type = GIT_DELTA_IGNORED; delta_type = GIT_DELTA_IGNORED;
/* if this contains a tracked item, treat as normal TREE */ /* if this contains a tracked item, treat as normal TREE */
...@@ -1091,7 +1091,7 @@ static int handle_unmatched_new_item( ...@@ -1091,7 +1091,7 @@ static int handle_unmatched_new_item(
if (error != GIT_ENOTFOUND) if (error != GIT_ENOTFOUND)
return error; return error;
giterr_clear(); git_error_clear();
return iterator_advance(&info->nitem, info->new_iter); return iterator_advance(&info->nitem, info->new_iter);
} }
} }
...@@ -1192,7 +1192,7 @@ int git_diff__from_iterators( ...@@ -1192,7 +1192,7 @@ int git_diff__from_iterators(
*out = NULL; *out = NULL;
diff = diff_generated_alloc(repo, old_iter, new_iter); diff = diff_generated_alloc(repo, old_iter, new_iter);
GITERR_CHECK_ALLOC(diff); GIT_ERROR_CHECK_ALLOC(diff);
info.repo = repo; info.repo = repo;
info.old_iter = old_iter; info.old_iter = old_iter;
...@@ -1269,7 +1269,7 @@ cleanup: ...@@ -1269,7 +1269,7 @@ cleanup:
b_opts.flags = FLAGS_SECOND; \ b_opts.flags = FLAGS_SECOND; \
b_opts.start = pfx; \ b_opts.start = pfx; \
b_opts.end = pfx; \ b_opts.end = pfx; \
GITERR_CHECK_VERSION(opts, GIT_DIFF_OPTIONS_VERSION, "git_diff_options"); \ GIT_ERROR_CHECK_VERSION(opts, GIT_DIFF_OPTIONS_VERSION, "git_diff_options"); \
if (opts && (opts->flags & GIT_DIFF_DISABLE_PATHSPEC_MATCH)) { \ if (opts && (opts->flags & GIT_DIFF_DISABLE_PATHSPEC_MATCH)) { \
a_opts.pathlist.strings = opts->pathspec.strings; \ a_opts.pathlist.strings = opts->pathspec.strings; \
a_opts.pathlist.count = opts->pathspec.count; \ a_opts.pathlist.count = opts->pathspec.count; \
...@@ -1320,7 +1320,7 @@ static int diff_load_index(git_index **index, git_repository *repo) ...@@ -1320,7 +1320,7 @@ static int diff_load_index(git_index **index, git_repository *repo)
/* reload the repository index when user did not pass one in */ /* reload the repository index when user did not pass one in */
if (!error && git_index_read(*index, false) < 0) if (!error && git_index_read(*index, false) < 0)
giterr_clear(); git_error_clear();
return error; return error;
} }
...@@ -1552,7 +1552,7 @@ int git_diff__paired_foreach( ...@@ -1552,7 +1552,7 @@ int git_diff__paired_foreach(
} }
if ((error = cb(h2i, i2w, payload)) != 0) { if ((error = cb(h2i, i2w, payload)) != 0) {
giterr_set_after_callback(error); git_error_set_after_callback(error);
break; break;
} }
} }
...@@ -1591,7 +1591,7 @@ int git_diff__commit( ...@@ -1591,7 +1591,7 @@ int git_diff__commit(
char commit_oidstr[GIT_OID_HEXSZ + 1]; char commit_oidstr[GIT_OID_HEXSZ + 1];
error = -1; error = -1;
giterr_set(GITERR_INVALID, "commit %s is a merge commit", git_error_set(GIT_ERROR_INVALID, "commit %s is a merge commit",
git_oid_tostr(commit_oidstr, GIT_OID_HEXSZ + 1, git_commit_id(commit))); git_oid_tostr(commit_oidstr, GIT_OID_HEXSZ + 1, git_commit_id(commit)));
goto on_error; goto on_error;
} }
......
...@@ -78,10 +78,10 @@ int git_diff_from_buffer( ...@@ -78,10 +78,10 @@ int git_diff_from_buffer(
*out = NULL; *out = NULL;
diff = diff_parsed_alloc(); diff = diff_parsed_alloc();
GITERR_CHECK_ALLOC(diff); GIT_ERROR_CHECK_ALLOC(diff);
ctx = git_patch_parse_ctx_init(content, content_len, NULL); ctx = git_patch_parse_ctx_init(content, content_len, NULL);
GITERR_CHECK_ALLOC(ctx); GIT_ERROR_CHECK_ALLOC(ctx);
while (ctx->parse_ctx.remain_len) { while (ctx->parse_ctx.remain_len) {
if ((error = git_patch_parse(&patch, ctx)) < 0) if ((error = git_patch_parse(&patch, ctx)) < 0)
...@@ -92,7 +92,7 @@ int git_diff_from_buffer( ...@@ -92,7 +92,7 @@ int git_diff_from_buffer(
} }
if (error == GIT_ENOTFOUND && git_vector_length(&diff->patches) > 0) { if (error == GIT_ENOTFOUND && git_vector_length(&diff->patches) > 0) {
giterr_clear(); git_error_clear();
error = 0; error = 0;
} }
......
...@@ -224,7 +224,7 @@ static int diff_print_one_raw( ...@@ -224,7 +224,7 @@ static int diff_print_one_raw(
delta->new_file.id_abbrev; delta->new_file.id_abbrev;
if (pi->id_strlen > id_abbrev) { if (pi->id_strlen > id_abbrev) {
giterr_set(GITERR_PATCH, git_error_set(GIT_ERROR_PATCH,
"the patch input contains %d id characters (cannot print %d)", "the patch input contains %d id characters (cannot print %d)",
id_abbrev, pi->id_strlen); id_abbrev, pi->id_strlen);
return -1; return -1;
...@@ -275,7 +275,7 @@ static int diff_print_oid_range( ...@@ -275,7 +275,7 @@ static int diff_print_oid_range(
if (delta->old_file.mode && if (delta->old_file.mode &&
id_strlen > delta->old_file.id_abbrev) { id_strlen > delta->old_file.id_abbrev) {
giterr_set(GITERR_PATCH, git_error_set(GIT_ERROR_PATCH,
"the patch input contains %d id characters (cannot print %d)", "the patch input contains %d id characters (cannot print %d)",
delta->old_file.id_abbrev, id_strlen); delta->old_file.id_abbrev, id_strlen);
return -1; return -1;
...@@ -283,7 +283,7 @@ static int diff_print_oid_range( ...@@ -283,7 +283,7 @@ static int diff_print_oid_range(
if ((delta->new_file.mode && if ((delta->new_file.mode &&
id_strlen > delta->new_file.id_abbrev)) { id_strlen > delta->new_file.id_abbrev)) {
giterr_set(GITERR_PATCH, git_error_set(GIT_ERROR_PATCH,
"the patch input contains %d id characters (cannot print %d)", "the patch input contains %d id characters (cannot print %d)",
delta->new_file.id_abbrev, id_strlen); delta->new_file.id_abbrev, id_strlen);
return -1; return -1;
...@@ -343,7 +343,7 @@ int diff_delta_format_similarity_header( ...@@ -343,7 +343,7 @@ int diff_delta_format_similarity_header(
int error = 0; int error = 0;
if (delta->similarity > 100) { if (delta->similarity > 100) {
giterr_set(GITERR_PATCH, "invalid similarity %d", delta->similarity); git_error_set(GIT_ERROR_PATCH, "invalid similarity %d", delta->similarity);
error = -1; error = -1;
goto done; goto done;
} }
...@@ -540,7 +540,7 @@ static int diff_print_patch_file_binary( ...@@ -540,7 +540,7 @@ static int diff_print_patch_file_binary(
binary->old_file.datalen, binary->old_file.inflatedlen)) < 0) { binary->old_file.datalen, binary->old_file.inflatedlen)) < 0) {
if (error == GIT_EBUFS) { if (error == GIT_EBUFS) {
giterr_clear(); git_error_clear();
git_buf_truncate(pi->buf, pre_binary_size); git_buf_truncate(pi->buf, pre_binary_size);
return diff_print_patch_file_binary_noshow( return diff_print_patch_file_binary_noshow(
...@@ -683,7 +683,7 @@ int git_diff_print( ...@@ -683,7 +683,7 @@ int git_diff_print(
print_file = diff_print_one_name_status; print_file = diff_print_one_name_status;
break; break;
default: default:
giterr_set(GITERR_INVALID, "unknown diff output format (%d)", format); git_error_set(GIT_ERROR_INVALID, "unknown diff output format (%d)", format);
return -1; return -1;
} }
...@@ -693,7 +693,7 @@ int git_diff_print( ...@@ -693,7 +693,7 @@ int git_diff_print(
diff, print_file, print_binary, print_hunk, print_line, &pi); diff, print_file, print_binary, print_hunk, print_line, &pi);
if (error) /* make sure error message is set */ if (error) /* make sure error message is set */
giterr_set_after_callback_function(error, "git_diff_print"); git_error_set_after_callback_function(error, "git_diff_print");
} }
git_buf_dispose(&buf); git_buf_dispose(&buf);
...@@ -711,7 +711,7 @@ int git_diff_print_callback__to_buf( ...@@ -711,7 +711,7 @@ int git_diff_print_callback__to_buf(
GIT_UNUSED(delta); GIT_UNUSED(hunk); GIT_UNUSED(delta); GIT_UNUSED(hunk);
if (!output) { if (!output) {
giterr_set(GITERR_INVALID, "buffer pointer must be provided"); git_error_set(GIT_ERROR_INVALID, "buffer pointer must be provided");
return -1; return -1;
} }
...@@ -773,7 +773,7 @@ int git_patch_print( ...@@ -773,7 +773,7 @@ int git_patch_print(
&pi); &pi);
if (error) /* make sure error message is set */ if (error) /* make sure error message is set */
giterr_set_after_callback_function(error, "git_patch_print"); git_error_set_after_callback_function(error, "git_patch_print");
} }
git_buf_dispose(&temp); git_buf_dispose(&temp);
......
...@@ -184,7 +184,7 @@ int git_diff_get_stats( ...@@ -184,7 +184,7 @@ int git_diff_get_stats(
assert(out && diff); assert(out && diff);
stats = git__calloc(1, sizeof(git_diff_stats)); stats = git__calloc(1, sizeof(git_diff_stats));
GITERR_CHECK_ALLOC(stats); GIT_ERROR_CHECK_ALLOC(stats);
deltas = git_diff_num_deltas(diff); deltas = git_diff_num_deltas(diff);
......
...@@ -131,7 +131,7 @@ int git_diff__merge( ...@@ -131,7 +131,7 @@ int git_diff__merge(
if (ignore_case != ((from->opts.flags & GIT_DIFF_IGNORE_CASE) != 0) || if (ignore_case != ((from->opts.flags & GIT_DIFF_IGNORE_CASE) != 0) ||
reversed != ((from->opts.flags & GIT_DIFF_REVERSE) != 0)) { reversed != ((from->opts.flags & GIT_DIFF_REVERSE) != 0)) {
giterr_set(GITERR_INVALID, git_error_set(GIT_ERROR_INVALID,
"attempt to merge diffs created with conflicting options"); "attempt to merge diffs created with conflicting options");
return -1; return -1;
} }
...@@ -251,7 +251,7 @@ static int normalize_find_opts( ...@@ -251,7 +251,7 @@ static int normalize_find_opts(
git_config *cfg = NULL; git_config *cfg = NULL;
git_hashsig_option_t hashsig_opts; git_hashsig_option_t hashsig_opts;
GITERR_CHECK_VERSION(given, GIT_DIFF_FIND_OPTIONS_VERSION, "git_diff_find_options"); GIT_ERROR_CHECK_VERSION(given, GIT_DIFF_FIND_OPTIONS_VERSION, "git_diff_find_options");
if (diff->repo != NULL && if (diff->repo != NULL &&
git_repository_config__weakptr(&cfg, diff->repo) < 0) git_repository_config__weakptr(&cfg, diff->repo) < 0)
...@@ -332,7 +332,7 @@ static int normalize_find_opts( ...@@ -332,7 +332,7 @@ static int normalize_find_opts(
/* assign the internal metric with whitespace flag as payload */ /* assign the internal metric with whitespace flag as payload */
if (!opts->metric) { if (!opts->metric) {
opts->metric = git__malloc(sizeof(git_diff_similarity_metric)); opts->metric = git__malloc(sizeof(git_diff_similarity_metric));
GITERR_CHECK_ALLOC(opts->metric); GIT_ERROR_CHECK_ALLOC(opts->metric);
opts->metric->file_signature = git_diff_find_similar__hashsig_for_file; opts->metric->file_signature = git_diff_find_similar__hashsig_for_file;
opts->metric->buffer_signature = git_diff_find_similar__hashsig_for_buf; opts->metric->buffer_signature = git_diff_find_similar__hashsig_for_buf;
...@@ -357,7 +357,7 @@ static int insert_delete_side_of_split( ...@@ -357,7 +357,7 @@ static int insert_delete_side_of_split(
{ {
/* make new record for DELETED side of split */ /* make new record for DELETED side of split */
git_diff_delta *deleted = git_diff__delta_dup(delta, &diff->pool); git_diff_delta *deleted = git_diff__delta_dup(delta, &diff->pool);
GITERR_CHECK_ALLOC(deleted); GIT_ERROR_CHECK_ALLOC(deleted);
deleted->status = GIT_DELTA_DELETED; deleted->status = GIT_DELTA_DELETED;
deleted->nfiles = 1; deleted->nfiles = 1;
...@@ -502,7 +502,7 @@ static int similarity_sig( ...@@ -502,7 +502,7 @@ static int similarity_sig(
if (error < 0) { if (error < 0) {
/* if lookup fails, just skip this item in similarity calc */ /* if lookup fails, just skip this item in similarity calc */
giterr_clear(); git_error_clear();
} else { } else {
size_t sz; size_t sz;
...@@ -831,9 +831,9 @@ int git_diff_find_similar( ...@@ -831,9 +831,9 @@ int git_diff_find_similar(
if ((opts.flags & GIT_DIFF_FIND_ALL) == 0) if ((opts.flags & GIT_DIFF_FIND_ALL) == 0)
goto cleanup; goto cleanup;
GITERR_CHECK_ALLOC_MULTIPLY(&sigcache_size, num_deltas, 2); GIT_ERROR_CHECK_ALLOC_MULTIPLY(&sigcache_size, num_deltas, 2);
sigcache = git__calloc(sigcache_size, sizeof(void *)); sigcache = git__calloc(sigcache_size, sizeof(void *));
GITERR_CHECK_ALLOC(sigcache); GIT_ERROR_CHECK_ALLOC(sigcache);
/* Label rename sources and targets /* Label rename sources and targets
* *
...@@ -856,13 +856,13 @@ int git_diff_find_similar( ...@@ -856,13 +856,13 @@ int git_diff_find_similar(
goto cleanup; goto cleanup;
src2tgt = git__calloc(num_deltas, sizeof(diff_find_match)); src2tgt = git__calloc(num_deltas, sizeof(diff_find_match));
GITERR_CHECK_ALLOC(src2tgt); GIT_ERROR_CHECK_ALLOC(src2tgt);
tgt2src = git__calloc(num_deltas, sizeof(diff_find_match)); tgt2src = git__calloc(num_deltas, sizeof(diff_find_match));
GITERR_CHECK_ALLOC(tgt2src); GIT_ERROR_CHECK_ALLOC(tgt2src);
if (FLAG_SET(&opts, GIT_DIFF_FIND_COPIES)) { if (FLAG_SET(&opts, GIT_DIFF_FIND_COPIES)) {
tgt2src_copy = git__calloc(num_deltas, sizeof(diff_find_match)); tgt2src_copy = git__calloc(num_deltas, sizeof(diff_find_match));
GITERR_CHECK_ALLOC(tgt2src_copy); GIT_ERROR_CHECK_ALLOC(tgt2src_copy);
} }
/* /*
......
...@@ -52,7 +52,7 @@ static int git_xdiff_parse_hunk(git_diff_hunk *hunk, const char *header) ...@@ -52,7 +52,7 @@ static int git_xdiff_parse_hunk(git_diff_hunk *hunk, const char *header)
return 0; return 0;
fail: fail:
giterr_set(GITERR_INVALID, "malformed hunk header from xdiff"); git_error_set(GIT_ERROR_INVALID, "malformed hunk header from xdiff");
return -1; return -1;
} }
...@@ -101,7 +101,7 @@ static int diff_update_lines( ...@@ -101,7 +101,7 @@ static int diff_update_lines(
info->new_lineno += (int)line->num_lines; info->new_lineno += (int)line->num_lines;
break; break;
default: default:
giterr_set(GITERR_INVALID, "unknown diff line origin %02x", git_error_set(GIT_ERROR_INVALID, "unknown diff line origin %02x",
(unsigned int)line->origin); (unsigned int)line->origin);
return -1; return -1;
} }
...@@ -224,7 +224,7 @@ static int git_xdiff(git_patch_generated_output *output, git_patch_generated *pa ...@@ -224,7 +224,7 @@ static int git_xdiff(git_patch_generated_output *output, git_patch_generated *pa
if (info.xd_old_data.size > GIT_XDIFF_MAX_SIZE || if (info.xd_old_data.size > GIT_XDIFF_MAX_SIZE ||
info.xd_new_data.size > GIT_XDIFF_MAX_SIZE) { info.xd_new_data.size > GIT_XDIFF_MAX_SIZE) {
giterr_set(GITERR_INVALID, "files too large for diff"); git_error_set(GIT_ERROR_INVALID, "files too large for diff");
return -1; return -1;
} }
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
static git_error g_git_oom_error = { static git_error g_git_oom_error = {
"Out of memory", "Out of memory",
GITERR_NOMEMORY GIT_ERROR_NOMEMORY
}; };
static void set_error_from_buffer(int error_class) static void set_error_from_buffer(int error_class)
...@@ -49,13 +49,13 @@ void git_error_set_oom(void) ...@@ -49,13 +49,13 @@ void git_error_set_oom(void)
GIT_GLOBAL->last_error = &g_git_oom_error; GIT_GLOBAL->last_error = &g_git_oom_error;
} }
void giterr_set(int error_class, const char *string, ...) void git_error_set(int error_class, const char *string, ...)
{ {
va_list arglist; va_list arglist;
#ifdef GIT_WIN32 #ifdef GIT_WIN32
DWORD win32_error_code = (error_class == GITERR_OS) ? GetLastError() : 0; DWORD win32_error_code = (error_class == GIT_ERROR_OS) ? GetLastError() : 0;
#endif #endif
int error_code = (error_class == GITERR_OS) ? errno : 0; int error_code = (error_class == GIT_ERROR_OS) ? errno : 0;
git_buf *buf = &GIT_GLOBAL->error_buf; git_buf *buf = &GIT_GLOBAL->error_buf;
git_buf_clear(buf); git_buf_clear(buf);
...@@ -64,11 +64,11 @@ void giterr_set(int error_class, const char *string, ...) ...@@ -64,11 +64,11 @@ void giterr_set(int error_class, const char *string, ...)
git_buf_vprintf(buf, string, arglist); git_buf_vprintf(buf, string, arglist);
va_end(arglist); va_end(arglist);
if (error_class == GITERR_OS) if (error_class == GIT_ERROR_OS)
git_buf_PUTS(buf, ": "); git_buf_PUTS(buf, ": ");
} }
if (error_class == GITERR_OS) { if (error_class == GIT_ERROR_OS) {
#ifdef GIT_WIN32 #ifdef GIT_WIN32
char * win32_error = git_win32_get_error_message(win32_error_code); char * win32_error = git_win32_get_error_message(win32_error_code);
if (win32_error) { if (win32_error) {
...@@ -105,14 +105,14 @@ void git_error_set_str(int error_class, const char *string) ...@@ -105,14 +105,14 @@ void git_error_set_str(int error_class, const char *string)
set_error_from_buffer(error_class); set_error_from_buffer(error_class);
} }
int giterr_set_regex(const regex_t *regex, int error_code) int git_error_set_regex(const regex_t *regex, int error_code)
{ {
char error_buf[1024]; char error_buf[1024];
assert(error_code); assert(error_code);
regerror(error_code, regex, error_buf, sizeof(error_buf)); regerror(error_code, regex, error_buf, sizeof(error_buf));
giterr_set_str(GITERR_REGEX, error_buf); git_error_set_str(GIT_ERROR_REGEX, error_buf);
if (error_code == REG_NOMATCH) if (error_code == REG_NOMATCH)
return GIT_ENOTFOUND; return GIT_ENOTFOUND;
...@@ -138,7 +138,7 @@ const git_error *git_error_last(void) ...@@ -138,7 +138,7 @@ const git_error *git_error_last(void)
return GIT_GLOBAL->last_error; return GIT_GLOBAL->last_error;
} }
int giterr_state_capture(git_error_state *state, int error_code) int git_error_state_capture(git_error_state *state, int error_code)
{ {
git_error *error = GIT_GLOBAL->last_error; git_error *error = GIT_GLOBAL->last_error;
git_buf *error_buf = &GIT_GLOBAL->error_buf; git_buf *error_buf = &GIT_GLOBAL->error_buf;
...@@ -160,19 +160,19 @@ int giterr_state_capture(git_error_state *state, int error_code) ...@@ -160,19 +160,19 @@ int giterr_state_capture(git_error_state *state, int error_code)
state->error_msg.message = git_buf_detach(error_buf); state->error_msg.message = git_buf_detach(error_buf);
} }
giterr_clear(); git_error_clear();
return error_code; return error_code;
} }
int giterr_state_restore(git_error_state *state) int git_error_state_restore(git_error_state *state)
{ {
int ret = 0; int ret = 0;
giterr_clear(); git_error_clear();
if (state && state->error_msg.message) { if (state && state->error_msg.message) {
if (state->oom) if (state->oom)
giterr_set_oom(); git_error_set_oom();
else else
set_error(state->error_msg.klass, state->error_msg.message); set_error(state->error_msg.klass, state->error_msg.message);
...@@ -183,7 +183,7 @@ int giterr_state_restore(git_error_state *state) ...@@ -183,7 +183,7 @@ int giterr_state_restore(git_error_state *state)
return ret; return ret;
} }
void giterr_state_free(git_error_state *state) void git_error_state_free(git_error_state *state)
{ {
if (!state) if (!state)
return; return;
...@@ -194,7 +194,7 @@ void giterr_state_free(git_error_state *state) ...@@ -194,7 +194,7 @@ void giterr_state_free(git_error_state *state)
memset(state, 0, sizeof(git_error_state)); memset(state, 0, sizeof(git_error_state));
} }
int giterr_system_last(void) int git_error_system_last(void)
{ {
#ifdef GIT_WIN32 #ifdef GIT_WIN32
return GetLastError(); return GetLastError();
...@@ -203,7 +203,7 @@ int giterr_system_last(void) ...@@ -203,7 +203,7 @@ int giterr_system_last(void)
#endif #endif
} }
void giterr_system_set(int code) void git_error_system_set(int code)
{ {
#ifdef GIT_WIN32 #ifdef GIT_WIN32
SetLastError(code); SetLastError(code);
......
...@@ -113,7 +113,7 @@ int git_fetch_negotiate(git_remote *remote, const git_fetch_options *opts) ...@@ -113,7 +113,7 @@ int git_fetch_negotiate(git_remote *remote, const git_fetch_options *opts)
remote->need_pack = 0; remote->need_pack = 0;
if (filter_wants(remote, opts) < 0) { if (filter_wants(remote, opts) < 0) {
giterr_set(GITERR_NET, "failed to filter the reference list for wants"); git_error_set(GIT_ERROR_NET, "failed to filter the reference list for wants");
return -1; return -1;
} }
......
...@@ -50,7 +50,7 @@ int git_fetchhead_ref_create( ...@@ -50,7 +50,7 @@ int git_fetchhead_ref_create(
*out = NULL; *out = NULL;
fetchhead_ref = git__malloc(sizeof(git_fetchhead_ref)); fetchhead_ref = git__malloc(sizeof(git_fetchhead_ref));
GITERR_CHECK_ALLOC(fetchhead_ref); GIT_ERROR_CHECK_ALLOC(fetchhead_ref);
memset(fetchhead_ref, 0x0, sizeof(git_fetchhead_ref)); memset(fetchhead_ref, 0x0, sizeof(git_fetchhead_ref));
...@@ -148,7 +148,7 @@ static int fetchhead_ref_parse( ...@@ -148,7 +148,7 @@ static int fetchhead_ref_parse(
*remote_url = NULL; *remote_url = NULL;
if (!*line) { if (!*line) {
giterr_set(GITERR_FETCHHEAD, git_error_set(GIT_ERROR_FETCHHEAD,
"empty line in FETCH_HEAD line %"PRIuZ, line_num); "empty line in FETCH_HEAD line %"PRIuZ, line_num);
return -1; return -1;
} }
...@@ -162,16 +162,16 @@ static int fetchhead_ref_parse( ...@@ -162,16 +162,16 @@ static int fetchhead_ref_parse(
} }
if (strlen(oid_str) != GIT_OID_HEXSZ) { if (strlen(oid_str) != GIT_OID_HEXSZ) {
giterr_set(GITERR_FETCHHEAD, git_error_set(GIT_ERROR_FETCHHEAD,
"invalid object ID in FETCH_HEAD line %"PRIuZ, line_num); "invalid object ID in FETCH_HEAD line %"PRIuZ, line_num);
return -1; return -1;
} }
if (git_oid_fromstr(oid, oid_str) < 0) { if (git_oid_fromstr(oid, oid_str) < 0) {
const git_error *oid_err = giterr_last(); const git_error *oid_err = git_error_last();
const char *err_msg = oid_err ? oid_err->message : "invalid object ID"; const char *err_msg = oid_err ? oid_err->message : "invalid object ID";
giterr_set(GITERR_FETCHHEAD, "%s in FETCH_HEAD line %"PRIuZ, git_error_set(GIT_ERROR_FETCHHEAD, "%s in FETCH_HEAD line %"PRIuZ,
err_msg, line_num); err_msg, line_num);
return -1; return -1;
} }
...@@ -179,7 +179,7 @@ static int fetchhead_ref_parse( ...@@ -179,7 +179,7 @@ static int fetchhead_ref_parse(
/* Parse new data from newer git clients */ /* Parse new data from newer git clients */
if (*line) { if (*line) {
if ((is_merge_str = git__strsep(&line, "\t")) == NULL) { if ((is_merge_str = git__strsep(&line, "\t")) == NULL) {
giterr_set(GITERR_FETCHHEAD, git_error_set(GIT_ERROR_FETCHHEAD,
"invalid description data in FETCH_HEAD line %"PRIuZ, line_num); "invalid description data in FETCH_HEAD line %"PRIuZ, line_num);
return -1; return -1;
} }
...@@ -189,13 +189,13 @@ static int fetchhead_ref_parse( ...@@ -189,13 +189,13 @@ static int fetchhead_ref_parse(
else if (strcmp(is_merge_str, "not-for-merge") == 0) else if (strcmp(is_merge_str, "not-for-merge") == 0)
*is_merge = 0; *is_merge = 0;
else { else {
giterr_set(GITERR_FETCHHEAD, git_error_set(GIT_ERROR_FETCHHEAD,
"invalid for-merge entry in FETCH_HEAD line %"PRIuZ, line_num); "invalid for-merge entry in FETCH_HEAD line %"PRIuZ, line_num);
return -1; return -1;
} }
if ((desc = line) == NULL) { if ((desc = line) == NULL) {
giterr_set(GITERR_FETCHHEAD, git_error_set(GIT_ERROR_FETCHHEAD,
"invalid description in FETCH_HEAD line %"PRIuZ, line_num); "invalid description in FETCH_HEAD line %"PRIuZ, line_num);
return -1; return -1;
} }
...@@ -212,7 +212,7 @@ static int fetchhead_ref_parse( ...@@ -212,7 +212,7 @@ static int fetchhead_ref_parse(
if (name) { if (name) {
if ((desc = strstr(name, "' ")) == NULL || if ((desc = strstr(name, "' ")) == NULL ||
git__prefixcmp(desc, "' of ") != 0) { git__prefixcmp(desc, "' of ") != 0) {
giterr_set(GITERR_FETCHHEAD, git_error_set(GIT_ERROR_FETCHHEAD,
"invalid description in FETCH_HEAD line %"PRIuZ, line_num); "invalid description in FETCH_HEAD line %"PRIuZ, line_num);
return -1; return -1;
} }
...@@ -271,13 +271,13 @@ int git_repository_fetchhead_foreach(git_repository *repo, ...@@ -271,13 +271,13 @@ int git_repository_fetchhead_foreach(git_repository *repo,
error = cb(ref_name, remote_url, &oid, is_merge, payload); error = cb(ref_name, remote_url, &oid, is_merge, payload);
if (error) { if (error) {
giterr_set_after_callback(error); git_error_set_after_callback(error);
goto done; goto done;
} }
} }
if (*buffer) { if (*buffer) {
giterr_set(GITERR_FETCHHEAD, "no EOL at line %"PRIuZ, line_num+1); git_error_set(GIT_ERROR_FETCHHEAD, "no EOL at line %"PRIuZ, line_num+1);
error = -1; error = -1;
goto done; goto done;
} }
......
...@@ -24,15 +24,15 @@ static int verify_last_error(git_filebuf *file) ...@@ -24,15 +24,15 @@ static int verify_last_error(git_filebuf *file)
{ {
switch (file->last_error) { switch (file->last_error) {
case BUFERR_WRITE: case BUFERR_WRITE:
giterr_set(GITERR_OS, "failed to write out file"); git_error_set(GIT_ERROR_OS, "failed to write out file");
return -1; return -1;
case BUFERR_MEM: case BUFERR_MEM:
giterr_set_oom(); git_error_set_oom();
return -1; return -1;
case BUFERR_ZLIB: case BUFERR_ZLIB:
giterr_set(GITERR_ZLIB, git_error_set(GIT_ERROR_ZLIB,
"Buffer error when writing out ZLib data"); "Buffer error when writing out ZLib data");
return -1; return -1;
...@@ -47,8 +47,8 @@ static int lock_file(git_filebuf *file, int flags, mode_t mode) ...@@ -47,8 +47,8 @@ static int lock_file(git_filebuf *file, int flags, mode_t mode)
if (flags & GIT_FILEBUF_FORCE) if (flags & GIT_FILEBUF_FORCE)
p_unlink(file->path_lock); p_unlink(file->path_lock);
else { else {
giterr_clear(); /* actual OS error code just confuses */ git_error_clear(); /* actual OS error code just confuses */
giterr_set(GITERR_OS, git_error_set(GIT_ERROR_OS,
"failed to lock file '%s' for writing", file->path_lock); "failed to lock file '%s' for writing", file->path_lock);
return GIT_ELOCKED; return GIT_ELOCKED;
} }
...@@ -75,7 +75,7 @@ static int lock_file(git_filebuf *file, int flags, mode_t mode) ...@@ -75,7 +75,7 @@ static int lock_file(git_filebuf *file, int flags, mode_t mode)
source = p_open(file->path_original, O_RDONLY); source = p_open(file->path_original, O_RDONLY);
if (source < 0) { if (source < 0) {
giterr_set(GITERR_OS, git_error_set(GIT_ERROR_OS,
"failed to open file '%s' for reading", "failed to open file '%s' for reading",
file->path_original); file->path_original);
return -1; return -1;
...@@ -91,10 +91,10 @@ static int lock_file(git_filebuf *file, int flags, mode_t mode) ...@@ -91,10 +91,10 @@ static int lock_file(git_filebuf *file, int flags, mode_t mode)
p_close(source); p_close(source);
if (read_bytes < 0) { if (read_bytes < 0) {
giterr_set(GITERR_OS, "failed to read file '%s'", file->path_original); git_error_set(GIT_ERROR_OS, "failed to read file '%s'", file->path_original);
return -1; return -1;
} else if (error < 0) { } else if (error < 0) {
giterr_set(GITERR_OS, "failed to write file '%s'", file->path_lock); git_error_set(GIT_ERROR_OS, "failed to write file '%s'", file->path_lock);
return -1; return -1;
} }
} }
...@@ -218,7 +218,7 @@ static int resolve_symlink(git_buf *out, const char *path) ...@@ -218,7 +218,7 @@ static int resolve_symlink(git_buf *out, const char *path)
} }
if (error < 0) { if (error < 0) {
giterr_set(GITERR_OS, "failed to stat '%s'", curpath.ptr); git_error_set(GIT_ERROR_OS, "failed to stat '%s'", curpath.ptr);
error = -1; error = -1;
goto cleanup; goto cleanup;
} }
...@@ -230,13 +230,13 @@ static int resolve_symlink(git_buf *out, const char *path) ...@@ -230,13 +230,13 @@ static int resolve_symlink(git_buf *out, const char *path)
ret = p_readlink(curpath.ptr, target.ptr, GIT_PATH_MAX); ret = p_readlink(curpath.ptr, target.ptr, GIT_PATH_MAX);
if (ret < 0) { if (ret < 0) {
giterr_set(GITERR_OS, "failed to read symlink '%s'", curpath.ptr); git_error_set(GIT_ERROR_OS, "failed to read symlink '%s'", curpath.ptr);
error = -1; error = -1;
goto cleanup; goto cleanup;
} }
if (ret == GIT_PATH_MAX) { if (ret == GIT_PATH_MAX) {
giterr_set(GITERR_INVALID, "symlink target too long"); git_error_set(GIT_ERROR_INVALID, "symlink target too long");
error = -1; error = -1;
goto cleanup; goto cleanup;
} }
...@@ -263,7 +263,7 @@ static int resolve_symlink(git_buf *out, const char *path) ...@@ -263,7 +263,7 @@ static int resolve_symlink(git_buf *out, const char *path)
} }
} }
giterr_set(GITERR_INVALID, "maximum symlink depth reached"); git_error_set(GIT_ERROR_INVALID, "maximum symlink depth reached");
error = -1; error = -1;
cleanup: cleanup:
...@@ -303,7 +303,7 @@ int git_filebuf_open_withsize(git_filebuf *file, const char *path, int flags, mo ...@@ -303,7 +303,7 @@ int git_filebuf_open_withsize(git_filebuf *file, const char *path, int flags, mo
/* Allocate the main cache buffer */ /* Allocate the main cache buffer */
if (!file->do_not_buffer) { if (!file->do_not_buffer) {
file->buffer = git__malloc(file->buf_size); file->buffer = git__malloc(file->buf_size);
GITERR_CHECK_ALLOC(file->buffer); GIT_ERROR_CHECK_ALLOC(file->buffer);
} }
/* If we are hashing on-write, allocate a new hash context */ /* If we are hashing on-write, allocate a new hash context */
...@@ -320,13 +320,13 @@ int git_filebuf_open_withsize(git_filebuf *file, const char *path, int flags, mo ...@@ -320,13 +320,13 @@ int git_filebuf_open_withsize(git_filebuf *file, const char *path, int flags, mo
if (compression != 0) { if (compression != 0) {
/* Initialize the ZLib stream */ /* Initialize the ZLib stream */
if (deflateInit(&file->zs, compression) != Z_OK) { if (deflateInit(&file->zs, compression) != Z_OK) {
giterr_set(GITERR_ZLIB, "failed to initialize zlib"); git_error_set(GIT_ERROR_ZLIB, "failed to initialize zlib");
goto cleanup; goto cleanup;
} }
/* Allocate the Zlib cache buffer */ /* Allocate the Zlib cache buffer */
file->z_buf = git__malloc(file->buf_size); file->z_buf = git__malloc(file->buf_size);
GITERR_CHECK_ALLOC(file->z_buf); GIT_ERROR_CHECK_ALLOC(file->z_buf);
/* Never flush */ /* Never flush */
file->flush_mode = Z_NO_FLUSH; file->flush_mode = Z_NO_FLUSH;
...@@ -352,7 +352,7 @@ int git_filebuf_open_withsize(git_filebuf *file, const char *path, int flags, mo ...@@ -352,7 +352,7 @@ int git_filebuf_open_withsize(git_filebuf *file, const char *path, int flags, mo
/* No original path */ /* No original path */
file->path_original = NULL; file->path_original = NULL;
file->path_lock = git_buf_detach(&tmp_path); file->path_lock = git_buf_detach(&tmp_path);
GITERR_CHECK_ALLOC(file->path_lock); GIT_ERROR_CHECK_ALLOC(file->path_lock);
} else { } else {
git_buf resolved_path = GIT_BUF_INIT; git_buf resolved_path = GIT_BUF_INIT;
...@@ -364,15 +364,15 @@ int git_filebuf_open_withsize(git_filebuf *file, const char *path, int flags, mo ...@@ -364,15 +364,15 @@ int git_filebuf_open_withsize(git_filebuf *file, const char *path, int flags, mo
file->path_original = git_buf_detach(&resolved_path); file->path_original = git_buf_detach(&resolved_path);
/* create the locking path by appending ".lock" to the original */ /* create the locking path by appending ".lock" to the original */
GITERR_CHECK_ALLOC_ADD(&alloc_len, path_len, GIT_FILELOCK_EXTLENGTH); GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, path_len, GIT_FILELOCK_EXTLENGTH);
file->path_lock = git__malloc(alloc_len); file->path_lock = git__malloc(alloc_len);
GITERR_CHECK_ALLOC(file->path_lock); GIT_ERROR_CHECK_ALLOC(file->path_lock);
memcpy(file->path_lock, file->path_original, path_len); memcpy(file->path_lock, file->path_original, path_len);
memcpy(file->path_lock + path_len, GIT_FILELOCK_EXTENSION, GIT_FILELOCK_EXTLENGTH); memcpy(file->path_lock + path_len, GIT_FILELOCK_EXTENSION, GIT_FILELOCK_EXTLENGTH);
if (git_path_isdir(file->path_original)) { if (git_path_isdir(file->path_original)) {
giterr_set(GITERR_FILESYSTEM, "path '%s' is a directory", file->path_original); git_error_set(GIT_ERROR_FILESYSTEM, "path '%s' is a directory", file->path_original);
error = GIT_EDIRECTORY; error = GIT_EDIRECTORY;
goto cleanup; goto cleanup;
} }
...@@ -411,7 +411,7 @@ int git_filebuf_commit_at(git_filebuf *file, const char *path) ...@@ -411,7 +411,7 @@ int git_filebuf_commit_at(git_filebuf *file, const char *path)
{ {
git__free(file->path_original); git__free(file->path_original);
file->path_original = git__strdup(path); file->path_original = git__strdup(path);
GITERR_CHECK_ALLOC(file->path_original); GIT_ERROR_CHECK_ALLOC(file->path_original);
return git_filebuf_commit(file); return git_filebuf_commit(file);
} }
...@@ -430,19 +430,19 @@ int git_filebuf_commit(git_filebuf *file) ...@@ -430,19 +430,19 @@ int git_filebuf_commit(git_filebuf *file)
file->fd_is_open = false; file->fd_is_open = false;
if (file->do_fsync && p_fsync(file->fd) < 0) { if (file->do_fsync && p_fsync(file->fd) < 0) {
giterr_set(GITERR_OS, "failed to fsync '%s'", file->path_lock); git_error_set(GIT_ERROR_OS, "failed to fsync '%s'", file->path_lock);
goto on_error; goto on_error;
} }
if (p_close(file->fd) < 0) { if (p_close(file->fd) < 0) {
giterr_set(GITERR_OS, "failed to close file at '%s'", file->path_lock); git_error_set(GIT_ERROR_OS, "failed to close file at '%s'", file->path_lock);
goto on_error; goto on_error;
} }
file->fd = -1; file->fd = -1;
if (p_rename(file->path_lock, file->path_original) < 0) { if (p_rename(file->path_lock, file->path_original) < 0) {
giterr_set(GITERR_OS, "failed to rename lockfile to '%s'", file->path_original); git_error_set(GIT_ERROR_OS, "failed to rename lockfile to '%s'", file->path_original);
goto on_error; goto on_error;
} }
...@@ -583,7 +583,7 @@ int git_filebuf_stats(time_t *mtime, size_t *size, git_filebuf *file) ...@@ -583,7 +583,7 @@ int git_filebuf_stats(time_t *mtime, size_t *size, git_filebuf *file)
res = p_stat(file->path_original, &st); res = p_stat(file->path_original, &st);
if (res < 0) { if (res < 0) {
giterr_set(GITERR_OS, "could not get stat info for '%s'", git_error_set(GIT_ERROR_OS, "could not get stat info for '%s'",
file->path_original); file->path_original);
return res; return res;
} }
......
...@@ -340,7 +340,7 @@ typedef struct { ...@@ -340,7 +340,7 @@ typedef struct {
* This function updates the file stamp to current data for the given path * This function updates the file stamp to current data for the given path
* and returns 0 if the file is up-to-date relative to the prior setting, * and returns 0 if the file is up-to-date relative to the prior setting,
* 1 if the file has been changed, or GIT_ENOTFOUND if the file doesn't * 1 if the file has been changed, or GIT_ENOTFOUND if the file doesn't
* exist. This will not call giterr_set, so you must set the error if you * exist. This will not call git_error_set, so you must set the error if you
* plan to return an error. * plan to return an error.
* *
* @param stamp File stamp to be checked * @param stamp File stamp to be checked
......
...@@ -157,15 +157,15 @@ static int filter_registry_insert( ...@@ -157,15 +157,15 @@ static int filter_registry_insert(
if (filter_def_scan_attrs(&attrs, &nattr, &nmatch, filter->attributes) < 0) if (filter_def_scan_attrs(&attrs, &nattr, &nmatch, filter->attributes) < 0)
return -1; return -1;
GITERR_CHECK_ALLOC_MULTIPLY(&alloc_len, nattr, 2); GIT_ERROR_CHECK_ALLOC_MULTIPLY(&alloc_len, nattr, 2);
GITERR_CHECK_ALLOC_MULTIPLY(&alloc_len, alloc_len, sizeof(char *)); GIT_ERROR_CHECK_ALLOC_MULTIPLY(&alloc_len, alloc_len, sizeof(char *));
GITERR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, sizeof(git_filter_def)); GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, sizeof(git_filter_def));
fdef = git__calloc(1, alloc_len); fdef = git__calloc(1, alloc_len);
GITERR_CHECK_ALLOC(fdef); GIT_ERROR_CHECK_ALLOC(fdef);
fdef->filter_name = git__strdup(name); fdef->filter_name = git__strdup(name);
GITERR_CHECK_ALLOC(fdef->filter_name); GIT_ERROR_CHECK_ALLOC(fdef->filter_name);
fdef->filter = filter; fdef->filter = filter;
fdef->priority = priority; fdef->priority = priority;
...@@ -269,13 +269,13 @@ int git_filter_register( ...@@ -269,13 +269,13 @@ int git_filter_register(
assert(name && filter); assert(name && filter);
if (git_rwlock_wrlock(&filter_registry.lock) < 0) { if (git_rwlock_wrlock(&filter_registry.lock) < 0) {
giterr_set(GITERR_OS, "failed to lock filter registry"); git_error_set(GIT_ERROR_OS, "failed to lock filter registry");
return -1; return -1;
} }
if (!filter_registry_find(NULL, name)) { if (!filter_registry_find(NULL, name)) {
giterr_set( git_error_set(
GITERR_FILTER, "attempt to reregister existing filter '%s'", name); GIT_ERROR_FILTER, "attempt to reregister existing filter '%s'", name);
error = GIT_EEXISTS; error = GIT_EEXISTS;
goto done; goto done;
} }
...@@ -297,17 +297,17 @@ int git_filter_unregister(const char *name) ...@@ -297,17 +297,17 @@ int git_filter_unregister(const char *name)
/* cannot unregister default filters */ /* cannot unregister default filters */
if (!strcmp(GIT_FILTER_CRLF, name) || !strcmp(GIT_FILTER_IDENT, name)) { if (!strcmp(GIT_FILTER_CRLF, name) || !strcmp(GIT_FILTER_IDENT, name)) {
giterr_set(GITERR_FILTER, "cannot unregister filter '%s'", name); git_error_set(GIT_ERROR_FILTER, "cannot unregister filter '%s'", name);
return -1; return -1;
} }
if (git_rwlock_wrlock(&filter_registry.lock) < 0) { if (git_rwlock_wrlock(&filter_registry.lock) < 0) {
giterr_set(GITERR_OS, "failed to lock filter registry"); git_error_set(GIT_ERROR_OS, "failed to lock filter registry");
return -1; return -1;
} }
if ((fdef = filter_registry_lookup(&pos, name)) == NULL) { if ((fdef = filter_registry_lookup(&pos, name)) == NULL) {
giterr_set(GITERR_FILTER, "cannot find filter '%s' to unregister", name); git_error_set(GIT_ERROR_FILTER, "cannot find filter '%s' to unregister", name);
error = GIT_ENOTFOUND; error = GIT_ENOTFOUND;
goto done; goto done;
} }
...@@ -348,7 +348,7 @@ git_filter *git_filter_lookup(const char *name) ...@@ -348,7 +348,7 @@ git_filter *git_filter_lookup(const char *name)
git_filter *filter = NULL; git_filter *filter = NULL;
if (git_rwlock_rdlock(&filter_registry.lock) < 0) { if (git_rwlock_rdlock(&filter_registry.lock) < 0) {
giterr_set(GITERR_OS, "failed to lock filter registry"); git_error_set(GIT_ERROR_OS, "failed to lock filter registry");
return NULL; return NULL;
} }
...@@ -404,11 +404,11 @@ static int filter_list_new( ...@@ -404,11 +404,11 @@ static int filter_list_new(
git_filter_list *fl = NULL; git_filter_list *fl = NULL;
size_t pathlen = src->path ? strlen(src->path) : 0, alloclen; size_t pathlen = src->path ? strlen(src->path) : 0, alloclen;
GITERR_CHECK_ALLOC_ADD(&alloclen, sizeof(git_filter_list), pathlen); GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, sizeof(git_filter_list), pathlen);
GITERR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1); GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1);
fl = git__calloc(1, alloclen); fl = git__calloc(1, alloclen);
GITERR_CHECK_ALLOC(fl); GIT_ERROR_CHECK_ALLOC(fl);
if (src->path) if (src->path)
memcpy(fl->path, src->path, pathlen); memcpy(fl->path, src->path, pathlen);
...@@ -431,14 +431,14 @@ static int filter_list_check_attributes( ...@@ -431,14 +431,14 @@ static int filter_list_check_attributes(
int error; int error;
size_t i; size_t i;
const char **strs = git__calloc(fdef->nattrs, sizeof(const char *)); const char **strs = git__calloc(fdef->nattrs, sizeof(const char *));
GITERR_CHECK_ALLOC(strs); GIT_ERROR_CHECK_ALLOC(strs);
error = git_attr_get_many_with_session( error = git_attr_get_many_with_session(
strs, repo, attr_session, 0, src->path, fdef->nattrs, fdef->attrs); strs, repo, attr_session, 0, src->path, fdef->nattrs, fdef->attrs);
/* if no values were found but no matches are needed, it's okay! */ /* if no values were found but no matches are needed, it's okay! */
if (error == GIT_ENOTFOUND && !fdef->nmatches) { if (error == GIT_ENOTFOUND && !fdef->nmatches) {
giterr_clear(); git_error_clear();
git__free((void *)strs); git__free((void *)strs);
return 0; return 0;
} }
...@@ -499,7 +499,7 @@ int git_filter_list__load_ext( ...@@ -499,7 +499,7 @@ int git_filter_list__load_ext(
git_filter_def *fdef; git_filter_def *fdef;
if (git_rwlock_rdlock(&filter_registry.lock) < 0) { if (git_rwlock_rdlock(&filter_registry.lock) < 0) {
giterr_set(GITERR_OS, "failed to lock filter registry"); git_error_set(GIT_ERROR_OS, "failed to lock filter registry");
return -1; return -1;
} }
...@@ -551,7 +551,7 @@ int git_filter_list__load_ext( ...@@ -551,7 +551,7 @@ int git_filter_list__load_ext(
} }
fe = git_array_alloc(fl->filters); fe = git_array_alloc(fl->filters);
GITERR_CHECK_ALLOC(fe); GIT_ERROR_CHECK_ALLOC(fe);
fe->filter = fdef->filter; fe->filter = fdef->filter;
fe->filter_name = fdef->filter_name; fe->filter_name = fdef->filter_name;
...@@ -634,7 +634,7 @@ int git_filter_list_push( ...@@ -634,7 +634,7 @@ int git_filter_list_push(
assert(fl && filter); assert(fl && filter);
if (git_rwlock_rdlock(&filter_registry.lock) < 0) { if (git_rwlock_rdlock(&filter_registry.lock) < 0) {
giterr_set(GITERR_OS, "failed to lock filter registry"); git_error_set(GIT_ERROR_OS, "failed to lock filter registry");
return -1; return -1;
} }
...@@ -646,7 +646,7 @@ int git_filter_list_push( ...@@ -646,7 +646,7 @@ int git_filter_list_push(
git_rwlock_rdunlock(&filter_registry.lock); git_rwlock_rdunlock(&filter_registry.lock);
if (fdef == NULL) { if (fdef == NULL) {
giterr_set(GITERR_FILTER, "cannot use an unregistered filter"); git_error_set(GIT_ERROR_FILTER, "cannot use an unregistered filter");
return -1; return -1;
} }
...@@ -654,7 +654,7 @@ int git_filter_list_push( ...@@ -654,7 +654,7 @@ int git_filter_list_push(
return error; return error;
fe = git_array_alloc(fl->filters); fe = git_array_alloc(fl->filters);
GITERR_CHECK_ALLOC(fe); GIT_ERROR_CHECK_ALLOC(fe);
fe->filter = filter; fe->filter = filter;
fe->payload = payload; fe->payload = payload;
...@@ -759,7 +759,7 @@ static int buf_from_blob(git_buf *out, git_blob *blob) ...@@ -759,7 +759,7 @@ static int buf_from_blob(git_buf *out, git_blob *blob)
git_off_t rawsize = git_blob_rawsize(blob); git_off_t rawsize = git_blob_rawsize(blob);
if (!git__is_sizet(rawsize)) { if (!git__is_sizet(rawsize)) {
giterr_set(GITERR_OS, "blob is too large to filter"); git_error_set(GIT_ERROR_OS, "blob is too large to filter");
return -1; return -1;
} }
...@@ -829,9 +829,9 @@ static int proxy_stream_close(git_writestream *s) ...@@ -829,9 +829,9 @@ static int proxy_stream_close(git_writestream *s)
} else { } else {
/* close stream before erroring out taking care /* close stream before erroring out taking care
* to preserve the original error */ * to preserve the original error */
giterr_state_capture(&error_state, error); git_error_state_capture(&error_state, error);
proxy_stream->target->close(proxy_stream->target); proxy_stream->target->close(proxy_stream->target);
giterr_state_restore(&error_state); git_error_state_restore(&error_state);
return error; return error;
} }
...@@ -861,7 +861,7 @@ static int proxy_stream_init( ...@@ -861,7 +861,7 @@ static int proxy_stream_init(
git_writestream *target) git_writestream *target)
{ {
struct proxy_stream *proxy_stream = git__calloc(1, sizeof(struct proxy_stream)); struct proxy_stream *proxy_stream = git__calloc(1, sizeof(struct proxy_stream));
GITERR_CHECK_ALLOC(proxy_stream); GIT_ERROR_CHECK_ALLOC(proxy_stream);
proxy_stream->parent.write = proxy_stream_write; proxy_stream->parent.write = proxy_stream_write;
proxy_stream->parent.close = proxy_stream_close; proxy_stream->parent.close = proxy_stream_close;
......
...@@ -41,7 +41,7 @@ GIT_INLINE(int) git_hash_final(git_oid *out, git_hash_ctx *ctx) ...@@ -41,7 +41,7 @@ GIT_INLINE(int) git_hash_final(git_oid *out, git_hash_ctx *ctx)
{ {
assert(ctx); assert(ctx);
if (SHA1DCFinal(out->id, &ctx->c)) { if (SHA1DCFinal(out->id, &ctx->c)) {
giterr_set(GITERR_SHA1, "SHA1 collision attack detected"); git_error_set(GIT_ERROR_SHA1, "SHA1 collision attack detected");
return -1; return -1;
} }
......
...@@ -29,7 +29,7 @@ GIT_INLINE(int) git_hash_init(git_hash_ctx *ctx) ...@@ -29,7 +29,7 @@ GIT_INLINE(int) git_hash_init(git_hash_ctx *ctx)
assert(ctx); assert(ctx);
if (SHA1_Init(&ctx->c) != 1) { if (SHA1_Init(&ctx->c) != 1) {
giterr_set(GITERR_SHA1, "hash_openssl: failed to initialize hash context"); git_error_set(GIT_ERROR_SHA1, "hash_openssl: failed to initialize hash context");
return -1; return -1;
} }
...@@ -41,7 +41,7 @@ GIT_INLINE(int) git_hash_update(git_hash_ctx *ctx, const void *data, size_t len) ...@@ -41,7 +41,7 @@ GIT_INLINE(int) git_hash_update(git_hash_ctx *ctx, const void *data, size_t len)
assert(ctx); assert(ctx);
if (SHA1_Update(&ctx->c, data, len) != 1) { if (SHA1_Update(&ctx->c, data, len) != 1) {
giterr_set(GITERR_SHA1, "hash_openssl: failed to update hash"); git_error_set(GIT_ERROR_SHA1, "hash_openssl: failed to update hash");
return -1; return -1;
} }
...@@ -53,7 +53,7 @@ GIT_INLINE(int) git_hash_final(git_oid *out, git_hash_ctx *ctx) ...@@ -53,7 +53,7 @@ GIT_INLINE(int) git_hash_final(git_oid *out, git_hash_ctx *ctx)
assert(ctx); assert(ctx);
if (SHA1_Final(out->id, &ctx->c) != 1) { if (SHA1_Final(out->id, &ctx->c) != 1) {
giterr_set(GITERR_SHA1, "hash_openssl: failed to finalize hash"); git_error_set(GIT_ERROR_SHA1, "hash_openssl: failed to finalize hash");
return -1; return -1;
} }
......
...@@ -25,7 +25,7 @@ GIT_INLINE(int) hash_cng_prov_init(void) ...@@ -25,7 +25,7 @@ GIT_INLINE(int) hash_cng_prov_init(void)
/* Only use CNG on Windows 2008 / Vista SP1 or better (Windows 6.0 SP1) */ /* Only use CNG on Windows 2008 / Vista SP1 or better (Windows 6.0 SP1) */
if (!git_has_win32_version(6, 0, 1)) { if (!git_has_win32_version(6, 0, 1)) {
giterr_set(GITERR_SHA1, "CryptoNG is not supported on this platform"); git_error_set(GIT_ERROR_SHA1, "CryptoNG is not supported on this platform");
return -1; return -1;
} }
...@@ -35,7 +35,7 @@ GIT_INLINE(int) hash_cng_prov_init(void) ...@@ -35,7 +35,7 @@ GIT_INLINE(int) hash_cng_prov_init(void)
StringCchCat(dll_path, MAX_PATH, "\\") < 0 || StringCchCat(dll_path, MAX_PATH, "\\") < 0 ||
StringCchCat(dll_path, MAX_PATH, GIT_HASH_CNG_DLL_NAME) < 0 || StringCchCat(dll_path, MAX_PATH, GIT_HASH_CNG_DLL_NAME) < 0 ||
(hash_prov.prov.cng.dll = LoadLibrary(dll_path)) == NULL) { (hash_prov.prov.cng.dll = LoadLibrary(dll_path)) == NULL) {
giterr_set(GITERR_SHA1, "CryptoNG library could not be loaded"); git_error_set(GIT_ERROR_SHA1, "CryptoNG library could not be loaded");
return -1; return -1;
} }
...@@ -49,7 +49,7 @@ GIT_INLINE(int) hash_cng_prov_init(void) ...@@ -49,7 +49,7 @@ GIT_INLINE(int) hash_cng_prov_init(void)
(hash_prov.prov.cng.close_algorithm_provider = (hash_win32_cng_close_algorithm_provider_fn)GetProcAddress(hash_prov.prov.cng.dll, "BCryptCloseAlgorithmProvider")) == NULL) { (hash_prov.prov.cng.close_algorithm_provider = (hash_win32_cng_close_algorithm_provider_fn)GetProcAddress(hash_prov.prov.cng.dll, "BCryptCloseAlgorithmProvider")) == NULL) {
FreeLibrary(hash_prov.prov.cng.dll); FreeLibrary(hash_prov.prov.cng.dll);
giterr_set(GITERR_OS, "CryptoNG functions could not be loaded"); git_error_set(GIT_ERROR_OS, "CryptoNG functions could not be loaded");
return -1; return -1;
} }
...@@ -57,7 +57,7 @@ GIT_INLINE(int) hash_cng_prov_init(void) ...@@ -57,7 +57,7 @@ GIT_INLINE(int) hash_cng_prov_init(void)
if (hash_prov.prov.cng.open_algorithm_provider(&hash_prov.prov.cng.handle, GIT_HASH_CNG_HASH_TYPE, NULL, GIT_HASH_CNG_HASH_REUSABLE) < 0) { if (hash_prov.prov.cng.open_algorithm_provider(&hash_prov.prov.cng.handle, GIT_HASH_CNG_HASH_TYPE, NULL, GIT_HASH_CNG_HASH_REUSABLE) < 0) {
FreeLibrary(hash_prov.prov.cng.dll); FreeLibrary(hash_prov.prov.cng.dll);
giterr_set(GITERR_OS, "algorithm provider could not be initialized"); git_error_set(GIT_ERROR_OS, "algorithm provider could not be initialized");
return -1; return -1;
} }
...@@ -66,7 +66,7 @@ GIT_INLINE(int) hash_cng_prov_init(void) ...@@ -66,7 +66,7 @@ GIT_INLINE(int) hash_cng_prov_init(void)
hash_prov.prov.cng.close_algorithm_provider(hash_prov.prov.cng.handle, 0); hash_prov.prov.cng.close_algorithm_provider(hash_prov.prov.cng.handle, 0);
FreeLibrary(hash_prov.prov.cng.dll); FreeLibrary(hash_prov.prov.cng.dll);
giterr_set(GITERR_OS, "algorithm handle could not be found"); git_error_set(GIT_ERROR_OS, "algorithm handle could not be found");
return -1; return -1;
} }
...@@ -86,7 +86,7 @@ GIT_INLINE(void) hash_cng_prov_shutdown(void) ...@@ -86,7 +86,7 @@ GIT_INLINE(void) hash_cng_prov_shutdown(void)
GIT_INLINE(int) hash_cryptoapi_prov_init() GIT_INLINE(int) hash_cryptoapi_prov_init()
{ {
if (!CryptAcquireContext(&hash_prov.prov.cryptoapi.handle, NULL, 0, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) { if (!CryptAcquireContext(&hash_prov.prov.cryptoapi.handle, NULL, 0, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) {
giterr_set(GITERR_OS, "legacy hash context could not be started"); git_error_set(GIT_ERROR_OS, "legacy hash context could not be started");
return -1; return -1;
} }
...@@ -141,7 +141,7 @@ GIT_INLINE(int) hash_cryptoapi_init(git_hash_ctx *ctx) ...@@ -141,7 +141,7 @@ GIT_INLINE(int) hash_cryptoapi_init(git_hash_ctx *ctx)
if (!CryptCreateHash(ctx->prov->prov.cryptoapi.handle, CALG_SHA1, 0, 0, &ctx->ctx.cryptoapi.hash_handle)) { if (!CryptCreateHash(ctx->prov->prov.cryptoapi.handle, CALG_SHA1, 0, 0, &ctx->ctx.cryptoapi.hash_handle)) {
ctx->ctx.cryptoapi.valid = 0; ctx->ctx.cryptoapi.valid = 0;
giterr_set(GITERR_OS, "legacy hash implementation could not be created"); git_error_set(GIT_ERROR_OS, "legacy hash implementation could not be created");
return -1; return -1;
} }
...@@ -159,7 +159,7 @@ GIT_INLINE(int) hash_cryptoapi_update(git_hash_ctx *ctx, const void *_data, size ...@@ -159,7 +159,7 @@ GIT_INLINE(int) hash_cryptoapi_update(git_hash_ctx *ctx, const void *_data, size
DWORD chunk = (len > MAXDWORD) ? MAXDWORD : (DWORD)len; DWORD chunk = (len > MAXDWORD) ? MAXDWORD : (DWORD)len;
if (!CryptHashData(ctx->ctx.cryptoapi.hash_handle, data, chunk, 0)) { if (!CryptHashData(ctx->ctx.cryptoapi.hash_handle, data, chunk, 0)) {
giterr_set(GITERR_OS, "legacy hash data could not be updated"); git_error_set(GIT_ERROR_OS, "legacy hash data could not be updated");
return -1; return -1;
} }
...@@ -178,7 +178,7 @@ GIT_INLINE(int) hash_cryptoapi_final(git_oid *out, git_hash_ctx *ctx) ...@@ -178,7 +178,7 @@ GIT_INLINE(int) hash_cryptoapi_final(git_oid *out, git_hash_ctx *ctx)
assert(ctx->ctx.cryptoapi.valid); assert(ctx->ctx.cryptoapi.valid);
if (!CryptGetHashParam(ctx->ctx.cryptoapi.hash_handle, HP_HASHVAL, out->id, &len, 0)) { if (!CryptGetHashParam(ctx->ctx.cryptoapi.hash_handle, HP_HASHVAL, out->id, &len, 0)) {
giterr_set(GITERR_OS, "legacy hash data could not be finished"); git_error_set(GIT_ERROR_OS, "legacy hash data could not be finished");
error = -1; error = -1;
} }
...@@ -204,7 +204,7 @@ GIT_INLINE(int) hash_ctx_cng_init(git_hash_ctx *ctx) ...@@ -204,7 +204,7 @@ GIT_INLINE(int) hash_ctx_cng_init(git_hash_ctx *ctx)
if (hash_prov.prov.cng.create_hash(hash_prov.prov.cng.handle, &ctx->ctx.cng.hash_handle, ctx->ctx.cng.hash_object, hash_prov.prov.cng.hash_object_size, NULL, 0, 0) < 0) { if (hash_prov.prov.cng.create_hash(hash_prov.prov.cng.handle, &ctx->ctx.cng.hash_handle, ctx->ctx.cng.hash_object, hash_prov.prov.cng.hash_object_size, NULL, 0, 0) < 0) {
git__free(ctx->ctx.cng.hash_object); git__free(ctx->ctx.cng.hash_object);
giterr_set(GITERR_OS, "hash implementation could not be created"); git_error_set(GIT_ERROR_OS, "hash implementation could not be created");
return -1; return -1;
} }
...@@ -223,7 +223,7 @@ GIT_INLINE(int) hash_cng_init(git_hash_ctx *ctx) ...@@ -223,7 +223,7 @@ GIT_INLINE(int) hash_cng_init(git_hash_ctx *ctx)
/* CNG needs to be finished to restart */ /* CNG needs to be finished to restart */
if (ctx->prov->prov.cng.finish_hash(ctx->ctx.cng.hash_handle, hash, GIT_OID_RAWSZ, 0) < 0) { if (ctx->prov->prov.cng.finish_hash(ctx->ctx.cng.hash_handle, hash, GIT_OID_RAWSZ, 0) < 0) {
giterr_set(GITERR_OS, "hash implementation could not be finished"); git_error_set(GIT_ERROR_OS, "hash implementation could not be finished");
return -1; return -1;
} }
...@@ -240,7 +240,7 @@ GIT_INLINE(int) hash_cng_update(git_hash_ctx *ctx, const void *_data, size_t len ...@@ -240,7 +240,7 @@ GIT_INLINE(int) hash_cng_update(git_hash_ctx *ctx, const void *_data, size_t len
ULONG chunk = (len > ULONG_MAX) ? ULONG_MAX : (ULONG)len; ULONG chunk = (len > ULONG_MAX) ? ULONG_MAX : (ULONG)len;
if (ctx->prov->prov.cng.hash_data(ctx->ctx.cng.hash_handle, data, chunk, 0) < 0) { if (ctx->prov->prov.cng.hash_data(ctx->ctx.cng.hash_handle, data, chunk, 0) < 0) {
giterr_set(GITERR_OS, "hash could not be updated"); git_error_set(GIT_ERROR_OS, "hash could not be updated");
return -1; return -1;
} }
...@@ -254,7 +254,7 @@ GIT_INLINE(int) hash_cng_update(git_hash_ctx *ctx, const void *_data, size_t len ...@@ -254,7 +254,7 @@ GIT_INLINE(int) hash_cng_update(git_hash_ctx *ctx, const void *_data, size_t len
GIT_INLINE(int) hash_cng_final(git_oid *out, git_hash_ctx *ctx) GIT_INLINE(int) hash_cng_final(git_oid *out, git_hash_ctx *ctx)
{ {
if (ctx->prov->prov.cng.finish_hash(ctx->ctx.cng.hash_handle, out->id, GIT_OID_RAWSZ, 0) < 0) { if (ctx->prov->prov.cng.finish_hash(ctx->ctx.cng.hash_handle, out->id, GIT_OID_RAWSZ, 0) < 0) {
giterr_set(GITERR_OS, "hash could not be finished"); git_error_set(GIT_ERROR_OS, "hash could not be finished");
return -1; return -1;
} }
......
...@@ -216,7 +216,7 @@ static int hashsig_finalize_hashes(git_hashsig *sig) ...@@ -216,7 +216,7 @@ static int hashsig_finalize_hashes(git_hashsig *sig)
{ {
if (sig->mins.size < HASHSIG_HEAP_MIN_SIZE && if (sig->mins.size < HASHSIG_HEAP_MIN_SIZE &&
!(sig->opt & GIT_HASHSIG_ALLOW_SMALL_FILES)) { !(sig->opt & GIT_HASHSIG_ALLOW_SMALL_FILES)) {
giterr_set(GITERR_INVALID, git_error_set(GIT_ERROR_INVALID,
"file too small for similarity signature calculation"); "file too small for similarity signature calculation");
return GIT_EBUFS; return GIT_EBUFS;
} }
...@@ -249,7 +249,7 @@ int git_hashsig_create( ...@@ -249,7 +249,7 @@ int git_hashsig_create(
int error; int error;
hashsig_in_progress prog; hashsig_in_progress prog;
git_hashsig *sig = hashsig_alloc(opts); git_hashsig *sig = hashsig_alloc(opts);
GITERR_CHECK_ALLOC(sig); GIT_ERROR_CHECK_ALLOC(sig);
hashsig_in_progress_init(&prog, sig); hashsig_in_progress_init(&prog, sig);
...@@ -276,7 +276,7 @@ int git_hashsig_create_fromfile( ...@@ -276,7 +276,7 @@ int git_hashsig_create_fromfile(
int error = 0, fd; int error = 0, fd;
hashsig_in_progress prog; hashsig_in_progress prog;
git_hashsig *sig = hashsig_alloc(opts); git_hashsig *sig = hashsig_alloc(opts);
GITERR_CHECK_ALLOC(sig); GIT_ERROR_CHECK_ALLOC(sig);
if ((fd = git_futils_open_ro(path)) < 0) { if ((fd = git_futils_open_ro(path)) < 0) {
git__free(sig); git__free(sig);
...@@ -288,7 +288,7 @@ int git_hashsig_create_fromfile( ...@@ -288,7 +288,7 @@ int git_hashsig_create_fromfile(
while (!error) { while (!error) {
if ((buflen = p_read(fd, buf, sizeof(buf))) <= 0) { if ((buflen = p_read(fd, buf, sizeof(buf))) <= 0) {
if ((error = (int)buflen) < 0) if ((error = (int)buflen) < 0)
giterr_set(GITERR_OS, git_error_set(GIT_ERROR_OS,
"read error on '%s' calculating similarity hashes", path); "read error on '%s' calculating similarity hashes", path);
break; break;
} }
......
...@@ -35,7 +35,7 @@ __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entr ...@@ -35,7 +35,7 @@ __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entr
int git_idxmap_alloc(git_idxmap **map) int git_idxmap_alloc(git_idxmap **map)
{ {
if ((*map = kh_init(idx)) == NULL) { if ((*map = kh_init(idx)) == NULL) {
giterr_set_oom(); git_error_set_oom();
return -1; return -1;
} }
...@@ -45,7 +45,7 @@ int git_idxmap_alloc(git_idxmap **map) ...@@ -45,7 +45,7 @@ int git_idxmap_alloc(git_idxmap **map)
int git_idxmap_icase_alloc(git_idxmap_icase **map) int git_idxmap_icase_alloc(git_idxmap_icase **map)
{ {
if ((*map = kh_init(idxicase)) == NULL) { if ((*map = kh_init(idxicase)) == NULL) {
giterr_set_oom(); git_error_set_oom();
return -1; return -1;
} }
......
...@@ -142,7 +142,7 @@ static int does_negate_rule(int *out, git_vector *rules, git_attr_fnmatch *match ...@@ -142,7 +142,7 @@ static int does_negate_rule(int *out, git_vector *rules, git_attr_fnmatch *match
goto out; goto out;
if ((error = p_fnmatch(git_buf_cstr(&buf), path, fnflags)) < 0) { if ((error = p_fnmatch(git_buf_cstr(&buf), path, fnflags)) < 0) {
giterr_set(GITERR_INVALID, "error matching pattern"); git_error_set(GIT_ERROR_INVALID, "error matching pattern");
goto out; goto out;
} }
...@@ -171,7 +171,7 @@ static int parse_ignore_file( ...@@ -171,7 +171,7 @@ static int parse_ignore_file(
git_attr_fnmatch *match = NULL; git_attr_fnmatch *match = NULL;
if (git_repository__cvar(&ignore_case, repo, GIT_CVAR_IGNORECASE) < 0) if (git_repository__cvar(&ignore_case, repo, GIT_CVAR_IGNORECASE) < 0)
giterr_clear(); git_error_clear();
/* if subdir file path, convert context for file paths */ /* if subdir file path, convert context for file paths */
if (attrs->entry && if (attrs->entry &&
...@@ -180,7 +180,7 @@ static int parse_ignore_file( ...@@ -180,7 +180,7 @@ static int parse_ignore_file(
context = attrs->entry->path; context = attrs->entry->path;
if (git_mutex_lock(&attrs->lock) < 0) { if (git_mutex_lock(&attrs->lock) < 0) {
giterr_set(GITERR_OS, "failed to lock ignore file"); git_error_set(GIT_ERROR_OS, "failed to lock ignore file");
return -1; return -1;
} }
...@@ -624,7 +624,7 @@ int git_ignore__check_pathspec_for_exact_ignores( ...@@ -624,7 +624,7 @@ int git_ignore__check_pathspec_for_exact_ignores(
break; break;
if (ignored) { if (ignored) {
giterr_set(GITERR_INVALID, "pathspec contains ignored file '%s'", git_error_set(GIT_ERROR_INVALID, "pathspec contains ignored file '%s'",
filename); filename);
error = GIT_EINVALIDSPEC; error = GIT_EINVALIDSPEC;
break; break;
......
...@@ -95,12 +95,12 @@ static int parse_header(struct git_pack_header *hdr, struct git_pack_file *pack) ...@@ -95,12 +95,12 @@ static int parse_header(struct git_pack_header *hdr, struct git_pack_file *pack)
/* Verify we recognize this pack file format. */ /* Verify we recognize this pack file format. */
if (hdr->hdr_signature != ntohl(PACK_SIGNATURE)) { if (hdr->hdr_signature != ntohl(PACK_SIGNATURE)) {
giterr_set(GITERR_INDEXER, "wrong pack signature"); git_error_set(GIT_ERROR_INDEXER, "wrong pack signature");
return -1; return -1;
} }
if (!pack_version_ok(hdr->hdr_version)) { if (!pack_version_ok(hdr->hdr_version)) {
giterr_set(GITERR_INDEXER, "wrong pack version"); git_error_set(GIT_ERROR_INDEXER, "wrong pack version");
return -1; return -1;
} }
...@@ -139,7 +139,7 @@ int git_indexer_new( ...@@ -139,7 +139,7 @@ int git_indexer_new(
memcpy(&opts, in_opts, sizeof(opts)); memcpy(&opts, in_opts, sizeof(opts));
idx = git__calloc(1, sizeof(git_indexer)); idx = git__calloc(1, sizeof(git_indexer));
GITERR_CHECK_ALLOC(idx); GIT_ERROR_CHECK_ALLOC(idx);
idx->odb = odb; idx->odb = odb;
idx->progress_cb = opts.progress_cb; idx->progress_cb = opts.progress_cb;
idx->progress_payload = opts.progress_cb_payload; idx->progress_payload = opts.progress_cb_payload;
...@@ -148,7 +148,7 @@ int git_indexer_new( ...@@ -148,7 +148,7 @@ int git_indexer_new(
git_hash_ctx_init(&idx->trailer); git_hash_ctx_init(&idx->trailer);
git_buf_init(&idx->entry_data, 0); git_buf_init(&idx->entry_data, 0);
idx->expected_oids = git_oidmap_alloc(); idx->expected_oids = git_oidmap_alloc();
GITERR_CHECK_ALLOC(idx->expected_oids); GIT_ERROR_CHECK_ALLOC(idx->expected_oids);
idx->do_verify = opts.verify; idx->do_verify = opts.verify;
...@@ -204,7 +204,7 @@ static int store_delta(git_indexer *idx) ...@@ -204,7 +204,7 @@ static int store_delta(git_indexer *idx)
struct delta_info *delta; struct delta_info *delta;
delta = git__calloc(1, sizeof(struct delta_info)); delta = git__calloc(1, sizeof(struct delta_info));
GITERR_CHECK_ALLOC(delta); GIT_ERROR_CHECK_ALLOC(delta);
delta->delta_off = idx->entry_start; delta->delta_off = idx->entry_start;
if (git_vector_insert(&idx->deltas, delta) < 0) if (git_vector_insert(&idx->deltas, delta) < 0)
...@@ -410,10 +410,10 @@ static int store_object(git_indexer *idx) ...@@ -410,10 +410,10 @@ static int store_object(git_indexer *idx)
git_off_t entry_start = idx->entry_start; git_off_t entry_start = idx->entry_start;
entry = git__calloc(1, sizeof(*entry)); entry = git__calloc(1, sizeof(*entry));
GITERR_CHECK_ALLOC(entry); GIT_ERROR_CHECK_ALLOC(entry);
pentry = git__calloc(1, sizeof(struct git_pack_entry)); pentry = git__calloc(1, sizeof(struct git_pack_entry));
GITERR_CHECK_ALLOC(pentry); GIT_ERROR_CHECK_ALLOC(pentry);
git_hash_final(&oid, &idx->hash_ctx); git_hash_final(&oid, &idx->hash_ctx);
entry_size = idx->off - entry_start; entry_size = idx->off - entry_start;
...@@ -441,12 +441,12 @@ static int store_object(git_indexer *idx) ...@@ -441,12 +441,12 @@ static int store_object(git_indexer *idx)
k = git_oidmap_put(idx->pack->idx_cache, &pentry->sha1, &error); k = git_oidmap_put(idx->pack->idx_cache, &pentry->sha1, &error);
if (error == -1) { if (error == -1) {
git__free(pentry); git__free(pentry);
giterr_set_oom(); git_error_set_oom();
goto on_error; goto on_error;
} }
if (error == 0) { if (error == 0) {
giterr_set(GITERR_INDEXER, "duplicate object %s found in pack", git_oid_tostr_s(&pentry->sha1)); git_error_set(GIT_ERROR_INDEXER, "duplicate object %s found in pack", git_oid_tostr_s(&pentry->sha1));
git__free(pentry); git__free(pentry);
goto on_error; goto on_error;
} }
...@@ -496,7 +496,7 @@ static int save_entry(git_indexer *idx, struct entry *entry, struct git_pack_ent ...@@ -496,7 +496,7 @@ static int save_entry(git_indexer *idx, struct entry *entry, struct git_pack_ent
k = git_oidmap_put(idx->pack->idx_cache, &pentry->sha1, &error); k = git_oidmap_put(idx->pack->idx_cache, &pentry->sha1, &error);
if (error <= 0) { if (error <= 0) {
giterr_set(GITERR_INDEXER, "cannot insert object into pack"); git_error_set(GIT_ERROR_INDEXER, "cannot insert object into pack");
return -1; return -1;
} }
...@@ -521,15 +521,15 @@ static int hash_and_save(git_indexer *idx, git_rawobj *obj, git_off_t entry_star ...@@ -521,15 +521,15 @@ static int hash_and_save(git_indexer *idx, git_rawobj *obj, git_off_t entry_star
struct git_pack_entry *pentry = NULL; struct git_pack_entry *pentry = NULL;
entry = git__calloc(1, sizeof(*entry)); entry = git__calloc(1, sizeof(*entry));
GITERR_CHECK_ALLOC(entry); GIT_ERROR_CHECK_ALLOC(entry);
if (git_odb__hashobj(&oid, obj) < 0) { if (git_odb__hashobj(&oid, obj) < 0) {
giterr_set(GITERR_INDEXER, "failed to hash object"); git_error_set(GIT_ERROR_INDEXER, "failed to hash object");
goto on_error; goto on_error;
} }
pentry = git__calloc(1, sizeof(struct git_pack_entry)); pentry = git__calloc(1, sizeof(struct git_pack_entry));
GITERR_CHECK_ALLOC(pentry); GIT_ERROR_CHECK_ALLOC(pentry);
git_oid_cpy(&pentry->sha1, &oid); git_oid_cpy(&pentry->sha1, &oid);
git_oid_cpy(&entry->oid, &oid); git_oid_cpy(&entry->oid, &oid);
...@@ -551,7 +551,7 @@ on_error: ...@@ -551,7 +551,7 @@ on_error:
static int do_progress_callback(git_indexer *idx, git_transfer_progress *stats) static int do_progress_callback(git_indexer *idx, git_transfer_progress *stats)
{ {
if (idx->progress_cb) if (idx->progress_cb)
return giterr_set_after_callback_function( return git_error_set_after_callback_function(
idx->progress_cb(stats, idx->progress_payload), idx->progress_cb(stats, idx->progress_payload),
"indexer progress"); "indexer progress");
return 0; return 0;
...@@ -649,7 +649,7 @@ static int append_to_pack(git_indexer *idx, const void *data, size_t size) ...@@ -649,7 +649,7 @@ static int append_to_pack(git_indexer *idx, const void *data, size_t size)
if (p_lseek(fd, page_start + mmap_alignment - 1, SEEK_SET) < 0 || if (p_lseek(fd, page_start + mmap_alignment - 1, SEEK_SET) < 0 ||
p_write(idx->pack->mwf.fd, data, 1) < 0) { p_write(idx->pack->mwf.fd, data, 1) < 0) {
giterr_set(GITERR_OS, "cannot extend packfile '%s'", idx->pack->pack_name); git_error_set(GIT_ERROR_OS, "cannot extend packfile '%s'", idx->pack->pack_name);
return -1; return -1;
} }
...@@ -777,12 +777,12 @@ int git_indexer_append(git_indexer *idx, const void *data, size_t size, git_tran ...@@ -777,12 +777,12 @@ int git_indexer_append(git_indexer *idx, const void *data, size_t size, git_tran
if (idx->nr_objects <= git_indexer__max_objects) { if (idx->nr_objects <= git_indexer__max_objects) {
total_objects = (unsigned int)idx->nr_objects; total_objects = (unsigned int)idx->nr_objects;
} else { } else {
giterr_set(GITERR_INDEXER, "too many objects"); git_error_set(GIT_ERROR_INDEXER, "too many objects");
return -1; return -1;
} }
idx->pack->idx_cache = git_oidmap_alloc(); idx->pack->idx_cache = git_oidmap_alloc();
GITERR_CHECK_ALLOC(idx->pack->idx_cache); GIT_ERROR_CHECK_ALLOC(idx->pack->idx_cache);
idx->pack->has_cache = 1; idx->pack->has_cache = 1;
if (git_vector_init(&idx->objects, total_objects, objects_cmp) < 0) if (git_vector_init(&idx->objects, total_objects, objects_cmp) < 0)
...@@ -872,7 +872,7 @@ static int inject_object(git_indexer *idx, git_oid *id) ...@@ -872,7 +872,7 @@ static int inject_object(git_indexer *idx, git_oid *id)
entry_start = idx->pack->mwf.size; entry_start = idx->pack->mwf.size;
if (git_odb_read(&obj, idx->odb, id) < 0) { if (git_odb_read(&obj, idx->odb, id) < 0) {
giterr_set(GITERR_INDEXER, "missing delta bases"); git_error_set(GIT_ERROR_INDEXER, "missing delta bases");
return -1; return -1;
} }
...@@ -880,7 +880,7 @@ static int inject_object(git_indexer *idx, git_oid *id) ...@@ -880,7 +880,7 @@ static int inject_object(git_indexer *idx, git_oid *id)
len = git_odb_object_size(obj); len = git_odb_object_size(obj);
entry = git__calloc(1, sizeof(*entry)); entry = git__calloc(1, sizeof(*entry));
GITERR_CHECK_ALLOC(entry); GIT_ERROR_CHECK_ALLOC(entry);
entry->crc = crc32(0L, Z_NULL, 0); entry->crc = crc32(0L, Z_NULL, 0);
...@@ -911,7 +911,7 @@ static int inject_object(git_indexer *idx, git_oid *id) ...@@ -911,7 +911,7 @@ static int inject_object(git_indexer *idx, git_oid *id)
idx->pack->mwf.size += GIT_OID_RAWSZ; idx->pack->mwf.size += GIT_OID_RAWSZ;
pentry = git__calloc(1, sizeof(struct git_pack_entry)); pentry = git__calloc(1, sizeof(struct git_pack_entry));
GITERR_CHECK_ALLOC(pentry); GIT_ERROR_CHECK_ALLOC(pentry);
git_oid_cpy(&pentry->sha1, id); git_oid_cpy(&pentry->sha1, id);
git_oid_cpy(&entry->oid, id); git_oid_cpy(&entry->oid, id);
...@@ -945,7 +945,7 @@ static int fix_thin_pack(git_indexer *idx, git_transfer_progress *stats) ...@@ -945,7 +945,7 @@ static int fix_thin_pack(git_indexer *idx, git_transfer_progress *stats)
assert(git_vector_length(&idx->deltas) > 0); assert(git_vector_length(&idx->deltas) > 0);
if (idx->odb == NULL) { if (idx->odb == NULL) {
giterr_set(GITERR_INDEXER, "cannot fix a thin pack without an ODB"); git_error_set(GIT_ERROR_INDEXER, "cannot fix a thin pack without an ODB");
return -1; return -1;
} }
...@@ -966,14 +966,14 @@ static int fix_thin_pack(git_indexer *idx, git_transfer_progress *stats) ...@@ -966,14 +966,14 @@ static int fix_thin_pack(git_indexer *idx, git_transfer_progress *stats)
} }
if (!found_ref_delta) { if (!found_ref_delta) {
giterr_set(GITERR_INDEXER, "no REF_DELTA found, cannot inject object"); git_error_set(GIT_ERROR_INDEXER, "no REF_DELTA found, cannot inject object");
return -1; return -1;
} }
/* curpos now points to the base information, which is an OID */ /* curpos now points to the base information, which is an OID */
base_info = git_mwindow_open(&idx->pack->mwf, &w, curpos, GIT_OID_RAWSZ, &left); base_info = git_mwindow_open(&idx->pack->mwf, &w, curpos, GIT_OID_RAWSZ, &left);
if (base_info == NULL) { if (base_info == NULL) {
giterr_set(GITERR_INDEXER, "failed to map delta information"); git_error_set(GIT_ERROR_INDEXER, "failed to map delta information");
return -1; return -1;
} }
...@@ -1102,17 +1102,17 @@ int git_indexer_commit(git_indexer *idx, git_transfer_progress *stats) ...@@ -1102,17 +1102,17 @@ int git_indexer_commit(git_indexer *idx, git_transfer_progress *stats)
void *packfile_trailer; void *packfile_trailer;
if (!idx->parsed_header) { if (!idx->parsed_header) {
giterr_set(GITERR_INDEXER, "incomplete pack header"); git_error_set(GIT_ERROR_INDEXER, "incomplete pack header");
return -1; return -1;
} }
/* Test for this before resolve_deltas(), as it plays with idx->off */ /* Test for this before resolve_deltas(), as it plays with idx->off */
if (idx->off + 20 < idx->pack->mwf.size) { if (idx->off + 20 < idx->pack->mwf.size) {
giterr_set(GITERR_INDEXER, "unexpected data at the end of the pack"); git_error_set(GIT_ERROR_INDEXER, "unexpected data at the end of the pack");
return -1; return -1;
} }
if (idx->off + 20 > idx->pack->mwf.size) { if (idx->off + 20 > idx->pack->mwf.size) {
giterr_set(GITERR_INDEXER, "missing trailer at the end of the pack"); git_error_set(GIT_ERROR_INDEXER, "missing trailer at the end of the pack");
return -1; return -1;
} }
...@@ -1128,7 +1128,7 @@ int git_indexer_commit(git_indexer *idx, git_transfer_progress *stats) ...@@ -1128,7 +1128,7 @@ int git_indexer_commit(git_indexer *idx, git_transfer_progress *stats)
git_hash_final(&trailer_hash, &idx->trailer); git_hash_final(&trailer_hash, &idx->trailer);
if (git_oid_cmp(&file_hash, &trailer_hash)) { if (git_oid_cmp(&file_hash, &trailer_hash)) {
giterr_set(GITERR_INDEXER, "packfile trailer mismatch"); git_error_set(GIT_ERROR_INDEXER, "packfile trailer mismatch");
return -1; return -1;
} }
...@@ -1139,7 +1139,7 @@ int git_indexer_commit(git_indexer *idx, git_transfer_progress *stats) ...@@ -1139,7 +1139,7 @@ int git_indexer_commit(git_indexer *idx, git_transfer_progress *stats)
return error; return error;
if (stats->indexed_objects != stats->total_objects) { if (stats->indexed_objects != stats->total_objects) {
giterr_set(GITERR_INDEXER, "early EOF"); git_error_set(GIT_ERROR_INDEXER, "early EOF");
return -1; return -1;
} }
...@@ -1158,7 +1158,7 @@ int git_indexer_commit(git_indexer *idx, git_transfer_progress *stats) ...@@ -1158,7 +1158,7 @@ int git_indexer_commit(git_indexer *idx, git_transfer_progress *stats)
* packfile. * packfile.
*/ */
if (git_oidmap_size(idx->expected_oids) > 0) { if (git_oidmap_size(idx->expected_oids) > 0) {
giterr_set(GITERR_INDEXER, "packfile is missing %"PRIuZ" objects", git_error_set(GIT_ERROR_INDEXER, "packfile is missing %"PRIuZ" objects",
git_oidmap_size(idx->expected_oids)); git_oidmap_size(idx->expected_oids));
return -1; return -1;
} }
...@@ -1249,18 +1249,18 @@ int git_indexer_commit(git_indexer *idx, git_transfer_progress *stats) ...@@ -1249,18 +1249,18 @@ int git_indexer_commit(git_indexer *idx, git_transfer_progress *stats)
/* Truncate file to undo rounding up to next page_size in append_to_pack */ /* Truncate file to undo rounding up to next page_size in append_to_pack */
if (p_ftruncate(idx->pack->mwf.fd, idx->pack->mwf.size) < 0) { if (p_ftruncate(idx->pack->mwf.fd, idx->pack->mwf.size) < 0) {
giterr_set(GITERR_OS, "failed to truncate pack file '%s'", idx->pack->pack_name); git_error_set(GIT_ERROR_OS, "failed to truncate pack file '%s'", idx->pack->pack_name);
return -1; return -1;
} }
if (idx->do_fsync && p_fsync(idx->pack->mwf.fd) < 0) { if (idx->do_fsync && p_fsync(idx->pack->mwf.fd) < 0) {
giterr_set(GITERR_OS, "failed to fsync packfile"); git_error_set(GIT_ERROR_OS, "failed to fsync packfile");
goto on_error; goto on_error;
} }
/* We need to close the descriptor here so Windows doesn't choke on commit_at */ /* We need to close the descriptor here so Windows doesn't choke on commit_at */
if (p_close(idx->pack->mwf.fd) < 0) { if (p_close(idx->pack->mwf.fd) < 0) {
giterr_set(GITERR_OS, "failed to close packfile"); git_error_set(GIT_ERROR_OS, "failed to close packfile");
goto on_error; goto on_error;
} }
......
...@@ -46,14 +46,14 @@ static int iterator_range_init( ...@@ -46,14 +46,14 @@ static int iterator_range_init(
{ {
if (start && *start) { if (start && *start) {
iter->start = git__strdup(start); iter->start = git__strdup(start);
GITERR_CHECK_ALLOC(iter->start); GIT_ERROR_CHECK_ALLOC(iter->start);
iter->start_len = strlen(iter->start); iter->start_len = strlen(iter->start);
} }
if (end && *end) { if (end && *end) {
iter->end = git__strdup(end); iter->end = git__strdup(end);
GITERR_CHECK_ALLOC(iter->end); GIT_ERROR_CHECK_ALLOC(iter->end);
iter->end_len = strlen(iter->end); iter->end_len = strlen(iter->end);
} }
...@@ -146,7 +146,7 @@ static int iterator_init_common( ...@@ -146,7 +146,7 @@ static int iterator_init_common(
(iter->flags & GIT_ITERATOR_DONT_PRECOMPOSE_UNICODE) == 0) { (iter->flags & GIT_ITERATOR_DONT_PRECOMPOSE_UNICODE) == 0) {
if (git_repository__cvar(&precompose, repo, GIT_CVAR_PRECOMPOSE) < 0) if (git_repository__cvar(&precompose, repo, GIT_CVAR_PRECOMPOSE) < 0)
giterr_clear(); git_error_clear();
else if (precompose) else if (precompose)
iter->flags |= GIT_ITERATOR_PRECOMPOSE_UNICODE; iter->flags |= GIT_ITERATOR_PRECOMPOSE_UNICODE;
} }
...@@ -403,7 +403,7 @@ int git_iterator_for_nothing( ...@@ -403,7 +403,7 @@ int git_iterator_for_nothing(
*out = NULL; *out = NULL;
iter = git__calloc(1, sizeof(empty_iterator)); iter = git__calloc(1, sizeof(empty_iterator));
GITERR_CHECK_ALLOC(iter); GIT_ERROR_CHECK_ALLOC(iter);
iter->base.type = GIT_ITERATOR_TYPE_EMPTY; iter->base.type = GIT_ITERATOR_TYPE_EMPTY;
iter->base.cb = &callbacks; iter->base.cb = &callbacks;
...@@ -541,7 +541,7 @@ static int tree_iterator_frame_init( ...@@ -541,7 +541,7 @@ static int tree_iterator_frame_init(
int error = 0; int error = 0;
new_frame = git_array_alloc(iter->frames); new_frame = git_array_alloc(iter->frames);
GITERR_CHECK_ALLOC(new_frame); GIT_ERROR_CHECK_ALLOC(new_frame);
memset(new_frame, 0, sizeof(tree_iterator_frame)); memset(new_frame, 0, sizeof(tree_iterator_frame));
...@@ -564,7 +564,7 @@ static int tree_iterator_frame_init( ...@@ -564,7 +564,7 @@ static int tree_iterator_frame_init(
git_array_foreach(dup->entries, i, tree_entry) { git_array_foreach(dup->entries, i, tree_entry) {
new_entry = git_pool_malloc(&iter->entry_pool, 1); new_entry = git_pool_malloc(&iter->entry_pool, 1);
GITERR_CHECK_ALLOC(new_entry); GIT_ERROR_CHECK_ALLOC(new_entry);
new_entry->tree_entry = tree_entry; new_entry->tree_entry = tree_entry;
new_entry->parent_path = new_frame->path.ptr; new_entry->parent_path = new_frame->path.ptr;
...@@ -618,20 +618,20 @@ GIT_INLINE(int) tree_iterator_frame_push_neighbors( ...@@ -618,20 +618,20 @@ GIT_INLINE(int) tree_iterator_frame_push_neighbors(
break; break;
path = git_array_alloc(parent_frame->similar_paths); path = git_array_alloc(parent_frame->similar_paths);
GITERR_CHECK_ALLOC(path); GIT_ERROR_CHECK_ALLOC(path);
memset(path, 0, sizeof(git_buf)); memset(path, 0, sizeof(git_buf));
if ((error = tree_iterator_compute_path(path, entry)) < 0) if ((error = tree_iterator_compute_path(path, entry)) < 0)
break; break;
GITERR_CHECK_ALLOC_ADD(&new_size, GIT_ERROR_CHECK_ALLOC_ADD(&new_size,
frame->entries.length, tree->entries.size); frame->entries.length, tree->entries.size);
git_vector_size_hint(&frame->entries, new_size); git_vector_size_hint(&frame->entries, new_size);
git_array_foreach(tree->entries, i, tree_entry) { git_array_foreach(tree->entries, i, tree_entry) {
new_entry = git_pool_malloc(&iter->entry_pool, 1); new_entry = git_pool_malloc(&iter->entry_pool, 1);
GITERR_CHECK_ALLOC(new_entry); GIT_ERROR_CHECK_ALLOC(new_entry);
new_entry->tree_entry = tree_entry; new_entry->tree_entry = tree_entry;
new_entry->parent_path = path->ptr; new_entry->parent_path = path->ptr;
...@@ -947,7 +947,7 @@ int git_iterator_for_tree( ...@@ -947,7 +947,7 @@ int git_iterator_for_tree(
return git_iterator_for_nothing(out, options); return git_iterator_for_nothing(out, options);
iter = git__calloc(1, sizeof(tree_iterator)); iter = git__calloc(1, sizeof(tree_iterator));
GITERR_CHECK_ALLOC(iter); GIT_ERROR_CHECK_ALLOC(iter);
iter->base.type = GIT_ITERATOR_TYPE_TREE; iter->base.type = GIT_ITERATOR_TYPE_TREE;
iter->base.cb = &callbacks; iter->base.cb = &callbacks;
...@@ -1143,7 +1143,7 @@ static void filesystem_iterator_frame_push_ignores( ...@@ -1143,7 +1143,7 @@ static void filesystem_iterator_frame_push_ignores(
if (git_ignore__lookup(&new_frame->is_ignored, if (git_ignore__lookup(&new_frame->is_ignored,
&iter->ignores, path, GIT_DIR_FLAG_TRUE) < 0) { &iter->ignores, path, GIT_DIR_FLAG_TRUE) < 0) {
giterr_clear(); git_error_clear();
new_frame->is_ignored = GIT_IGNORE_NOTFOUND; new_frame->is_ignored = GIT_IGNORE_NOTFOUND;
} }
...@@ -1299,12 +1299,12 @@ static int filesystem_iterator_entry_init( ...@@ -1299,12 +1299,12 @@ static int filesystem_iterator_entry_init(
/* Make sure to append two bytes, one for the path's null /* Make sure to append two bytes, one for the path's null
* termination, one for a possible trailing '/' for folders. * termination, one for a possible trailing '/' for folders.
*/ */
GITERR_CHECK_ALLOC_ADD(&entry_size, GIT_ERROR_CHECK_ALLOC_ADD(&entry_size,
sizeof(filesystem_iterator_entry), path_len); sizeof(filesystem_iterator_entry), path_len);
GITERR_CHECK_ALLOC_ADD(&entry_size, entry_size, 2); GIT_ERROR_CHECK_ALLOC_ADD(&entry_size, entry_size, 2);
entry = git_pool_malloc(&frame->entry_pool, entry_size); entry = git_pool_malloc(&frame->entry_pool, entry_size);
GITERR_CHECK_ALLOC(entry); GIT_ERROR_CHECK_ALLOC(entry);
entry->path_len = path_len; entry->path_len = path_len;
entry->match = pathlist_match; entry->match = pathlist_match;
...@@ -1340,13 +1340,13 @@ static int filesystem_iterator_frame_push( ...@@ -1340,13 +1340,13 @@ static int filesystem_iterator_frame_push(
int error; int error;
if (iter->frames.size == FILESYSTEM_MAX_DEPTH) { if (iter->frames.size == FILESYSTEM_MAX_DEPTH) {
giterr_set(GITERR_REPOSITORY, git_error_set(GIT_ERROR_REPOSITORY,
"directory nesting too deep (%"PRIuZ")", iter->frames.size); "directory nesting too deep (%"PRIuZ")", iter->frames.size);
return -1; return -1;
} }
new_frame = git_array_alloc(iter->frames); new_frame = git_array_alloc(iter->frames);
GITERR_CHECK_ALLOC(new_frame); GIT_ERROR_CHECK_ALLOC(new_frame);
memset(new_frame, 0, sizeof(filesystem_iterator_frame)); memset(new_frame, 0, sizeof(filesystem_iterator_frame));
...@@ -1695,7 +1695,7 @@ static void filesystem_iterator_update_ignored(filesystem_iterator *iter) ...@@ -1695,7 +1695,7 @@ static void filesystem_iterator_update_ignored(filesystem_iterator *iter)
if (git_ignore__lookup(&iter->current_is_ignored, if (git_ignore__lookup(&iter->current_is_ignored,
&iter->ignores, iter->entry.path, dir_flag) < 0) { &iter->ignores, iter->entry.path, dir_flag) < 0) {
giterr_clear(); git_error_clear();
iter->current_is_ignored = GIT_IGNORE_NOTFOUND; iter->current_is_ignored = GIT_IGNORE_NOTFOUND;
} }
...@@ -1904,7 +1904,7 @@ static int iterator_for_filesystem( ...@@ -1904,7 +1904,7 @@ static int iterator_for_filesystem(
return git_iterator_for_nothing(out, options); return git_iterator_for_nothing(out, options);
iter = git__calloc(1, sizeof(filesystem_iterator)); iter = git__calloc(1, sizeof(filesystem_iterator));
GITERR_CHECK_ALLOC(iter); GIT_ERROR_CHECK_ALLOC(iter);
iter->base.type = type; iter->base.type = type;
iter->base.cb = &callbacks; iter->base.cb = &callbacks;
...@@ -1912,7 +1912,7 @@ static int iterator_for_filesystem( ...@@ -1912,7 +1912,7 @@ static int iterator_for_filesystem(
root_len = strlen(root); root_len = strlen(root);
iter->root = git__malloc(root_len+2); iter->root = git__malloc(root_len+2);
GITERR_CHECK_ALLOC(iter->root); GIT_ERROR_CHECK_ALLOC(iter->root);
memcpy(iter->root, root, root_len); memcpy(iter->root, root, root_len);
...@@ -2234,7 +2234,7 @@ int git_iterator_for_index( ...@@ -2234,7 +2234,7 @@ int git_iterator_for_index(
return git_iterator_for_nothing(out, options); return git_iterator_for_nothing(out, options);
iter = git__calloc(1, sizeof(index_iterator)); iter = git__calloc(1, sizeof(index_iterator));
GITERR_CHECK_ALLOC(iter); GIT_ERROR_CHECK_ALLOC(iter);
iter->base.type = GIT_ITERATOR_TYPE_INDEX; iter->base.type = GIT_ITERATOR_TYPE_INDEX;
iter->base.cb = &callbacks; iter->base.cb = &callbacks;
...@@ -2334,8 +2334,8 @@ int git_iterator_walk( ...@@ -2334,8 +2334,8 @@ int git_iterator_walk(
iterator_item = git__calloc(cnt, sizeof(git_index_entry *)); iterator_item = git__calloc(cnt, sizeof(git_index_entry *));
cur_items = git__calloc(cnt, sizeof(git_index_entry *)); cur_items = git__calloc(cnt, sizeof(git_index_entry *));
GITERR_CHECK_ALLOC(iterator_item); GIT_ERROR_CHECK_ALLOC(iterator_item);
GITERR_CHECK_ALLOC(cur_items); GIT_ERROR_CHECK_ALLOC(cur_items);
/* Set up the iterators */ /* Set up the iterators */
for (i = 0; i < cnt; i++) { for (i = 0; i < cnt; i++) {
......
...@@ -149,7 +149,7 @@ int git_mailmap_new(git_mailmap **out) ...@@ -149,7 +149,7 @@ int git_mailmap_new(git_mailmap **out)
{ {
int error; int error;
git_mailmap *mm = git__calloc(1, sizeof(git_mailmap)); git_mailmap *mm = git__calloc(1, sizeof(git_mailmap));
GITERR_CHECK_ALLOC(mm); GIT_ERROR_CHECK_ALLOC(mm);
error = git_vector_init(&mm->entries, 0, mailmap_entry_cmp); error = git_vector_init(&mm->entries, 0, mailmap_entry_cmp);
if (error < 0) { if (error < 0) {
...@@ -183,24 +183,24 @@ static int mailmap_add_entry_unterminated( ...@@ -183,24 +183,24 @@ static int mailmap_add_entry_unterminated(
{ {
int error; int error;
git_mailmap_entry *entry = git__calloc(1, sizeof(git_mailmap_entry)); git_mailmap_entry *entry = git__calloc(1, sizeof(git_mailmap_entry));
GITERR_CHECK_ALLOC(entry); GIT_ERROR_CHECK_ALLOC(entry);
assert(mm && replace_email && *replace_email); assert(mm && replace_email && *replace_email);
if (real_name_size > 0) { if (real_name_size > 0) {
entry->real_name = git__substrdup(real_name, real_name_size); entry->real_name = git__substrdup(real_name, real_name_size);
GITERR_CHECK_ALLOC(entry->real_name); GIT_ERROR_CHECK_ALLOC(entry->real_name);
} }
if (real_email_size > 0) { if (real_email_size > 0) {
entry->real_email = git__substrdup(real_email, real_email_size); entry->real_email = git__substrdup(real_email, real_email_size);
GITERR_CHECK_ALLOC(entry->real_email); GIT_ERROR_CHECK_ALLOC(entry->real_email);
} }
if (replace_name_size > 0) { if (replace_name_size > 0) {
entry->replace_name = git__substrdup(replace_name, replace_name_size); entry->replace_name = git__substrdup(replace_name, replace_name_size);
GITERR_CHECK_ALLOC(entry->replace_name); GIT_ERROR_CHECK_ALLOC(entry->replace_name);
} }
entry->replace_email = git__substrdup(replace_email, replace_email_size); entry->replace_email = git__substrdup(replace_email, replace_email_size);
GITERR_CHECK_ALLOC(entry->replace_email); GIT_ERROR_CHECK_ALLOC(entry->replace_email);
error = git_vector_insert_sorted(&mm->entries, entry, mailmap_entry_replace); error = git_vector_insert_sorted(&mm->entries, entry, mailmap_entry_replace);
if (error == GIT_EEXISTS) if (error == GIT_EEXISTS)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment