Commit a3126a72 by Edward Thomson

repository functions: return an int

Stop returning a void for functions, future-proofing them to allow them
to fail.
parent cb43274a
...@@ -44,8 +44,11 @@ GIT_EXTERN(int) git_repository_new(git_repository **out); ...@@ -44,8 +44,11 @@ GIT_EXTERN(int) git_repository_new(git_repository **out);
* trying to aggressively cleanup the repo before its * trying to aggressively cleanup the repo before its
* deallocation. `git_repository_free` already performs this operation * deallocation. `git_repository_free` already performs this operation
* before deallocating the repo. * before deallocating the repo.
*
* @param repo The repository to clean up
* @return 0 on success, or an error code
*/ */
GIT_EXTERN(void) git_repository__cleanup(git_repository *repo); GIT_EXTERN(int) git_repository__cleanup(git_repository *repo);
/** /**
* Update the filesystem config settings for an open repository * Update the filesystem config settings for an open repository
...@@ -78,8 +81,9 @@ GIT_EXTERN(int) git_repository_reinit_filesystem( ...@@ -78,8 +81,9 @@ GIT_EXTERN(int) git_repository_reinit_filesystem(
* *
* @param repo A repository object * @param repo A repository object
* @param config A Config object * @param config A Config object
* @return 0 on success, or an error code
*/ */
GIT_EXTERN(void) git_repository_set_config(git_repository *repo, git_config *config); GIT_EXTERN(int) git_repository_set_config(git_repository *repo, git_config *config);
/** /**
* Set the Object Database for this repository * Set the Object Database for this repository
...@@ -93,8 +97,9 @@ GIT_EXTERN(void) git_repository_set_config(git_repository *repo, git_config *con ...@@ -93,8 +97,9 @@ GIT_EXTERN(void) git_repository_set_config(git_repository *repo, git_config *con
* *
* @param repo A repository object * @param repo A repository object
* @param odb An ODB object * @param odb An ODB object
* @return 0 on success, or an error code
*/ */
GIT_EXTERN(void) git_repository_set_odb(git_repository *repo, git_odb *odb); GIT_EXTERN(int) git_repository_set_odb(git_repository *repo, git_odb *odb);
/** /**
* Set the Reference Database Backend for this repository * Set the Reference Database Backend for this repository
...@@ -108,8 +113,9 @@ GIT_EXTERN(void) git_repository_set_odb(git_repository *repo, git_odb *odb); ...@@ -108,8 +113,9 @@ GIT_EXTERN(void) git_repository_set_odb(git_repository *repo, git_odb *odb);
* *
* @param repo A repository object * @param repo A repository object
* @param refdb An refdb object * @param refdb An refdb object
* @return 0 on success, or an error code
*/ */
GIT_EXTERN(void) git_repository_set_refdb(git_repository *repo, git_refdb *refdb); GIT_EXTERN(int) git_repository_set_refdb(git_repository *repo, git_refdb *refdb);
/** /**
* Set the index file for this repository * Set the index file for this repository
...@@ -123,8 +129,9 @@ GIT_EXTERN(void) git_repository_set_refdb(git_repository *repo, git_refdb *refdb ...@@ -123,8 +129,9 @@ GIT_EXTERN(void) git_repository_set_refdb(git_repository *repo, git_refdb *refdb
* *
* @param repo A repository object * @param repo A repository object
* @param index An index object * @param index An index object
* @return 0 on success, or an error code
*/ */
GIT_EXTERN(void) git_repository_set_index(git_repository *repo, git_index *index); GIT_EXTERN(int) git_repository_set_index(git_repository *repo, git_index *index);
/** /**
* Set a repository to be bare. * Set a repository to be bare.
......
...@@ -138,7 +138,7 @@ static void set_index(git_repository *repo, git_index *index) ...@@ -138,7 +138,7 @@ static void set_index(git_repository *repo, git_index *index)
} }
} }
void git_repository__cleanup(git_repository *repo) int git_repository__cleanup(git_repository *repo)
{ {
assert(repo); assert(repo);
...@@ -150,6 +150,8 @@ void git_repository__cleanup(git_repository *repo) ...@@ -150,6 +150,8 @@ void git_repository__cleanup(git_repository *repo)
set_index(repo, NULL); set_index(repo, NULL);
set_odb(repo, NULL); set_odb(repo, NULL);
set_refdb(repo, NULL); set_refdb(repo, NULL);
return 0;
} }
void git_repository_free(git_repository *repo) void git_repository_free(git_repository *repo)
...@@ -1070,10 +1072,11 @@ int git_repository_config_snapshot(git_config **out, git_repository *repo) ...@@ -1070,10 +1072,11 @@ int git_repository_config_snapshot(git_config **out, git_repository *repo)
return git_config_snapshot(out, weak); return git_config_snapshot(out, weak);
} }
void git_repository_set_config(git_repository *repo, git_config *config) int git_repository_set_config(git_repository *repo, git_config *config)
{ {
assert(repo && config); assert(repo && config);
set_config(repo, config); set_config(repo, config);
return 0;
} }
int git_repository_odb__weakptr(git_odb **out, git_repository *repo) int git_repository_odb__weakptr(git_odb **out, git_repository *repo)
...@@ -1121,10 +1124,11 @@ int git_repository_odb(git_odb **out, git_repository *repo) ...@@ -1121,10 +1124,11 @@ int git_repository_odb(git_odb **out, git_repository *repo)
return 0; return 0;
} }
void git_repository_set_odb(git_repository *repo, git_odb *odb) int git_repository_set_odb(git_repository *repo, git_odb *odb)
{ {
assert(repo && odb); assert(repo && odb);
set_odb(repo, odb); set_odb(repo, odb);
return 0;
} }
int git_repository_refdb__weakptr(git_refdb **out, git_repository *repo) int git_repository_refdb__weakptr(git_refdb **out, git_repository *repo)
...@@ -1161,10 +1165,11 @@ int git_repository_refdb(git_refdb **out, git_repository *repo) ...@@ -1161,10 +1165,11 @@ int git_repository_refdb(git_refdb **out, git_repository *repo)
return 0; return 0;
} }
void git_repository_set_refdb(git_repository *repo, git_refdb *refdb) int git_repository_set_refdb(git_repository *repo, git_refdb *refdb)
{ {
assert(repo && refdb); assert(repo && refdb);
set_refdb(repo, refdb); set_refdb(repo, refdb);
return 0;
} }
int git_repository_index__weakptr(git_index **out, git_repository *repo) int git_repository_index__weakptr(git_index **out, git_repository *repo)
...@@ -1210,10 +1215,11 @@ int git_repository_index(git_index **out, git_repository *repo) ...@@ -1210,10 +1215,11 @@ int git_repository_index(git_index **out, git_repository *repo)
return 0; return 0;
} }
void git_repository_set_index(git_repository *repo, git_index *index) int git_repository_set_index(git_repository *repo, git_index *index)
{ {
assert(repo); assert(repo);
set_index(repo, index); set_index(repo, index);
return 0;
} }
int git_repository_set_namespace(git_repository *repo, const char *namespace) int git_repository_set_namespace(git_repository *repo, const char *namespace)
......
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