Commit de2220a4 by Shawn O. Pearce

Replace git_result_t with int

This seems to be preferred on the mailing list.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
parent 4f9339df
...@@ -37,12 +37,12 @@ and may disappear or change their signature in a future release. ...@@ -37,12 +37,12 @@ and may disappear or change their signature in a future release.
Calling Conventions Calling Conventions
------------------- -------------------
Functions should prefer to return a 'git_result_t' to indicate Functions should prefer to return a 'int' to indicate success or
success/failure and supply any output through the first argument failure and supply any output through the first argument (or first
(or first few arguments if multiple outputs are supplied). few arguments if multiple outputs are supplied).
git_result_t status codes are 0 for GIT_SUCCESS and < 0 for an int status codes are 0 for GIT_SUCCESS and < 0 for an error.
error. This permits common POSIX result testing: This permits common POSIX result testing:
---- ----
if (git_odb_open(&odb, path)) if (git_odb_open(&odb, path))
......
...@@ -62,9 +62,6 @@ GIT_BEGIN_DECL ...@@ -62,9 +62,6 @@ GIT_BEGIN_DECL
# define GIT_EXTERN(type) type # define GIT_EXTERN(type) type
#endif #endif
/** Generic result code for any API call. */
typedef int git_result_t;
/** Operation completed successfully. */ /** Operation completed successfully. */
#define GIT_SUCCESS 0 #define GIT_SUCCESS 0
......
...@@ -46,7 +46,7 @@ struct git_odb_t { ...@@ -46,7 +46,7 @@ struct git_odb_t {
unsigned n_alternates; unsigned n_alternates;
}; };
git_result_t git_odb_read( int git_odb_read(
git_sobj_t *out, git_sobj_t *out,
git_odb_t *db, git_odb_t *db,
const git_oid_t *id) const git_oid_t *id)
......
...@@ -60,7 +60,7 @@ typedef struct git_odb_t git_odb_t; ...@@ -60,7 +60,7 @@ typedef struct git_odb_t git_odb_t;
* @return GIT_SUCCESS if the database opened; otherwise an error * @return GIT_SUCCESS if the database opened; otherwise an error
* code describing why the open was not possible. * code describing why the open was not possible.
*/ */
GIT_EXTERN(git_result_t) git_odb_open(git_odb_t **out, const char *objects_dir); GIT_EXTERN(int) git_odb_open(git_odb_t **out, const char *objects_dir);
/** /**
* Close an open object database. * Close an open object database.
...@@ -101,7 +101,7 @@ typedef struct { ...@@ -101,7 +101,7 @@ typedef struct {
* - GIT_SUCCESS if the object was read; * - GIT_SUCCESS if the object was read;
* - GIT_ENOTFOUND if the object is not in the database. * - GIT_ENOTFOUND if the object is not in the database.
*/ */
GIT_EXTERN(git_result_t) git_odb_read(git_sobj_t *out, git_odb_t *db, const git_oid_t *id); GIT_EXTERN(int) git_odb_read(git_sobj_t *out, git_odb_t *db, const git_oid_t *id);
/** /**
* Read a small object from the database using only pack files. * Read a small object from the database using only pack files.
...@@ -115,7 +115,7 @@ GIT_EXTERN(git_result_t) git_odb_read(git_sobj_t *out, git_odb_t *db, const git_ ...@@ -115,7 +115,7 @@ GIT_EXTERN(git_result_t) git_odb_read(git_sobj_t *out, git_odb_t *db, const git_
* - GIT_SUCCESS if the object was read. * - GIT_SUCCESS if the object was read.
* - GIT_ENOTFOUND if the object is not in the database. * - GIT_ENOTFOUND if the object is not in the database.
*/ */
GIT_EXTERN(git_result_t) git_odb__read_packed(git_sobj_t *out, git_odb_t *db, const git_oid_t *id); GIT_EXTERN(int) git_odb__read_packed(git_sobj_t *out, git_odb_t *db, const git_oid_t *id);
/** /**
* Read a small object from the database using only loose object files. * Read a small object from the database using only loose object files.
...@@ -129,7 +129,7 @@ GIT_EXTERN(git_result_t) git_odb__read_packed(git_sobj_t *out, git_odb_t *db, co ...@@ -129,7 +129,7 @@ GIT_EXTERN(git_result_t) git_odb__read_packed(git_sobj_t *out, git_odb_t *db, co
* - GIT_SUCCESS if the object was read. * - GIT_SUCCESS if the object was read.
* - GIT_ENOTFOUND if the object is not in the database. * - GIT_ENOTFOUND if the object is not in the database.
*/ */
GIT_EXTERN(git_result_t) git_odb__read_loose(git_sobj_t *out, git_odb_t *db, const git_oid_t *id); GIT_EXTERN(int) git_odb__read_loose(git_sobj_t *out, git_odb_t *db, const git_oid_t *id);
/** /**
* Release all memory used by the sobj structure. * Release all memory used by the sobj structure.
......
...@@ -55,7 +55,7 @@ static signed char from_hex[] = { ...@@ -55,7 +55,7 @@ static signed char from_hex[] = {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* f0 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* f0 */
}; };
git_result_t git_oid_mkstr(git_oid_t *out, const char *str) int git_oid_mkstr(git_oid_t *out, const char *str)
{ {
int p; int p;
for (p = 0; p < sizeof(out->id); p++, str += 2) { for (p = 0; p < sizeof(out->id); p++, str += 2) {
......
...@@ -62,7 +62,7 @@ typedef struct ...@@ -62,7 +62,7 @@ typedef struct
* needed for an oid encoded in hex (40 bytes). * needed for an oid encoded in hex (40 bytes).
* @return GIT_SUCCESS if valid; GIT_ENOTOID on failure. * @return GIT_SUCCESS if valid; GIT_ENOTOID on failure.
*/ */
GIT_EXTERN(git_result_t) git_oid_mkstr(git_oid_t *out, const char *str); GIT_EXTERN(int) git_oid_mkstr(git_oid_t *out, const char *str);
/** /**
* Copy an already raw oid into a git_oid structure. * Copy an already raw oid into a git_oid structure.
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
struct git_revp_attr_t { struct git_revp_attr_t {
size_t app_size; size_t app_size;
git_result_t (*app_init)(git_commit_t *, void *); int (*app_init)(git_commit_t *, void *);
}; };
struct git_revp_t { struct git_revp_t {
......
...@@ -90,7 +90,7 @@ GIT_EXTERN(git_revp_attr_t*) git_revp_attr_alloc(void); ...@@ -90,7 +90,7 @@ GIT_EXTERN(git_revp_attr_t*) git_revp_attr_alloc(void);
GIT_EXTERN(void) git_revp_attr_appdata( GIT_EXTERN(void) git_revp_attr_appdata(
git_revp_attr_t *attr, git_revp_attr_t *attr,
size_t size, size_t size,
git_result_t (*init)(git_commit_t *, void *)); int (*init)(git_commit_t *, void *));
/** /**
* Free a pool configuration. * Free a pool configuration.
......
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