Replace git_result_t with int This seems to be preferred on the mailing list. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
diff --git a/CONVENTIONS b/CONVENTIONS
index 60811b0..4b09c08 100644
--- a/CONVENTIONS
+++ b/CONVENTIONS
@@ -37,12 +37,12 @@ and may disappear or change their signature in a future release.
Calling Conventions
-------------------
-Functions should prefer to return a 'git_result_t' to indicate
-success/failure and supply any output through the first argument
-(or first few arguments if multiple outputs are supplied).
+Functions should prefer to return a 'int' to indicate success or
+failure and supply any output through the first argument (or first
+few arguments if multiple outputs are supplied).
-git_result_t status codes are 0 for GIT_SUCCESS and < 0 for an
-error. This permits common POSIX result testing:
+int status codes are 0 for GIT_SUCCESS and < 0 for an error.
+This permits common POSIX result testing:
----
if (git_odb_open(&odb, path))
diff --git a/src/git_common.h b/src/git_common.h
index 6d8e93b..791826c 100644
--- a/src/git_common.h
+++ b/src/git_common.h
@@ -62,9 +62,6 @@ GIT_BEGIN_DECL
# define GIT_EXTERN(type) type
#endif
-/** Generic result code for any API call. */
-typedef int git_result_t;
-
/** Operation completed successfully. */
#define GIT_SUCCESS 0
diff --git a/src/git_odb.c b/src/git_odb.c
index 13de54b..d7ae061 100644
--- a/src/git_odb.c
+++ b/src/git_odb.c
@@ -46,7 +46,7 @@ struct git_odb_t {
unsigned n_alternates;
};
-git_result_t git_odb_read(
+int git_odb_read(
git_sobj_t *out,
git_odb_t *db,
const git_oid_t *id)
diff --git a/src/git_odb.h b/src/git_odb.h
index 1213764..8e0a161 100644
--- a/src/git_odb.h
+++ b/src/git_odb.h
@@ -60,7 +60,7 @@ typedef struct git_odb_t git_odb_t;
* @return GIT_SUCCESS if the database opened; otherwise an error
* 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.
@@ -101,7 +101,7 @@ typedef struct {
* - GIT_SUCCESS if the object was read;
* - 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.
@@ -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_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.
@@ -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_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.
diff --git a/src/git_oid.c b/src/git_oid.c
index fd899f4..b20f1d8 100644
--- a/src/git_oid.c
+++ b/src/git_oid.c
@@ -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 */
};
-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;
for (p = 0; p < sizeof(out->id); p++, str += 2) {
diff --git a/src/git_oid.h b/src/git_oid.h
index 30c62a2..9a9e5ab 100644
--- a/src/git_oid.h
+++ b/src/git_oid.h
@@ -62,7 +62,7 @@ typedef struct
* needed for an oid encoded in hex (40 bytes).
* @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.
diff --git a/src/git_revwalk.c b/src/git_revwalk.c
index 7b7d17f..5e9e1f2 100644
--- a/src/git_revwalk.c
+++ b/src/git_revwalk.c
@@ -39,7 +39,7 @@
struct git_revp_attr_t {
size_t app_size;
- git_result_t (*app_init)(git_commit_t *, void *);
+ int (*app_init)(git_commit_t *, void *);
};
struct git_revp_t {
diff --git a/src/git_revwalk.h b/src/git_revwalk.h
index a84d130..e7ed799 100644
--- a/src/git_revwalk.h
+++ b/src/git_revwalk.h
@@ -90,7 +90,7 @@ GIT_EXTERN(git_revp_attr_t*) git_revp_attr_alloc(void);
GIT_EXTERN(void) git_revp_attr_appdata(
git_revp_attr_t *attr,
size_t size,
- git_result_t (*init)(git_commit_t *, void *));
+ int (*init)(git_commit_t *, void *));
/**
* Free a pool configuration.