Commit 0d0fa7c3 by Russell Belfer

Convert attr, ignore, mwindow, status to new errors

Also cleaned up some previously converted code that still had
little things to polish.
parent 4cfe2ab6
...@@ -22,9 +22,9 @@ int git_attr_get( ...@@ -22,9 +22,9 @@ int git_attr_get(
*value = NULL; *value = NULL;
if ((error = git_attr_path__init( if ((error = git_attr_path__init(
&path, pathname, git_repository_workdir(repo))) < GIT_SUCCESS || &path, pathname, git_repository_workdir(repo))) < 0 ||
(error = collect_attr_files(repo, pathname, &files)) < GIT_SUCCESS) (error = collect_attr_files(repo, pathname, &files)) < 0)
return git__rethrow(error, "Could not get attribute for %s", pathname); return error;
attr.name = name; attr.name = name;
attr.name_hash = git_attr_file__name_hash(name); attr.name_hash = git_attr_file__name_hash(name);
...@@ -33,8 +33,6 @@ int git_attr_get( ...@@ -33,8 +33,6 @@ int git_attr_get(
git_attr_file__foreach_matching_rule(file, &path, j, rule) { git_attr_file__foreach_matching_rule(file, &path, j, rule) {
int pos = git_vector_bsearch(&rule->assigns, &attr); int pos = git_vector_bsearch(&rule->assigns, &attr);
git_clearerror(); /* okay if search failed */
if (pos >= 0) { if (pos >= 0) {
*value = ((git_attr_assignment *)git_vector_get( *value = ((git_attr_assignment *)git_vector_get(
&rule->assigns, pos))->value; &rule->assigns, pos))->value;
...@@ -71,14 +69,12 @@ int git_attr_get_many( ...@@ -71,14 +69,12 @@ int git_attr_get_many(
memset((void *)values, 0, sizeof(const char *) * num_attr); memset((void *)values, 0, sizeof(const char *) * num_attr);
if ((error = git_attr_path__init( if ((error = git_attr_path__init(
&path, pathname, git_repository_workdir(repo))) < GIT_SUCCESS || &path, pathname, git_repository_workdir(repo))) < 0 ||
(error = collect_attr_files(repo, pathname, &files)) < GIT_SUCCESS) (error = collect_attr_files(repo, pathname, &files)) < 0)
return git__rethrow(error, "Could not get attributes for %s", pathname); return error;
if ((info = git__calloc(num_attr, sizeof(attr_get_many_info))) == NULL) { info = git__calloc(num_attr, sizeof(attr_get_many_info));
git__rethrow(GIT_ENOMEM, "Could not get attributes for %s", pathname); GITERR_CHECK_ALLOC(info);
goto cleanup;
}
git_vector_foreach(&files, i, file) { git_vector_foreach(&files, i, file) {
...@@ -96,8 +92,6 @@ int git_attr_get_many( ...@@ -96,8 +92,6 @@ int git_attr_get_many(
} }
pos = git_vector_bsearch(&rule->assigns, &info[k].name); pos = git_vector_bsearch(&rule->assigns, &info[k].name);
git_clearerror(); /* okay if search failed */
if (pos >= 0) { if (pos >= 0) {
info[k].found = (git_attr_assignment *) info[k].found = (git_attr_assignment *)
git_vector_get(&rule->assigns, pos); git_vector_get(&rule->assigns, pos);
...@@ -133,15 +127,12 @@ int git_attr_foreach( ...@@ -133,15 +127,12 @@ int git_attr_foreach(
git_hashtable *seen = NULL; git_hashtable *seen = NULL;
if ((error = git_attr_path__init( if ((error = git_attr_path__init(
&path, pathname, git_repository_workdir(repo))) < GIT_SUCCESS || &path, pathname, git_repository_workdir(repo))) < 0 ||
(error = collect_attr_files(repo, pathname, &files)) < GIT_SUCCESS) (error = collect_attr_files(repo, pathname, &files)) < 0)
return git__rethrow(error, "Could not get attributes for %s", pathname); return error;
seen = git_hashtable_alloc(8, git_hash__strhash_cb, git_hash__strcmp_cb); seen = git_hashtable_alloc(8, git_hash__strhash_cb, git_hash__strcmp_cb);
if (!seen) { GITERR_CHECK_ALLOC(seen);
error = GIT_ENOMEM;
goto cleanup;
}
git_vector_foreach(&files, i, file) { git_vector_foreach(&files, i, file) {
...@@ -152,25 +143,19 @@ int git_attr_foreach( ...@@ -152,25 +143,19 @@ int git_attr_foreach(
if (git_hashtable_lookup(seen, assign->name)) if (git_hashtable_lookup(seen, assign->name))
continue; continue;
error = git_hashtable_insert(seen, assign->name, assign); if (!(error = git_hashtable_insert(seen, assign->name, assign)))
if (error != GIT_SUCCESS)
goto cleanup;
error = callback(assign->name, assign->value, payload); error = callback(assign->name, assign->value, payload);
if (error != GIT_SUCCESS)
if (error != 0)
goto cleanup; goto cleanup;
} }
} }
} }
cleanup: cleanup:
if (seen)
git_hashtable_free(seen); git_hashtable_free(seen);
git_vector_free(&files); git_vector_free(&files);
if (error != GIT_SUCCESS)
(void)git__rethrow(error, "Could not get attributes for %s", pathname);
return error; return error;
} }
...@@ -183,39 +168,35 @@ int git_attr_add_macro( ...@@ -183,39 +168,35 @@ int git_attr_add_macro(
int error; int error;
git_attr_rule *macro = NULL; git_attr_rule *macro = NULL;
if ((error = git_attr_cache__init(repo)) < GIT_SUCCESS) if (git_attr_cache__init(repo) < 0)
return error; return -1;
macro = git__calloc(1, sizeof(git_attr_rule)); macro = git__calloc(1, sizeof(git_attr_rule));
if (!macro) GITERR_CHECK_ALLOC(macro);
return GIT_ENOMEM;
macro->match.pattern = git__strdup(name); macro->match.pattern = git__strdup(name);
if (!macro->match.pattern) { GITERR_CHECK_ALLOC(macro->match.pattern);
git__free(macro);
return GIT_ENOMEM;
}
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;
error = git_attr_assignment__parse(repo, &macro->assigns, &values); error = git_attr_assignment__parse(repo, &macro->assigns, &values);
if (error == GIT_SUCCESS) if (!error)
error = git_attr_cache__insert_macro(repo, macro); error = git_attr_cache__insert_macro(repo, macro);
if (error < GIT_SUCCESS) if (error < 0)
git_attr_rule__free(macro); git_attr_rule__free(macro);
return error; return error;
} }
int git_attr_cache__is_cached(git_repository *repo, const char *path) bool git_attr_cache__is_cached(git_repository *repo, const char *path)
{ {
const char *cache_key = path; const char *cache_key = path;
if (repo && git__prefixcmp(cache_key, git_repository_workdir(repo)) == 0) if (repo && git__prefixcmp(cache_key, git_repository_workdir(repo)) == 0)
cache_key += strlen(git_repository_workdir(repo)); cache_key += strlen(git_repository_workdir(repo));
return (git_hashtable_lookup(repo->attrcache.files, cache_key) == NULL); return (git_hashtable_lookup(repo->attrcache.files, cache_key) != NULL);
} }
int git_attr_cache__lookup_or_create_file( int git_attr_cache__lookup_or_create_file(
...@@ -229,29 +210,28 @@ int git_attr_cache__lookup_or_create_file( ...@@ -229,29 +210,28 @@ int git_attr_cache__lookup_or_create_file(
git_attr_cache *cache = &repo->attrcache; git_attr_cache *cache = &repo->attrcache;
git_attr_file *file = NULL; git_attr_file *file = NULL;
file = git_hashtable_lookup(cache->files, key); if ((file = git_hashtable_lookup(cache->files, key)) != NULL) {
if (file) {
*file_ptr = file; *file_ptr = file;
return GIT_SUCCESS; return 0;
} }
if (loader && git_path_exists(filename) == false) { if (loader && git_path_exists(filename) == false) {
*file_ptr = NULL; *file_ptr = NULL;
return GIT_SUCCESS; return 0;
} }
if ((error = git_attr_file__new(&file)) < GIT_SUCCESS) if (git_attr_file__new(&file) < 0)
return error; return -1;
if (loader) if (loader)
error = loader(repo, filename, file); error = loader(repo, filename, file);
else else
error = git_attr_file__set_path(repo, key, file); error = git_attr_file__set_path(repo, key, file);
if (error == GIT_SUCCESS) if (!error)
error = git_hashtable_insert(cache->files, file->path, file); error = git_hashtable_insert(cache->files, file->path, file);
if (error < GIT_SUCCESS) { if (error < 0) {
git_attr_file__free(file); git_attr_file__free(file);
file = NULL; file = NULL;
} }
...@@ -274,8 +254,8 @@ int git_attr_cache__push_file( ...@@ -274,8 +254,8 @@ int git_attr_cache__push_file(
const char *cache_key; const char *cache_key;
if (base != NULL) { if (base != NULL) {
if ((error = git_buf_joinpath(&path, base, filename)) < GIT_SUCCESS) if (git_buf_joinpath(&path, base, filename) < 0)
return error; return -1;
filename = path.ptr; filename = path.ptr;
} }
...@@ -287,7 +267,7 @@ int git_attr_cache__push_file( ...@@ -287,7 +267,7 @@ int git_attr_cache__push_file(
error = git_attr_cache__lookup_or_create_file( error = git_attr_cache__lookup_or_create_file(
repo, cache_key, filename, loader, &file); repo, cache_key, filename, loader, &file);
if (error == GIT_SUCCESS && file != NULL) if (!error && file != NULL)
error = git_vector_insert(stack, file); error = git_vector_insert(stack, file);
git_buf_free(&path); git_buf_free(&path);
...@@ -311,7 +291,7 @@ static int push_one_attr(void *ref, git_buf *path) ...@@ -311,7 +291,7 @@ static int push_one_attr(void *ref, git_buf *path)
static int collect_attr_files( static int collect_attr_files(
git_repository *repo, const char *path, git_vector *files) git_repository *repo, const char *path, git_vector *files)
{ {
int error = GIT_SUCCESS; int error;
git_buf dir = GIT_BUF_INIT; git_buf dir = GIT_BUF_INIT;
git_config *cfg; git_config *cfg;
const char *workdir = git_repository_workdir(repo); const char *workdir = git_repository_workdir(repo);
...@@ -342,7 +322,7 @@ static int collect_attr_files( ...@@ -342,7 +322,7 @@ static int collect_attr_files(
if (error < 0) if (error < 0)
goto cleanup; goto cleanup;
if ((error = git_repository_config(&cfg, repo)) == GIT_SUCCESS) { if (!(error = git_repository_config(&cfg, repo))) {
const char *core_attribs = NULL; const char *core_attribs = NULL;
git_config_get_string(cfg, GIT_ATTR_CONFIG, &core_attribs); git_config_get_string(cfg, GIT_ATTR_CONFIG, &core_attribs);
git_clearerror(); /* don't care if attributesfile is not set */ git_clearerror(); /* don't care if attributesfile is not set */
...@@ -392,7 +372,7 @@ int git_attr_cache__init(git_repository *repo) ...@@ -392,7 +372,7 @@ int git_attr_cache__init(git_repository *repo)
cache->initialized = 1; cache->initialized = 1;
/* insert default macros */ /* insert default macros */
return git_attr_add_macro(repo, "binary", "-diff -crlf"); return git_attr_add_macro(repo, "binary", "-diff -crlf -text");
} }
void git_attr_cache_flush( void git_attr_cache_flush(
......
...@@ -34,7 +34,7 @@ extern int git_attr_cache__push_file( ...@@ -34,7 +34,7 @@ extern int git_attr_cache__push_file(
const char *filename, const char *filename,
int (*loader)(git_repository *, const char *, git_attr_file *)); int (*loader)(git_repository *, const char *, git_attr_file *));
/* returns GIT_SUCCESS if path is in cache */ /* returns true if path is in cache */
extern int git_attr_cache__is_cached(git_repository *repo, const char *path); extern bool git_attr_cache__is_cached(git_repository *repo, const char *path);
#endif #endif
...@@ -287,7 +287,7 @@ int git_attr_path__init( ...@@ -287,7 +287,7 @@ int git_attr_path__init(
*/ */
/* /*
* This will return GIT_SUCCESS if the spec was filled out, * This will return 0 if the spec was filled out,
* GIT_ENOTFOUND if the fnmatch does not require matching, or * GIT_ENOTFOUND if the fnmatch does not require matching, or
* another error code there was an actual problem. * another error code there was an actual problem.
*/ */
......
...@@ -150,7 +150,7 @@ static int write_symlink( ...@@ -150,7 +150,7 @@ static int write_symlink(
int git_blob_create_fromfile(git_oid *oid, git_repository *repo, const char *path) int git_blob_create_fromfile(git_oid *oid, git_repository *repo, const char *path)
{ {
int error = GIT_SUCCESS; int error;
git_buf full_path = GIT_BUF_INIT; git_buf full_path = GIT_BUF_INIT;
git_off_t size; git_off_t size;
struct stat st; struct stat st;
......
...@@ -17,8 +17,8 @@ char git_buf_initbuf[1]; ...@@ -17,8 +17,8 @@ char git_buf_initbuf[1];
static char git_buf__oom; static char git_buf__oom;
#define ENSURE_SIZE(b, d) \ #define ENSURE_SIZE(b, d) \
if ((d) > buf->asize && git_buf_grow(b, (d)) < GIT_SUCCESS)\ if ((d) > buf->asize && git_buf_grow(b, (d)) < 0)\
return GIT_ENOMEM; return -1;
void git_buf_init(git_buf *buf, size_t initial_size) void git_buf_init(git_buf *buf, size_t initial_size)
...@@ -34,10 +34,8 @@ void git_buf_init(git_buf *buf, size_t initial_size) ...@@ -34,10 +34,8 @@ void git_buf_init(git_buf *buf, size_t initial_size)
int git_buf_grow(git_buf *buf, size_t target_size) int git_buf_grow(git_buf *buf, size_t target_size)
{ {
int error = git_buf_try_grow(buf, target_size); int error = git_buf_try_grow(buf, target_size);
if (error != GIT_SUCCESS) { if (error != 0)
buf->ptr = &git_buf__oom; buf->ptr = &git_buf__oom;
}
return error; return error;
} }
...@@ -47,10 +45,10 @@ int git_buf_try_grow(git_buf *buf, size_t target_size) ...@@ -47,10 +45,10 @@ int git_buf_try_grow(git_buf *buf, size_t target_size)
size_t new_size; size_t new_size;
if (buf->ptr == &git_buf__oom) if (buf->ptr == &git_buf__oom)
return GIT_ENOMEM; return -1;
if (target_size <= buf->asize) if (target_size <= buf->asize)
return GIT_SUCCESS; return 0;
if (buf->asize == 0) { if (buf->asize == 0) {
new_size = target_size; new_size = target_size;
...@@ -80,7 +78,7 @@ int git_buf_try_grow(git_buf *buf, size_t target_size) ...@@ -80,7 +78,7 @@ int git_buf_try_grow(git_buf *buf, size_t target_size)
buf->size = buf->asize - 1; buf->size = buf->asize - 1;
buf->ptr[buf->size] = '\0'; buf->ptr[buf->size] = '\0';
return GIT_SUCCESS; return 0;
} }
void git_buf_free(git_buf *buf) void git_buf_free(git_buf *buf)
...@@ -117,7 +115,7 @@ int git_buf_set(git_buf *buf, const char *data, size_t len) ...@@ -117,7 +115,7 @@ int git_buf_set(git_buf *buf, const char *data, size_t len)
buf->size = len; buf->size = len;
buf->ptr[buf->size] = '\0'; buf->ptr[buf->size] = '\0';
} }
return GIT_SUCCESS; return 0;
} }
int git_buf_sets(git_buf *buf, const char *string) int git_buf_sets(git_buf *buf, const char *string)
...@@ -130,7 +128,7 @@ int git_buf_putc(git_buf *buf, char c) ...@@ -130,7 +128,7 @@ int git_buf_putc(git_buf *buf, char c)
ENSURE_SIZE(buf, buf->size + 2); ENSURE_SIZE(buf, buf->size + 2);
buf->ptr[buf->size++] = c; buf->ptr[buf->size++] = c;
buf->ptr[buf->size] = '\0'; buf->ptr[buf->size] = '\0';
return GIT_SUCCESS; return 0;
} }
int git_buf_put(git_buf *buf, const char *data, size_t len) int git_buf_put(git_buf *buf, const char *data, size_t len)
...@@ -139,7 +137,7 @@ int git_buf_put(git_buf *buf, const char *data, size_t len) ...@@ -139,7 +137,7 @@ int git_buf_put(git_buf *buf, const char *data, size_t len)
memmove(buf->ptr + buf->size, data, len); memmove(buf->ptr + buf->size, data, len);
buf->size += len; buf->size += len;
buf->ptr[buf->size] = '\0'; buf->ptr[buf->size] = '\0';
return GIT_SUCCESS; return 0;
} }
int git_buf_puts(git_buf *buf, const char *string) int git_buf_puts(git_buf *buf, const char *string)
...@@ -163,7 +161,7 @@ int git_buf_printf(git_buf *buf, const char *format, ...) ...@@ -163,7 +161,7 @@ int git_buf_printf(git_buf *buf, const char *format, ...)
if (len < 0) { if (len < 0) {
free(buf->ptr); free(buf->ptr);
buf->ptr = &git_buf__oom; buf->ptr = &git_buf__oom;
return GIT_ENOMEM; return -1;
} }
if ((size_t)len + 1 <= buf->asize - buf->size) { if ((size_t)len + 1 <= buf->asize - buf->size) {
...@@ -174,7 +172,7 @@ int git_buf_printf(git_buf *buf, const char *format, ...) ...@@ -174,7 +172,7 @@ int git_buf_printf(git_buf *buf, const char *format, ...)
ENSURE_SIZE(buf, buf->size + len + 1); ENSURE_SIZE(buf, buf->size + len + 1);
} }
return GIT_SUCCESS; return 0;
} }
void git_buf_copy_cstr(char *data, size_t datasize, const git_buf *buf) void git_buf_copy_cstr(char *data, size_t datasize, const git_buf *buf)
...@@ -257,7 +255,7 @@ void git_buf_attach(git_buf *buf, char *ptr, size_t asize) ...@@ -257,7 +255,7 @@ void git_buf_attach(git_buf *buf, char *ptr, size_t asize)
int git_buf_join_n(git_buf *buf, char separator, int nbuf, ...) int git_buf_join_n(git_buf *buf, char separator, int nbuf, ...)
{ {
va_list ap; va_list ap;
int i, error = GIT_SUCCESS; int i;
size_t total_size = 0; size_t total_size = 0;
char *out; char *out;
...@@ -284,8 +282,8 @@ int git_buf_join_n(git_buf *buf, char separator, int nbuf, ...) ...@@ -284,8 +282,8 @@ int git_buf_join_n(git_buf *buf, char separator, int nbuf, ...)
/* expand buffer if needed */ /* expand buffer if needed */
if (total_size > 0 && if (total_size > 0 &&
(error = git_buf_grow(buf, buf->size + total_size + 1)) < GIT_SUCCESS) git_buf_grow(buf, buf->size + total_size + 1) < 0)
return error; return -1;
out = buf->ptr + buf->size; out = buf->ptr + buf->size;
...@@ -323,7 +321,7 @@ int git_buf_join_n(git_buf *buf, char separator, int nbuf, ...) ...@@ -323,7 +321,7 @@ int git_buf_join_n(git_buf *buf, char separator, int nbuf, ...)
buf->size = out - buf->ptr; buf->size = out - buf->ptr;
buf->ptr[buf->size] = '\0'; buf->ptr[buf->size] = '\0';
return error; return 0;
} }
int git_buf_join( int git_buf_join(
...@@ -332,7 +330,6 @@ int git_buf_join( ...@@ -332,7 +330,6 @@ int git_buf_join(
const char *str_a, const char *str_a,
const char *str_b) const char *str_b)
{ {
int error = GIT_SUCCESS;
size_t strlen_a = str_a ? strlen(str_a) : 0; size_t strlen_a = str_a ? strlen(str_a) : 0;
size_t strlen_b = strlen(str_b); size_t strlen_b = strlen(str_b);
int need_sep = 0; int need_sep = 0;
...@@ -352,9 +349,8 @@ int git_buf_join( ...@@ -352,9 +349,8 @@ 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;
error = git_buf_grow(buf, strlen_a + strlen_b + need_sep + 1); if (git_buf_grow(buf, strlen_a + strlen_b + need_sep + 1) < 0)
if (error < GIT_SUCCESS) return -1;
return error;
/* fix up internal pointers */ /* fix up internal pointers */
if (offset_a >= 0) if (offset_a >= 0)
...@@ -370,7 +366,7 @@ int git_buf_join( ...@@ -370,7 +366,7 @@ int git_buf_join(
buf->size = strlen_a + strlen_b + need_sep; buf->size = strlen_a + strlen_b + need_sep;
buf->ptr[buf->size] = '\0'; buf->ptr[buf->size] = '\0';
return error; return 0;
} }
void git_buf_rtrim(git_buf *buf) void git_buf_rtrim(git_buf *buf)
......
...@@ -32,7 +32,7 @@ void git_buf_init(git_buf *buf, size_t initial_size); ...@@ -32,7 +32,7 @@ void git_buf_init(git_buf *buf, size_t initial_size);
* If the allocation fails, this will return an error and the buffer * If the allocation fails, this will return an error and the buffer
* will be marked as invalid for future operations. The existing * will be marked as invalid for future operations. The existing
* contents of the buffer will be preserved however. * contents of the buffer will be preserved however.
* @return GIT_SUCCESS or GIT_ENOMEM on failure * @return 0 on success or -1 on failure
*/ */
int git_buf_grow(git_buf *buf, size_t target_size); int git_buf_grow(git_buf *buf, size_t target_size);
...@@ -63,12 +63,12 @@ void git_buf_attach(git_buf *buf, char *ptr, size_t asize); ...@@ -63,12 +63,12 @@ void git_buf_attach(git_buf *buf, char *ptr, size_t asize);
bool git_buf_oom(const git_buf *buf); bool git_buf_oom(const git_buf *buf);
/* /*
* The functions below that return int values, will return GIT_ENOMEM * Functions below that return int value error codes will return 0 on
* if they fail to expand the git_buf when they are called, otherwise * success or -1 on failure (which generally means an allocation failed).
* GIT_SUCCESS. Passing a git_buf that has failed an allocation will * Using a git_buf where the allocation has failed with result in -1 from
* automatically return GIT_ENOMEM for all further calls. As a result, * all further calls using that buffer. As a result, you can ignore the
* you can ignore the return code of these functions and call them in a * return code of these functions and call them in a series then just call
* series then just call git_buf_lasterror at the end. * git_buf_oom at the end.
*/ */
int git_buf_set(git_buf *buf, const char *data, size_t len); int git_buf_set(git_buf *buf, const char *data, size_t len);
int git_buf_sets(git_buf *buf, const char *string); int git_buf_sets(git_buf *buf, const char *string);
...@@ -86,7 +86,7 @@ int git_buf_join(git_buf *buf, char separator, const char *str_a, const char *st ...@@ -86,7 +86,7 @@ int git_buf_join(git_buf *buf, char separator, const char *str_a, const char *st
/** /**
* Join two strings as paths, inserting a slash between as needed. * Join two strings as paths, inserting a slash between as needed.
* @return error code or GIT_SUCCESS * @return 0 on success, -1 on failure
*/ */
GIT_INLINE(int) git_buf_joinpath(git_buf *buf, const char *a, const char *b) GIT_INLINE(int) git_buf_joinpath(git_buf *buf, const char *a, const char *b)
{ {
......
...@@ -32,11 +32,10 @@ int git_cache_init(git_cache *cache, size_t size, git_cached_obj_freeptr free_pt ...@@ -32,11 +32,10 @@ int git_cache_init(git_cache *cache, size_t size, git_cached_obj_freeptr free_pt
git_mutex_init(&cache->lock); git_mutex_init(&cache->lock);
cache->nodes = git__malloc(size * sizeof(git_cached_obj *)); cache->nodes = git__malloc(size * sizeof(git_cached_obj *));
if (cache->nodes == NULL) GITERR_CHECK_ALLOC(cache->nodes);
return GIT_ENOMEM;
memset(cache->nodes, 0x0, size * sizeof(git_cached_obj *)); memset(cache->nodes, 0x0, size * sizeof(git_cached_obj *));
return GIT_SUCCESS; return 0;
} }
void git_cache_free(git_cache *cache) void git_cache_free(git_cache *cache)
......
...@@ -249,14 +249,14 @@ static git_diff_list *git_diff_list_alloc( ...@@ -249,14 +249,14 @@ static git_diff_list *git_diff_list_alloc(
diff->opts.dst_prefix = swap; diff->opts.dst_prefix = swap;
} }
if (git_vector_init(&diff->deltas, 0, diff_delta__cmp) < GIT_SUCCESS) { if (git_vector_init(&diff->deltas, 0, diff_delta__cmp) < 0) {
git__free(diff->opts.src_prefix); git__free(diff->opts.src_prefix);
git__free(diff->opts.dst_prefix); git__free(diff->opts.dst_prefix);
git__free(diff); git__free(diff);
return NULL; return NULL;
} }
/* do something safe with the pathspec strarray */ /* TODO: do something safe with the pathspec strarray */
return diff; return diff;
} }
......
...@@ -91,7 +91,7 @@ static int lock_file(git_filebuf *file, int flags) ...@@ -91,7 +91,7 @@ static int lock_file(git_filebuf *file, int flags)
p_close(source); p_close(source);
} }
return GIT_SUCCESS; return 0;
} }
void git_filebuf_cleanup(git_filebuf *file) void git_filebuf_cleanup(git_filebuf *file)
......
...@@ -208,13 +208,19 @@ int git_futils_mmap_ro(git_map *out, git_file fd, git_off_t begin, size_t len) ...@@ -208,13 +208,19 @@ int git_futils_mmap_ro(git_map *out, git_file fd, git_off_t begin, size_t len)
int git_futils_mmap_ro_file(git_map *out, const char *path) int git_futils_mmap_ro_file(git_map *out, const char *path)
{ {
git_file fd = p_open(path, O_RDONLY /* | O_NOATIME */); git_file fd = git_futils_open_ro(path);
git_off_t len = git_futils_filesize(fd); git_off_t len;
int result; int result;
if (fd < 0)
return fd;
len = git_futils_filesize(fd);
if (!git__is_sizet(len)) { if (!git__is_sizet(len)) {
giterr_set(GITERR_OS, "File `%s` too large to mmap", path); giterr_set(GITERR_OS, "File `%s` too large to mmap", path);
return -1; return -1;
} }
result = git_futils_mmap_ro(out, fd, 0, (size_t)len); result = git_futils_mmap_ro(out, fd, 0, (size_t)len);
p_close(fd); p_close(fd);
return result; return result;
......
...@@ -26,7 +26,7 @@ extern int git_futils_readbuffer_updated(git_buf *obj, const char *path, time_t ...@@ -26,7 +26,7 @@ extern int git_futils_readbuffer_updated(git_buf *obj, const char *path, time_t
* These are custom filesystem-related helper methods. They are * These are custom filesystem-related helper methods. They are
* rather high level, and wrap the underlying POSIX methods * rather high level, and wrap the underlying POSIX methods
* *
* All these methods return GIT_SUCCESS on success, * All these methods return 0 on success,
* or an error code on failure and an error message is set. * or an error code on failure and an error message is set.
*/ */
...@@ -108,8 +108,8 @@ extern mode_t git_futils_canonical_mode(mode_t raw_mode); ...@@ -108,8 +108,8 @@ extern mode_t git_futils_canonical_mode(mode_t raw_mode);
* @param begin first byte to map, this should be page aligned. * @param begin first byte to map, this should be page aligned.
* @param end number of bytes to map. * @param end number of bytes to map.
* @return * @return
* - GIT_SUCCESS on success; * - 0 on success;
* - GIT_EOSERR on an unspecified OS related error. * - -1 on error.
*/ */
extern int git_futils_mmap_ro( extern int git_futils_mmap_ro(
git_map *out, git_map *out,
...@@ -123,8 +123,9 @@ extern int git_futils_mmap_ro( ...@@ -123,8 +123,9 @@ extern int git_futils_mmap_ro(
* @param out buffer to populate with the mapping information. * @param out buffer to populate with the mapping information.
* @param path path to file to be opened. * @param path path to file to be opened.
* @return * @return
* - GIT_SUCCESS on success; * - 0 on success;
* - GIT_EOSERR on an unspecified OS related error. * - GIT_ENOTFOUND if not found;
* - -1 on an unspecified OS related error.
*/ */
extern int git_futils_mmap_ro_file( extern int git_futils_mmap_ro_file(
git_map *out, git_map *out,
...@@ -142,9 +143,9 @@ extern void git_futils_mmap_free(git_map *map); ...@@ -142,9 +143,9 @@ extern void git_futils_mmap_free(git_map *map);
* @param pathbuf buffer to write the full path into * @param pathbuf buffer to write the full path into
* @param filename name of file to find in the home directory * @param filename name of file to find in the home directory
* @return * @return
* - GIT_SUCCESS if found; * - 0 if found;
* - GIT_ENOTFOUND if not found; * - GIT_ENOTFOUND if not found;
* - GIT_EOSERR on an unspecified OS related error. * - -1 on an unspecified OS related error.
*/ */
extern int git_futils_find_global_file(git_buf *path, const char *filename); extern int git_futils_find_global_file(git_buf *path, const char *filename);
...@@ -154,9 +155,9 @@ extern int git_futils_find_global_file(git_buf *path, const char *filename); ...@@ -154,9 +155,9 @@ extern int git_futils_find_global_file(git_buf *path, const char *filename);
* @param pathbuf buffer to write the full path into * @param pathbuf buffer to write the full path into
* @param filename name of file to find in the home directory * @param filename name of file to find in the home directory
* @return * @return
* - GIT_SUCCESS if found; * - 0 if found;
* - GIT_ENOTFOUND if not found; * - GIT_ENOTFOUND if not found;
* - GIT_EOSERR on an unspecified OS related error. * - -1 on an unspecified OS related error.
*/ */
extern int git_futils_find_system_file(git_buf *path, const char *filename); extern int git_futils_find_system_file(git_buf *path, const char *filename);
......
...@@ -10,30 +10,31 @@ ...@@ -10,30 +10,31 @@
static int load_ignore_file( static int load_ignore_file(
git_repository *repo, const char *path, git_attr_file *ignores) git_repository *repo, const char *path, git_attr_file *ignores)
{ {
int error = GIT_SUCCESS; int error;
git_buf fbuf = GIT_BUF_INIT; git_buf fbuf = GIT_BUF_INIT;
git_attr_fnmatch *match = NULL; git_attr_fnmatch *match = NULL;
const char *scan = NULL; const char *scan = NULL;
char *context = NULL; char *context = NULL;
if (ignores->path == NULL) if (ignores->path == NULL) {
error = git_attr_file__set_path(repo, path, ignores); if (git_attr_file__set_path(repo, path, ignores) < 0)
return -1;
}
if (git__suffixcmp(ignores->path, GIT_IGNORE_FILE) == 0) { if (git__suffixcmp(ignores->path, GIT_IGNORE_FILE) == 0) {
context = git__strndup(ignores->path, context = git__strndup(ignores->path,
strlen(ignores->path) - strlen(GIT_IGNORE_FILE)); strlen(ignores->path) - strlen(GIT_IGNORE_FILE));
if (!context) error = GIT_ENOMEM; GITERR_CHECK_ALLOC(context);
} }
if (error == GIT_SUCCESS)
error = git_futils_readbuffer(&fbuf, path); error = git_futils_readbuffer(&fbuf, path);
scan = fbuf.ptr; scan = fbuf.ptr;
while (error == GIT_SUCCESS && *scan) { while (!error && *scan) {
if (!match && !(match = git__calloc(1, sizeof(git_attr_fnmatch)))) { if (!match) {
error = GIT_ENOMEM; match = git__calloc(1, sizeof(*match));
break; GITERR_CHECK_ALLOC(match);
} }
if (!(error = git_attr_fnmatch__parse(match, context, &scan))) { if (!(error = git_attr_fnmatch__parse(match, context, &scan))) {
...@@ -42,12 +43,12 @@ static int load_ignore_file( ...@@ -42,12 +43,12 @@ static int load_ignore_file(
error = git_vector_insert(&ignores->rules, match); error = git_vector_insert(&ignores->rules, match);
} }
if (error != GIT_SUCCESS) { if (error != 0) {
git__free(match->pattern); git__free(match->pattern);
match->pattern = NULL; match->pattern = NULL;
if (error == GIT_ENOTFOUND) if (error == GIT_ENOTFOUND)
error = GIT_SUCCESS; error = 0;
} else { } else {
match = NULL; /* vector now "owns" the match */ match = NULL; /* vector now "owns" the match */
} }
...@@ -57,9 +58,6 @@ static int load_ignore_file( ...@@ -57,9 +58,6 @@ static int load_ignore_file(
git__free(match); git__free(match);
git__free(context); git__free(context);
if (error != GIT_SUCCESS)
git__rethrow(error, "Could not open ignore file '%s'", path);
return error; return error;
} }
...@@ -74,7 +72,7 @@ static int push_one_ignore(void *ref, git_buf *path) ...@@ -74,7 +72,7 @@ static int push_one_ignore(void *ref, git_buf *path)
int git_ignore__for_path(git_repository *repo, const char *path, git_ignores *ignores) int git_ignore__for_path(git_repository *repo, const char *path, git_ignores *ignores)
{ {
int error = GIT_SUCCESS; int error = 0;
git_config *cfg; git_config *cfg;
const char *workdir = git_repository_workdir(repo); const char *workdir = git_repository_workdir(repo);
...@@ -83,63 +81,59 @@ int git_ignore__for_path(git_repository *repo, const char *path, git_ignores *ig ...@@ -83,63 +81,59 @@ int git_ignore__for_path(git_repository *repo, const char *path, git_ignores *ig
ignores->repo = repo; ignores->repo = repo;
git_buf_init(&ignores->dir, 0); git_buf_init(&ignores->dir, 0);
ignores->ign_internal = NULL; ignores->ign_internal = NULL;
git_vector_init(&ignores->ign_path, 8, NULL);
git_vector_init(&ignores->ign_global, 2, NULL);
if ((error = git_attr_cache__init(repo)) < GIT_SUCCESS) if ((error = git_vector_init(&ignores->ign_path, 8, NULL)) < 0 ||
(error = git_vector_init(&ignores->ign_global, 2, NULL)) < 0 ||
(error = git_attr_cache__init(repo)) < 0)
goto cleanup; goto cleanup;
if ((error = git_path_find_dir(&ignores->dir, path, workdir)) < GIT_SUCCESS) /* translate path into directory within workdir */
if ((error = git_path_find_dir(&ignores->dir, path, workdir)) < 0)
goto cleanup; goto cleanup;
/* set up internals */ /* set up internals */
error = git_attr_cache__lookup_or_create_file( error = git_attr_cache__lookup_or_create_file(
repo, GIT_IGNORE_INTERNAL, NULL, NULL, &ignores->ign_internal); repo, GIT_IGNORE_INTERNAL, NULL, NULL, &ignores->ign_internal);
if (error < GIT_SUCCESS) if (error < 0)
goto cleanup; goto cleanup;
/* load .gitignore up the path */ /* load .gitignore up the path */
error = git_path_walk_up(&ignores->dir, workdir, push_one_ignore, ignores); error = git_path_walk_up(&ignores->dir, workdir, push_one_ignore, ignores);
if (error < GIT_SUCCESS) if (error < 0)
goto cleanup; goto cleanup;
/* load .git/info/exclude */ /* load .git/info/exclude */
error = push_ignore(repo, &ignores->ign_global, error = push_ignore(repo, &ignores->ign_global,
repo->path_repository, GIT_IGNORE_FILE_INREPO); repo->path_repository, GIT_IGNORE_FILE_INREPO);
if (error < GIT_SUCCESS) if (error < 0)
goto cleanup; goto cleanup;
/* load core.excludesfile */ /* load core.excludesfile */
if ((error = git_repository_config(&cfg, repo)) == GIT_SUCCESS) { if ((error = git_repository_config(&cfg, repo)) == 0) {
const char *core_ignore; const char *core_ignore;
error = git_config_get_string(cfg, GIT_IGNORE_CONFIG, &core_ignore); error = git_config_get_string(cfg, GIT_IGNORE_CONFIG, &core_ignore);
if (error == GIT_SUCCESS && core_ignore != NULL) if (error == 0 && core_ignore != NULL)
error = push_ignore(repo, &ignores->ign_global, NULL, core_ignore); error = push_ignore(repo, &ignores->ign_global, NULL, core_ignore);
else { else {
error = GIT_SUCCESS; error = 0;
git_clearerror(); /* don't care if attributesfile is not set */ giterr_clear(); /* don't care if attributesfile is not set */
} }
git_config_free(cfg); git_config_free(cfg);
} }
cleanup: cleanup:
if (error < GIT_SUCCESS) { if (error < 0)
git_ignore__free(ignores); git_ignore__free(ignores);
git__rethrow(error, "Could not get ignore files for '%s'", path);
}
return error; return error;
} }
int git_ignore__push_dir(git_ignores *ign, const char *dir) int git_ignore__push_dir(git_ignores *ign, const char *dir)
{ {
int error = git_buf_joinpath(&ign->dir, ign->dir.ptr, dir); if (git_buf_joinpath(&ign->dir, ign->dir.ptr, dir) < 0)
return -1;
if (error == GIT_SUCCESS) else
error = push_ignore( return push_ignore(
ign->repo, &ign->ign_path, ign->dir.ptr, GIT_IGNORE_FILE); ign->repo, &ign->ign_path, ign->dir.ptr, GIT_IGNORE_FILE);
return error;
} }
int git_ignore__pop_dir(git_ignores *ign) int git_ignore__pop_dir(git_ignores *ign)
...@@ -150,7 +144,7 @@ int git_ignore__pop_dir(git_ignores *ign) ...@@ -150,7 +144,7 @@ int git_ignore__pop_dir(git_ignores *ign)
git_vector_pop(&ign->ign_path); git_vector_pop(&ign->ign_path);
git_buf_rtruncate_at_char(&ign->dir, '/'); git_buf_rtruncate_at_char(&ign->dir, '/');
} }
return GIT_SUCCESS; return 0;
} }
void git_ignore__free(git_ignores *ignores) void git_ignore__free(git_ignores *ignores)
...@@ -161,7 +155,7 @@ void git_ignore__free(git_ignores *ignores) ...@@ -161,7 +155,7 @@ void git_ignore__free(git_ignores *ignores)
git_buf_free(&ignores->dir); git_buf_free(&ignores->dir);
} }
static int ignore_lookup_in_rules( static bool ignore_lookup_in_rules(
git_vector *rules, git_attr_path *path, int *ignored) git_vector *rules, git_attr_path *path, int *ignored)
{ {
unsigned int j; unsigned int j;
...@@ -170,45 +164,40 @@ static int ignore_lookup_in_rules( ...@@ -170,45 +164,40 @@ static int ignore_lookup_in_rules(
git_vector_rforeach(rules, j, match) { git_vector_rforeach(rules, j, match) {
if (git_attr_fnmatch__match(match, path)) { if (git_attr_fnmatch__match(match, path)) {
*ignored = ((match->flags & GIT_ATTR_FNMATCH_NEGATIVE) == 0); *ignored = ((match->flags & GIT_ATTR_FNMATCH_NEGATIVE) == 0);
return 0; return true;
} }
} }
return GIT_ENOTFOUND; return false;
} }
int git_ignore__lookup(git_ignores *ignores, const char *pathname, int *ignored) int git_ignore__lookup(git_ignores *ignores, const char *pathname, int *ignored)
{ {
int error;
unsigned int i; unsigned int i;
git_attr_file *file; git_attr_file *file;
git_attr_path path; git_attr_path path;
if ((error = git_attr_path__init( if (git_attr_path__init(
&path, pathname, git_repository_workdir(ignores->repo))) < GIT_SUCCESS) &path, pathname, git_repository_workdir(ignores->repo)) < 0)
return git__rethrow(error, "Could not get attribute for '%s'", pathname); return -1;
/* first process builtins */ /* first process builtins - success means path was found */
error = ignore_lookup_in_rules( if (ignore_lookup_in_rules(
&ignores->ign_internal->rules, &path, ignored); &ignores->ign_internal->rules, &path, ignored))
if (error == GIT_SUCCESS) return 0;
return error;
/* next process files in the path */ /* next process files in the path */
git_vector_foreach(&ignores->ign_path, i, file) { git_vector_foreach(&ignores->ign_path, i, file) {
error = ignore_lookup_in_rules(&file->rules, &path, ignored); if (ignore_lookup_in_rules(&file->rules, &path, ignored))
if (error == GIT_SUCCESS) return 0;
return error;
} }
/* last process global ignores */ /* last process global ignores */
git_vector_foreach(&ignores->ign_global, i, file) { git_vector_foreach(&ignores->ign_global, i, file) {
error = ignore_lookup_in_rules(&file->rules, &path, ignored); if (ignore_lookup_in_rules(&file->rules, &path, ignored))
if (error == GIT_SUCCESS) return 0;
return error;
} }
*ignored = 0; *ignored = 0;
return 0;
return GIT_SUCCESS;
} }
...@@ -34,25 +34,24 @@ static const git_tree_entry *tree_iterator__tree_entry(tree_iterator *ti) ...@@ -34,25 +34,24 @@ static const git_tree_entry *tree_iterator__tree_entry(tree_iterator *ti)
static int tree_iterator__current( static int tree_iterator__current(
git_iterator *self, const git_index_entry **entry) git_iterator *self, const git_index_entry **entry)
{ {
int error;
tree_iterator *ti = (tree_iterator *)self; tree_iterator *ti = (tree_iterator *)self;
const git_tree_entry *te = tree_iterator__tree_entry(ti); const git_tree_entry *te = tree_iterator__tree_entry(ti);
*entry = NULL; *entry = NULL;
if (te == NULL) if (te == NULL)
return GIT_SUCCESS; return 0;
ti->entry.mode = te->attr; ti->entry.mode = te->attr;
git_oid_cpy(&ti->entry.oid, &te->oid); git_oid_cpy(&ti->entry.oid, &te->oid);
error = git_buf_joinpath(&ti->path, ti->path.ptr, te->filename); if (git_buf_joinpath(&ti->path, ti->path.ptr, te->filename) < 0)
if (error < GIT_SUCCESS) return -1;
return error;
ti->entry.path = ti->path.ptr; ti->entry.path = ti->path.ptr;
*entry = &ti->entry; *entry = &ti->entry;
return GIT_SUCCESS; return 0;
} }
static int tree_iterator__at_end(git_iterator *self) static int tree_iterator__at_end(git_iterator *self)
...@@ -63,6 +62,7 @@ static int tree_iterator__at_end(git_iterator *self) ...@@ -63,6 +62,7 @@ static int tree_iterator__at_end(git_iterator *self)
static tree_iterator_frame *tree_iterator__alloc_frame(git_tree *tree) static tree_iterator_frame *tree_iterator__alloc_frame(git_tree *tree)
{ {
tree_iterator_frame *tf = git__calloc(1, sizeof(tree_iterator_frame)); tree_iterator_frame *tf = git__calloc(1, sizeof(tree_iterator_frame));
if (tf != NULL)
tf->tree = tree; tf->tree = tree;
return tf; return tf;
} }
...@@ -75,24 +75,22 @@ static int tree_iterator__expand_tree(tree_iterator *ti) ...@@ -75,24 +75,22 @@ static int tree_iterator__expand_tree(tree_iterator *ti)
tree_iterator_frame *tf; tree_iterator_frame *tf;
while (te != NULL && entry_is_tree(te)) { while (te != NULL && entry_is_tree(te)) {
error = git_tree_lookup(&subtree, ti->repo, &te->oid); if ((error = git_tree_lookup(&subtree, ti->repo, &te->oid)) < 0)
if (error != GIT_SUCCESS)
return error; return error;
if ((tf = tree_iterator__alloc_frame(subtree)) == NULL) if ((tf = tree_iterator__alloc_frame(subtree)) == NULL)
return GIT_ENOMEM; return -1;
tf->next = ti->stack; tf->next = ti->stack;
ti->stack = tf; ti->stack = tf;
error = git_buf_joinpath(&ti->path, ti->path.ptr, te->filename); if (git_buf_joinpath(&ti->path, ti->path.ptr, te->filename) < 0)
if (error < GIT_SUCCESS) return -1;
return error;
te = tree_iterator__tree_entry(ti); te = tree_iterator__tree_entry(ti);
} }
return GIT_SUCCESS; return 0;
} }
static void tree_iterator__pop_frame(tree_iterator *ti) static void tree_iterator__pop_frame(tree_iterator *ti)
...@@ -107,7 +105,7 @@ static void tree_iterator__pop_frame(tree_iterator *ti) ...@@ -107,7 +105,7 @@ static void tree_iterator__pop_frame(tree_iterator *ti)
static int tree_iterator__advance( static int tree_iterator__advance(
git_iterator *self, const git_index_entry **entry) git_iterator *self, const git_index_entry **entry)
{ {
int error = GIT_SUCCESS; int error = 0;
tree_iterator *ti = (tree_iterator *)self; tree_iterator *ti = (tree_iterator *)self;
const git_tree_entry *te = NULL; const git_tree_entry *te = NULL;
...@@ -129,7 +127,7 @@ static int tree_iterator__advance( ...@@ -129,7 +127,7 @@ static int tree_iterator__advance(
if (te && entry_is_tree(te)) if (te && entry_is_tree(te))
error = tree_iterator__expand_tree(ti); error = tree_iterator__expand_tree(ti);
if (error == GIT_SUCCESS && entry != NULL) if (!error && entry != NULL)
error = tree_iterator__current(self, entry); error = tree_iterator__current(self, entry);
return error; return error;
...@@ -158,8 +156,7 @@ int git_iterator_for_tree( ...@@ -158,8 +156,7 @@ int git_iterator_for_tree(
{ {
int error; int error;
tree_iterator *ti = git__calloc(1, sizeof(tree_iterator)); tree_iterator *ti = git__calloc(1, sizeof(tree_iterator));
if (!ti) GITERR_CHECK_ALLOC(ti);
return GIT_ENOMEM;
ti->base.type = GIT_ITERATOR_TREE; ti->base.type = GIT_ITERATOR_TREE;
ti->base.current = tree_iterator__current; ti->base.current = tree_iterator__current;
...@@ -170,11 +167,10 @@ int git_iterator_for_tree( ...@@ -170,11 +167,10 @@ int git_iterator_for_tree(
ti->repo = repo; ti->repo = repo;
ti->stack = tree_iterator__alloc_frame(tree); ti->stack = tree_iterator__alloc_frame(tree);
if ((error = tree_iterator__expand_tree(ti)) < GIT_SUCCESS) if ((error = tree_iterator__expand_tree(ti)) < 0)
git_iterator_free((git_iterator *)ti); git_iterator_free((git_iterator *)ti);
else else
*iter = (git_iterator *)ti; *iter = (git_iterator *)ti;
return error; return error;
} }
...@@ -190,7 +186,7 @@ static int index_iterator__current( ...@@ -190,7 +186,7 @@ static int index_iterator__current(
{ {
index_iterator *ii = (index_iterator *)self; index_iterator *ii = (index_iterator *)self;
*entry = git_index_get(ii->index, ii->current); *entry = git_index_get(ii->index, ii->current);
return GIT_SUCCESS; return 0;
} }
static int index_iterator__at_end(git_iterator *self) static int index_iterator__at_end(git_iterator *self)
...@@ -207,14 +203,14 @@ static int index_iterator__advance( ...@@ -207,14 +203,14 @@ static int index_iterator__advance(
ii->current++; ii->current++;
if (entry) if (entry)
*entry = git_index_get(ii->index, ii->current); *entry = git_index_get(ii->index, ii->current);
return GIT_SUCCESS; return 0;
} }
static int index_iterator__reset(git_iterator *self) static int index_iterator__reset(git_iterator *self)
{ {
index_iterator *ii = (index_iterator *)self; index_iterator *ii = (index_iterator *)self;
ii->current = 0; ii->current = 0;
return GIT_SUCCESS; return 0;
} }
static void index_iterator__free(git_iterator *self) static void index_iterator__free(git_iterator *self)
...@@ -228,8 +224,7 @@ int git_iterator_for_index(git_repository *repo, git_iterator **iter) ...@@ -228,8 +224,7 @@ int git_iterator_for_index(git_repository *repo, git_iterator **iter)
{ {
int error; int error;
index_iterator *ii = git__calloc(1, sizeof(index_iterator)); index_iterator *ii = git__calloc(1, sizeof(index_iterator));
if (!ii) GITERR_CHECK_ALLOC(ii);
return GIT_ENOMEM;
ii->base.type = GIT_ITERATOR_INDEX; ii->base.type = GIT_ITERATOR_INDEX;
ii->base.current = index_iterator__current; ii->base.current = index_iterator__current;
...@@ -239,7 +234,7 @@ int git_iterator_for_index(git_repository *repo, git_iterator **iter) ...@@ -239,7 +234,7 @@ int git_iterator_for_index(git_repository *repo, git_iterator **iter)
ii->base.free = index_iterator__free; ii->base.free = index_iterator__free;
ii->current = 0; ii->current = 0;
if ((error = git_repository_index(&ii->index, repo)) < GIT_SUCCESS) if ((error = git_repository_index(&ii->index, repo)) < 0)
git__free(ii); git__free(ii);
else else
*iter = (git_iterator *)ii; *iter = (git_iterator *)ii;
...@@ -269,8 +264,8 @@ static workdir_iterator_frame *workdir_iterator__alloc_frame(void) ...@@ -269,8 +264,8 @@ static workdir_iterator_frame *workdir_iterator__alloc_frame(void)
{ {
workdir_iterator_frame *wf = git__calloc(1, sizeof(workdir_iterator_frame)); workdir_iterator_frame *wf = git__calloc(1, sizeof(workdir_iterator_frame));
if (wf == NULL) if (wf == NULL)
return wf; return NULL;
if (git_vector_init(&wf->entries, 0, git_path_with_stat_cmp) != GIT_SUCCESS) { if (git_vector_init(&wf->entries, 0, git_path_with_stat_cmp) != 0) {
git__free(wf); git__free(wf);
return NULL; return NULL;
} }
...@@ -294,11 +289,10 @@ static int workdir_iterator__expand_dir(workdir_iterator *wi) ...@@ -294,11 +289,10 @@ static int workdir_iterator__expand_dir(workdir_iterator *wi)
{ {
int error; int error;
workdir_iterator_frame *wf = workdir_iterator__alloc_frame(); workdir_iterator_frame *wf = workdir_iterator__alloc_frame();
if (wf == NULL) GITERR_CHECK_ALLOC(wf);
return GIT_ENOMEM;
error = git_path_dirload_with_stat(wi->path.ptr, wi->root_len, &wf->entries); error = git_path_dirload_with_stat(wi->path.ptr, wi->root_len, &wf->entries);
if (error < GIT_SUCCESS || wf->entries.length == 0) { if (error < 0 || wf->entries.length == 0) {
workdir_iterator__free_frame(wf); workdir_iterator__free_frame(wf);
return GIT_ENOTFOUND; return GIT_ENOTFOUND;
} }
...@@ -321,7 +315,7 @@ static int workdir_iterator__current( ...@@ -321,7 +315,7 @@ static int workdir_iterator__current(
{ {
workdir_iterator *wi = (workdir_iterator *)self; workdir_iterator *wi = (workdir_iterator *)self;
*entry = (wi->entry.path == NULL) ? NULL : &wi->entry; *entry = (wi->entry.path == NULL) ? NULL : &wi->entry;
return GIT_SUCCESS; return 0;
} }
static int workdir_iterator__at_end(git_iterator *self) static int workdir_iterator__at_end(git_iterator *self)
...@@ -341,7 +335,7 @@ static int workdir_iterator__advance( ...@@ -341,7 +335,7 @@ static int workdir_iterator__advance(
*entry = NULL; *entry = NULL;
if (wi->entry.path == NULL) if (wi->entry.path == NULL)
return GIT_SUCCESS; return 0;
while ((wf = wi->stack) != NULL) { while ((wf = wi->stack) != NULL) {
next = git_vector_get(&wf->entries, ++wf->index); next = git_vector_get(&wf->entries, ++wf->index);
...@@ -359,13 +353,13 @@ static int workdir_iterator__advance( ...@@ -359,13 +353,13 @@ static int workdir_iterator__advance(
if (wi->stack == NULL) { if (wi->stack == NULL) {
memset(&wi->entry, 0, sizeof(wi->entry)); memset(&wi->entry, 0, sizeof(wi->entry));
return GIT_SUCCESS; return 0;
} }
} }
error = workdir_iterator__update_entry(wi); error = workdir_iterator__update_entry(wi);
if (error == GIT_SUCCESS && entry != NULL) if (!error && entry != NULL)
error = workdir_iterator__current(self, entry); error = workdir_iterator__current(self, entry);
return error; return error;
...@@ -382,7 +376,7 @@ static int workdir_iterator__reset(git_iterator *self) ...@@ -382,7 +376,7 @@ static int workdir_iterator__reset(git_iterator *self)
} }
if (wi->stack) if (wi->stack)
wi->stack->index = 0; wi->stack->index = 0;
return GIT_SUCCESS; return 0;
} }
static void workdir_iterator__free(git_iterator *self) static void workdir_iterator__free(git_iterator *self)
...@@ -405,9 +399,8 @@ static int workdir_iterator__update_entry(workdir_iterator *wi) ...@@ -405,9 +399,8 @@ static int workdir_iterator__update_entry(workdir_iterator *wi)
git_path_with_stat *ps = git_vector_get(&wi->stack->entries, wi->stack->index); git_path_with_stat *ps = git_vector_get(&wi->stack->entries, wi->stack->index);
git_buf_truncate(&wi->path, wi->root_len); git_buf_truncate(&wi->path, wi->root_len);
error = git_buf_put(&wi->path, ps->path, ps->path_len); if (git_buf_put(&wi->path, ps->path, ps->path_len) < 0)
if (error < GIT_SUCCESS) return -1;
return error;
memset(&wi->entry, 0, sizeof(wi->entry)); memset(&wi->entry, 0, sizeof(wi->entry));
wi->entry.path = ps->path; wi->entry.path = ps->path;
...@@ -431,27 +424,26 @@ static int workdir_iterator__update_entry(workdir_iterator *wi) ...@@ -431,27 +424,26 @@ static int workdir_iterator__update_entry(workdir_iterator *wi)
/* if this is a file type we don't handle, treat as ignored */ /* if this is a file type we don't handle, treat as ignored */
if (wi->entry.mode == 0) if (wi->entry.mode == 0)
return GIT_SUCCESS; return 0;
/* okay, we are far enough along to look up real ignore rule */ /* okay, we are far enough along to look up real ignore rule */
error = git_ignore__lookup(&wi->ignores, wi->entry.path, &wi->is_ignored); error = git_ignore__lookup(&wi->ignores, wi->entry.path, &wi->is_ignored);
if (error != GIT_SUCCESS) if (error < 0)
return GIT_SUCCESS; return 0;
/* detect submodules */ /* detect submodules */
if (S_ISDIR(wi->entry.mode) && if (S_ISDIR(wi->entry.mode) &&
git_path_contains(&wi->path, DOT_GIT) == true) git_path_contains(&wi->path, DOT_GIT) == true)
wi->entry.mode = S_IFGITLINK; wi->entry.mode = S_IFGITLINK;
return GIT_SUCCESS; return 0;
} }
int git_iterator_for_workdir(git_repository *repo, git_iterator **iter) int git_iterator_for_workdir(git_repository *repo, git_iterator **iter)
{ {
int error; int error;
workdir_iterator *wi = git__calloc(1, sizeof(workdir_iterator)); workdir_iterator *wi = git__calloc(1, sizeof(workdir_iterator));
if (!wi) GITERR_CHECK_ALLOC(wi);
return GIT_ENOMEM;
wi->base.type = GIT_ITERATOR_WORKDIR; wi->base.type = GIT_ITERATOR_WORKDIR;
wi->base.current = workdir_iterator__current; wi->base.current = workdir_iterator__current;
...@@ -461,19 +453,17 @@ int git_iterator_for_workdir(git_repository *repo, git_iterator **iter) ...@@ -461,19 +453,17 @@ int git_iterator_for_workdir(git_repository *repo, git_iterator **iter)
wi->base.free = workdir_iterator__free; wi->base.free = workdir_iterator__free;
wi->repo = repo; wi->repo = repo;
error = git_buf_sets(&wi->path, git_repository_workdir(repo)); if (git_buf_sets(&wi->path, git_repository_workdir(repo)) < 0 ||
if (error == GIT_SUCCESS) git_path_to_dir(&wi->path) < 0 ||
error = git_path_to_dir(&wi->path); git_ignore__for_path(repo, "", &wi->ignores) < 0)
if (error == GIT_SUCCESS) {
error = git_ignore__for_path(repo, "", &wi->ignores);
if (error != GIT_SUCCESS) {
git__free(wi); git__free(wi);
return error; return -1;
} }
wi->root_len = wi->path.size; wi->root_len = wi->path.size;
if ((error = workdir_iterator__expand_dir(wi)) < GIT_SUCCESS) if ((error = workdir_iterator__expand_dir(wi)) < 0)
git_iterator_free((git_iterator *)wi); git_iterator_free((git_iterator *)wi);
else else
*iter = (git_iterator *)wi; *iter = (git_iterator *)wi;
...@@ -487,7 +477,7 @@ int git_iterator_current_tree_entry( ...@@ -487,7 +477,7 @@ int git_iterator_current_tree_entry(
{ {
*tree_entry = (iter->type != GIT_ITERATOR_TREE) ? NULL : *tree_entry = (iter->type != GIT_ITERATOR_TREE) ? NULL :
tree_iterator__tree_entry((tree_iterator *)iter); tree_iterator__tree_entry((tree_iterator *)iter);
return GIT_SUCCESS; return 0;
} }
int git_iterator_current_is_ignored(git_iterator *iter) int git_iterator_current_is_ignored(git_iterator *iter)
...@@ -504,10 +494,10 @@ int git_iterator_advance_into_directory( ...@@ -504,10 +494,10 @@ int git_iterator_advance_into_directory(
if (iter->type == GIT_ITERATOR_WORKDIR && if (iter->type == GIT_ITERATOR_WORKDIR &&
wi->entry.path && S_ISDIR(wi->entry.mode)) wi->entry.path && S_ISDIR(wi->entry.mode))
{ {
if (workdir_iterator__expand_dir(wi) < GIT_SUCCESS) if (workdir_iterator__expand_dir(wi) < 0)
/* if error loading or if empty, skip the directory. */ /* if error loading or if empty, skip the directory. */
return workdir_iterator__advance(iter, entry); return workdir_iterator__advance(iter, entry);
} }
return entry ? git_iterator_current(iter, entry) : GIT_SUCCESS; return entry ? git_iterator_current(iter, entry) : 0;
} }
...@@ -115,7 +115,7 @@ static int git_mwindow_close_lru(git_mwindow_file *mwf) ...@@ -115,7 +115,7 @@ static int git_mwindow_close_lru(git_mwindow_file *mwf)
unsigned int i; unsigned int i;
git_mwindow *lru_w = NULL, *lru_l = NULL, **list = &mwf->windows; git_mwindow *lru_w = NULL, *lru_l = NULL, **list = &mwf->windows;
/* FIMXE: Does this give us any advantage? */ /* FIXME: Does this give us any advantage? */
if(mwf->windows) if(mwf->windows)
git_mwindow_scan_lru(mwf, &lru_w, &lru_l); git_mwindow_scan_lru(mwf, &lru_w, &lru_l);
...@@ -127,7 +127,11 @@ static int git_mwindow_close_lru(git_mwindow_file *mwf) ...@@ -127,7 +127,11 @@ static int git_mwindow_close_lru(git_mwindow_file *mwf)
list = &cur->windows; list = &cur->windows;
} }
if (lru_w) { if (!lru_w) {
giterr_set(GITERR_OS, "Failed to close memory window. Couldn't find LRU");
return -1;
}
ctl->mapped -= lru_w->window_map.len; ctl->mapped -= lru_w->window_map.len;
git_futils_mmap_free(&lru_w->window_map); git_futils_mmap_free(&lru_w->window_map);
...@@ -139,10 +143,7 @@ static int git_mwindow_close_lru(git_mwindow_file *mwf) ...@@ -139,10 +143,7 @@ static int git_mwindow_close_lru(git_mwindow_file *mwf)
git__free(lru_w); git__free(lru_w);
ctl->open_windows--; ctl->open_windows--;
return GIT_SUCCESS; return 0;
}
return git__throw(GIT_ERROR, "Failed to close memory window. Couln't find LRU");
} }
static git_mwindow *new_window( static git_mwindow *new_window(
...@@ -158,7 +159,7 @@ static git_mwindow *new_window( ...@@ -158,7 +159,7 @@ static git_mwindow *new_window(
w = git__malloc(sizeof(*w)); w = git__malloc(sizeof(*w));
if (w == NULL) if (w == NULL)
return w; return NULL;
memset(w, 0x0, sizeof(*w)); memset(w, 0x0, sizeof(*w));
w->offset = (offset / walign) * walign; w->offset = (offset / walign) * walign;
...@@ -170,7 +171,7 @@ static git_mwindow *new_window( ...@@ -170,7 +171,7 @@ static git_mwindow *new_window(
ctl->mapped += (size_t)len; ctl->mapped += (size_t)len;
while (_mw_options.mapped_limit < ctl->mapped && while (_mw_options.mapped_limit < ctl->mapped &&
git_mwindow_close_lru(mwf) == GIT_SUCCESS) /* nop */; git_mwindow_close_lru(mwf) == 0) /* nop */;
/* /*
* We treat _mw_options.mapped_limit as a soft limit. If we can't find a * We treat _mw_options.mapped_limit as a soft limit. If we can't find a
......
...@@ -582,7 +582,7 @@ static int loose_backend__read_header(size_t *len_p, git_otype *type_p, git_odb_ ...@@ -582,7 +582,7 @@ static int loose_backend__read_header(size_t *len_p, git_otype *type_p, git_odb_
{ {
git_buf object_path = GIT_BUF_INIT; git_buf object_path = GIT_BUF_INIT;
git_rawobj raw; git_rawobj raw;
int error = GIT_SUCCESS; int error;
assert(backend && oid); assert(backend && oid);
...@@ -803,7 +803,7 @@ static int loose_backend__write(git_oid *oid, git_odb_backend *_backend, const v ...@@ -803,7 +803,7 @@ static int loose_backend__write(git_oid *oid, git_odb_backend *_backend, const v
error = -1; error = -1;
cleanup: cleanup:
if (error < GIT_SUCCESS) if (error < 0)
git_filebuf_cleanup(&fbuf); git_filebuf_cleanup(&fbuf);
git_buf_free(&final_path); git_buf_free(&final_path);
return error; return error;
......
...@@ -226,7 +226,7 @@ static int packfile_load__cb(void *_data, git_buf *path) ...@@ -226,7 +226,7 @@ static int packfile_load__cb(void *_data, git_buf *path)
error = git_packfile_check(&pack, path->ptr); error = git_packfile_check(&pack, path->ptr);
if (error == GIT_ENOTFOUND) if (error == GIT_ENOTFOUND)
/* ignore missing .pack file as git does */ /* ignore missing .pack file as git does */
return GIT_SUCCESS; return 0;
else if (error < 0) else if (error < 0)
return error; return error;
......
...@@ -508,7 +508,7 @@ static int packfile_open(struct git_pack_file *p) ...@@ -508,7 +508,7 @@ static int packfile_open(struct git_pack_file *p)
assert(p->index_map.data); assert(p->index_map.data);
if (!p->index_map.data && pack_index_open(p) < GIT_SUCCESS) if (!p->index_map.data && pack_index_open(p) < 0)
return git_odb__error_notfound("failed to open packfile"); return git_odb__error_notfound("failed to open packfile");
/* TODO: open with noatime */ /* TODO: open with noatime */
......
...@@ -327,7 +327,7 @@ int git_path_walk_up( ...@@ -327,7 +327,7 @@ int git_path_walk_up(
assert(path && cb); assert(path && cb);
if (ceiling != NULL) { if (ceiling != NULL) {
if (git__prefixcmp(path->ptr, ceiling) == GIT_SUCCESS) if (git__prefixcmp(path->ptr, ceiling) == 0)
stop = (ssize_t)strlen(ceiling); stop = (ssize_t)strlen(ceiling);
else else
stop = path->size; stop = path->size;
......
...@@ -139,7 +139,7 @@ extern int git_path_lstat(const char *path, struct stat *st); ...@@ -139,7 +139,7 @@ extern int git_path_lstat(const char *path, struct stat *st);
* *
* @param dir Directory to check. * @param dir Directory to check.
* @param item Item that might be in the directory. * @param item Item that might be in the directory.
* @return GIT_SUCCESS if item exists in directory, <0 otherwise. * @return 0 if item exists in directory, <0 otherwise.
*/ */
extern bool git_path_contains(git_buf *dir, const char *item); extern bool git_path_contains(git_buf *dir, const char *item);
...@@ -211,7 +211,7 @@ extern int git_path_cmp( ...@@ -211,7 +211,7 @@ extern int git_path_cmp(
* Invoke callback up path directory by directory until the ceiling is * Invoke callback up path directory by directory until the ceiling is
* reached (inclusive of a final call at the root_path). * reached (inclusive of a final call at the root_path).
* *
* Returning anything other than GIT_SUCCESS from the callback function * Returning anything other than 0 from the callback function
* will stop the iteration and propogate the error to the caller. * will stop the iteration and propogate the error to the caller.
* *
* @param pathbuf Buffer the function reads the directory from and * @param pathbuf Buffer the function reads the directory from and
......
...@@ -186,7 +186,7 @@ static int loose_parse_oid(git_oid *oid, git_buf *file_content) ...@@ -186,7 +186,7 @@ static int loose_parse_oid(git_oid *oid, git_buf *file_content)
if (*buffer != '\n') if (*buffer != '\n')
goto corrupt; goto corrupt;
return GIT_SUCCESS; return 0;
corrupt: corrupt:
giterr_set(GITERR_REFERENCE, "Corrupted loose reference file"); giterr_set(GITERR_REFERENCE, "Corrupted loose reference file");
...@@ -200,7 +200,7 @@ static git_rtype loose_guess_rtype(const git_buf *full_path) ...@@ -200,7 +200,7 @@ static git_rtype loose_guess_rtype(const git_buf *full_path)
type = GIT_REF_INVALID; type = GIT_REF_INVALID;
if (git_futils_readbuffer(&ref_file, full_path->ptr) == GIT_SUCCESS) { if (git_futils_readbuffer(&ref_file, full_path->ptr) == 0) {
if (git__prefixcmp((const char *)(ref_file.ptr), GIT_SYMREF) == 0) if (git__prefixcmp((const char *)(ref_file.ptr), GIT_SYMREF) == 0)
type = GIT_REF_SYMBOLIC; type = GIT_REF_SYMBOLIC;
else else
...@@ -335,7 +335,7 @@ static int packed_parse_peel( ...@@ -335,7 +335,7 @@ static int packed_parse_peel(
goto corrupt; goto corrupt;
/* Is this a valid object id? */ /* Is this a valid object id? */
if (git_oid_fromstr(&tag_ref->peel, buffer) < GIT_SUCCESS) if (git_oid_fromstr(&tag_ref->peel, buffer) < 0)
goto corrupt; goto corrupt;
buffer = buffer + GIT_OID_HEXSZ; buffer = buffer + GIT_OID_HEXSZ;
...@@ -1483,7 +1483,7 @@ int git_reference_listall( ...@@ -1483,7 +1483,7 @@ int git_reference_listall(
array->strings = NULL; array->strings = NULL;
array->count = 0; array->count = 0;
if (git_vector_init(&ref_list, 8, NULL) < GIT_SUCCESS) if (git_vector_init(&ref_list, 8, NULL) < 0)
return -1; return -1;
if (git_reference_foreach( if (git_reference_foreach(
......
...@@ -878,7 +878,7 @@ int git_repository_set_workdir(git_repository *repo, const char *workdir) ...@@ -878,7 +878,7 @@ int git_repository_set_workdir(git_repository *repo, const char *workdir)
GITERR_CHECK_ALLOC(repo->workdir); GITERR_CHECK_ALLOC(repo->workdir);
repo->is_bare = 0; repo->is_bare = 0;
return GIT_SUCCESS; return 0;
} }
int git_repository_is_bare(git_repository *repo) int git_repository_is_bare(git_repository *repo)
......
...@@ -38,11 +38,12 @@ int git__fnmatch(const char *pattern, const char *name, int flags) ...@@ -38,11 +38,12 @@ int git__fnmatch(const char *pattern, const char *name, int flags)
ret = p_fnmatch(pattern, name, flags); ret = p_fnmatch(pattern, name, flags);
switch (ret) { switch (ret) {
case 0: case 0:
return GIT_SUCCESS; return 0;
case FNM_NOMATCH: case FNM_NOMATCH:
return GIT_ENOMATCH; return GIT_ENOMATCH;
default: default:
return git__throw(GIT_EOSERR, "Error trying to match path"); giterr_set(GITERR_OS, "Error trying to match path");
return -1;
} }
} }
......
...@@ -72,9 +72,9 @@ void test_attr_repo__get_one(void) ...@@ -72,9 +72,9 @@ void test_attr_repo__get_one(void)
attr_check_expected(scan->expected, scan->expected_str, value); attr_check_expected(scan->expected, scan->expected_str, value);
} }
cl_git_pass(git_attr_cache__is_cached(g_repo, ".git/info/attributes")); cl_assert(git_attr_cache__is_cached(g_repo, ".git/info/attributes"));
cl_git_pass(git_attr_cache__is_cached(g_repo, ".gitattributes")); cl_assert(git_attr_cache__is_cached(g_repo, ".gitattributes"));
cl_git_pass(git_attr_cache__is_cached(g_repo, "sub/.gitattributes")); cl_assert(git_attr_cache__is_cached(g_repo, "sub/.gitattributes"));
} }
void test_attr_repo__get_many(void) void test_attr_repo__get_many(void)
...@@ -114,7 +114,7 @@ static int count_attrs( ...@@ -114,7 +114,7 @@ static int count_attrs(
*((int *)payload) += 1; *((int *)payload) += 1;
return GIT_SUCCESS; return 0;
} }
void test_attr_repo__foreach(void) void test_attr_repo__foreach(void)
......
...@@ -348,7 +348,7 @@ static int check_one_walkup_step(void *ref, git_buf *path) ...@@ -348,7 +348,7 @@ static int check_one_walkup_step(void *ref, git_buf *path)
cl_assert(info->expect[info->expect_idx] != NULL); cl_assert(info->expect[info->expect_idx] != NULL);
cl_assert_strequal(info->expect[info->expect_idx], path->ptr); cl_assert_strequal(info->expect[info->expect_idx], path->ptr);
info->expect_idx++; info->expect_idx++;
return GIT_SUCCESS; return 0;
} }
void test_core_path__11_walkup(void) void test_core_path__11_walkup(void)
......
...@@ -24,7 +24,7 @@ static void diff_cmp(const git_tree_diff_data *a, const git_tree_diff_data *b) ...@@ -24,7 +24,7 @@ static void diff_cmp(const git_tree_diff_data *a, const git_tree_diff_data *b)
static int diff_cb(const git_tree_diff_data *diff, void *data) static int diff_cb(const git_tree_diff_data *diff, void *data)
{ {
diff_cmp(diff, data); diff_cmp(diff, data);
return GIT_SUCCESS; return 0;
} }
static void test_diff(git_tree *a, git_tree *b, git_tree_diff_cb cb, void *data) static void test_diff(git_tree *a, git_tree *b, git_tree_diff_cb cb, void *data)
...@@ -126,7 +126,7 @@ static int diff_more_cb(const git_tree_diff_data *diff, void *data) ...@@ -126,7 +126,7 @@ static int diff_more_cb(const git_tree_diff_data *diff, void *data)
more_data->expect_idx = (more_data->expect_idx + 1) % ARRAY_SIZE(more_data->expect); more_data->expect_idx = (more_data->expect_idx + 1) % ARRAY_SIZE(more_data->expect);
return GIT_SUCCESS; return 0;
} }
void test_object_tree_diff__more(void) void test_object_tree_diff__more(void)
......
...@@ -47,6 +47,6 @@ void test_status_ignore__0(void) ...@@ -47,6 +47,6 @@ void test_status_ignore__0(void)
} }
/* confirm that ignore files were cached */ /* confirm that ignore files were cached */
cl_git_pass(git_attr_cache__is_cached(g_repo, ".git/info/exclude")); cl_assert(git_attr_cache__is_cached(g_repo, ".git/info/exclude"));
cl_git_pass(git_attr_cache__is_cached(g_repo, ".gitignore")); cl_assert(git_attr_cache__is_cached(g_repo, ".gitignore"));
} }
...@@ -27,7 +27,7 @@ cb_status__normal( const char *path, unsigned int status_flags, void *payload) ...@@ -27,7 +27,7 @@ cb_status__normal( const char *path, unsigned int status_flags, void *payload)
exit: exit:
counts->entry_count++; counts->entry_count++;
return GIT_SUCCESS; return 0;
} }
static int static int
...@@ -40,7 +40,7 @@ cb_status__count(const char *p, unsigned int s, void *payload) ...@@ -40,7 +40,7 @@ cb_status__count(const char *p, unsigned int s, void *payload)
(*count)++; (*count)++;
return GIT_SUCCESS; return 0;
} }
......
...@@ -432,7 +432,7 @@ BEGIN_TEST(singlestatus4, "can't determine the status for a folder") ...@@ -432,7 +432,7 @@ BEGIN_TEST(singlestatus4, "can't determine the status for a folder")
must_pass(git_repository_open(&repo, TEST_STD_REPO_FOLDER)); must_pass(git_repository_open(&repo, TEST_STD_REPO_FOLDER));
error = git_status_file(&status_flags, repo, "subdir"); error = git_status_file(&status_flags, repo, "subdir");
must_be_true(error == GIT_EINVALIDPATH); must_be_true(error < 0);
git_repository_free(repo); git_repository_free(repo);
......
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