Skip to content

Commit 4383ab4

Browse files
authored
Merge pull request libgit2#5365 from libgit2/ethomson/no_void
Return int from non-free functions
2 parents 4460bf4 + 4cae9e7 commit 4383ab4

File tree

20 files changed

+132
-56
lines changed

20 files changed

+132
-56
lines changed

include/git2/attr.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,11 @@ GIT_EXTERN(int) git_attr_foreach(
238238
* disk no longer match the cached contents of memory. This will cause
239239
* the attributes files to be reloaded the next time that an attribute
240240
* access function is called.
241+
*
242+
* @param repo The repository containing the gitattributes cache
243+
* @return 0 on success, or an error code
241244
*/
242-
GIT_EXTERN(void) git_attr_cache_flush(
245+
GIT_EXTERN(int) git_attr_cache_flush(
243246
git_repository *repo);
244247

245248
/**

include/git2/common.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,9 @@ GIT_BEGIN_DECL
117117
* @param major Store the major version number
118118
* @param minor Store the minor version number
119119
* @param rev Store the revision (patch) number
120+
* @return 0 on success or an error code on failure
120121
*/
121-
GIT_EXTERN(void) git_libgit2_version(int *major, int *minor, int *rev);
122+
GIT_EXTERN(int) git_libgit2_version(int *major, int *minor, int *rev);
122123

123124
/**
124125
* Combinations of these values describe the features with which libgit2

include/git2/errors.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,9 @@ GIT_EXTERN(void) git_error_clear(void);
143143
* @param error_class One of the `git_error_t` enum above describing the
144144
* general subsystem that is responsible for the error.
145145
* @param string The formatted error message to keep
146+
* @return 0 on success or -1 on failure
146147
*/
147-
GIT_EXTERN(void) git_error_set_str(int error_class, const char *string);
148+
GIT_EXTERN(int) git_error_set_str(int error_class, const char *string);
148149

149150
/**
150151
* Set the error message to a special value for memory allocation failure.

include/git2/oid.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,9 @@ GIT_EXTERN(int) git_oid_fromstrn(git_oid *out, const char *str, size_t length);
7373
*
7474
* @param out oid structure the result is written into.
7575
* @param raw the raw input bytes to be copied.
76+
* @return 0 on success or error code
7677
*/
77-
GIT_EXTERN(void) git_oid_fromraw(git_oid *out, const unsigned char *raw);
78+
GIT_EXTERN(int) git_oid_fromraw(git_oid *out, const unsigned char *raw);
7879

7980
/**
8081
* Format a git_oid into a hex string.
@@ -85,8 +86,9 @@ GIT_EXTERN(void) git_oid_fromraw(git_oid *out, const unsigned char *raw);
8586
* oid digits are written; a '\\0' terminator must be added
8687
* by the caller if it is required.
8788
* @param id oid structure to format.
89+
* @return 0 on success or error code
8890
*/
89-
GIT_EXTERN(void) git_oid_fmt(char *out, const git_oid *id);
91+
GIT_EXTERN(int) git_oid_fmt(char *out, const git_oid *id);
9092

9193
/**
9294
* Format a git_oid into a partial hex string.
@@ -96,8 +98,9 @@ GIT_EXTERN(void) git_oid_fmt(char *out, const git_oid *id);
9698
* will be zeroed; if not, a '\0' terminator is NOT added.
9799
* @param n number of characters to write into out string
98100
* @param id oid structure to format.
101+
* @return 0 on success or error code
99102
*/
100-
GIT_EXTERN(void) git_oid_nfmt(char *out, size_t n, const git_oid *id);
103+
GIT_EXTERN(int) git_oid_nfmt(char *out, size_t n, const git_oid *id);
101104

102105
/**
103106
* Format a git_oid into a loose-object path string.
@@ -111,8 +114,9 @@ GIT_EXTERN(void) git_oid_nfmt(char *out, size_t n, const git_oid *id);
111114
* oid digits are written; a '\\0' terminator must be added
112115
* by the caller if it is required.
113116
* @param id oid structure to format.
117+
* @return 0 on success, non-zero callback return value, or error code
114118
*/
115-
GIT_EXTERN(void) git_oid_pathfmt(char *out, const git_oid *id);
119+
GIT_EXTERN(int) git_oid_pathfmt(char *out, const git_oid *id);
116120

117121
/**
118122
* Format a git_oid into a statically allocated c-string.
@@ -151,8 +155,9 @@ GIT_EXTERN(char *) git_oid_tostr(char *out, size_t n, const git_oid *id);
151155
*
152156
* @param out oid structure the result is written into.
153157
* @param src oid structure to copy from.
158+
* @return 0 on success or error code
154159
*/
155-
GIT_EXTERN(void) git_oid_cpy(git_oid *out, const git_oid *src);
160+
GIT_EXTERN(int) git_oid_cpy(git_oid *out, const git_oid *src);
156161

157162
/**
158163
* Compare two oid structures.

include/git2/remote.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,17 +378,19 @@ GIT_EXTERN(int) git_remote_connected(const git_remote *remote);
378378
* the operation has been cancelled and if so stops the operation.
379379
*
380380
* @param remote the remote
381+
* @return 0 on success, or an error code
381382
*/
382-
GIT_EXTERN(void) git_remote_stop(git_remote *remote);
383+
GIT_EXTERN(int) git_remote_stop(git_remote *remote);
383384

384385
/**
385386
* Disconnect from the remote
386387
*
387388
* Close the connection to the remote.
388389
*
389390
* @param remote the remote to disconnect from
391+
* @return 0 on success, or an error code
390392
*/
391-
GIT_EXTERN(void) git_remote_disconnect(git_remote *remote);
393+
GIT_EXTERN(int) git_remote_disconnect(git_remote *remote);
392394

393395
/**
394396
* Free the memory associated with a remote

include/git2/revwalk.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,9 @@ GIT_EXTERN(int) git_revwalk_new(git_revwalk **out, git_repository *repo);
8484
* is over.
8585
*
8686
* @param walker handle to reset.
87+
* @return 0 or an error code
8788
*/
88-
GIT_EXTERN(void) git_revwalk_reset(git_revwalk *walker);
89+
GIT_EXTERN(int) git_revwalk_reset(git_revwalk *walker);
8990

9091
/**
9192
* Add a new root for the traversal
@@ -224,8 +225,9 @@ GIT_EXTERN(int) git_revwalk_next(git_oid *out, git_revwalk *walk);
224225
*
225226
* @param walk the walker being used for the traversal.
226227
* @param sort_mode combination of GIT_SORT_XXX flags
228+
* @return 0 or an error code
227229
*/
228-
GIT_EXTERN(void) git_revwalk_sorting(git_revwalk *walk, unsigned int sort_mode);
230+
GIT_EXTERN(int) git_revwalk_sorting(git_revwalk *walk, unsigned int sort_mode);
229231

230232
/**
231233
* Push and hide the respective endpoints of the given range.
@@ -246,8 +248,10 @@ GIT_EXTERN(int) git_revwalk_push_range(git_revwalk *walk, const char *range);
246248
* Simplify the history by first-parent
247249
*
248250
* No parents other than the first for each commit will be enqueued.
251+
*
252+
* @return 0 or an error code
249253
*/
250-
GIT_EXTERN(void) git_revwalk_simplify_first_parent(git_revwalk *walk);
254+
GIT_EXTERN(int) git_revwalk_simplify_first_parent(git_revwalk *walk);
251255

252256

253257
/**

include/git2/sys/index.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,9 @@ GIT_EXTERN(int) git_index_name_add(git_index *index,
7575
* Remove all filename conflict entries.
7676
*
7777
* @param index an existing index object
78+
* @return 0 or an error code
7879
*/
79-
GIT_EXTERN(void) git_index_name_clear(git_index *index);
80+
GIT_EXTERN(int) git_index_name_clear(git_index *index);
8081

8182
/**@}*/
8283

@@ -170,8 +171,9 @@ GIT_EXTERN(int) git_index_reuc_remove(git_index *index, size_t n);
170171
* Remove all resolve undo entries from the index
171172
*
172173
* @param index an existing index object
174+
* @return 0 or an error code
173175
*/
174-
GIT_EXTERN(void) git_index_reuc_clear(git_index *index);
176+
GIT_EXTERN(int) git_index_reuc_clear(git_index *index);
175177

176178
/**@}*/
177179

include/git2/sys/mempack.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ GIT_EXTERN(int) git_mempack_dump(git_buf *pack, git_repository *repo, git_odb_ba
7878
* semantics to the Git repository.
7979
*
8080
* @param backend The mempack backend
81+
* @return 0 on success; error code otherwise
8182
*/
82-
GIT_EXTERN(void) git_mempack_reset(git_odb_backend *backend);
83+
GIT_EXTERN(int) git_mempack_reset(git_odb_backend *backend);
8384

8485
GIT_END_DECL
8586

include/git2/sys/repository.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,11 @@ GIT_EXTERN(int) git_repository_new(git_repository **out);
4444
* trying to aggressively cleanup the repo before its
4545
* deallocation. `git_repository_free` already performs this operation
4646
* before deallocating the repo.
47+
*
48+
* @param repo The repository to clean up
49+
* @return 0 on success, or an error code
4750
*/
48-
GIT_EXTERN(void) git_repository__cleanup(git_repository *repo);
51+
GIT_EXTERN(int) git_repository__cleanup(git_repository *repo);
4952

5053
/**
5154
* Update the filesystem config settings for an open repository
@@ -78,8 +81,9 @@ GIT_EXTERN(int) git_repository_reinit_filesystem(
7881
*
7982
* @param repo A repository object
8083
* @param config A Config object
84+
* @return 0 on success, or an error code
8185
*/
82-
GIT_EXTERN(void) git_repository_set_config(git_repository *repo, git_config *config);
86+
GIT_EXTERN(int) git_repository_set_config(git_repository *repo, git_config *config);
8387

8488
/**
8589
* Set the Object Database for this repository
@@ -93,8 +97,9 @@ GIT_EXTERN(void) git_repository_set_config(git_repository *repo, git_config *con
9397
*
9498
* @param repo A repository object
9599
* @param odb An ODB object
100+
* @return 0 on success, or an error code
96101
*/
97-
GIT_EXTERN(void) git_repository_set_odb(git_repository *repo, git_odb *odb);
102+
GIT_EXTERN(int) git_repository_set_odb(git_repository *repo, git_odb *odb);
98103

99104
/**
100105
* 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);
108113
*
109114
* @param repo A repository object
110115
* @param refdb An refdb object
116+
* @return 0 on success, or an error code
111117
*/
112-
GIT_EXTERN(void) git_repository_set_refdb(git_repository *repo, git_refdb *refdb);
118+
GIT_EXTERN(int) git_repository_set_refdb(git_repository *repo, git_refdb *refdb);
113119

114120
/**
115121
* Set the index file for this repository
@@ -123,8 +129,9 @@ GIT_EXTERN(void) git_repository_set_refdb(git_repository *repo, git_refdb *refdb
123129
*
124130
* @param repo A repository object
125131
* @param index An index object
132+
* @return 0 on success, or an error code
126133
*/
127-
GIT_EXTERN(void) git_repository_set_index(git_repository *repo, git_index *index);
134+
GIT_EXTERN(int) git_repository_set_index(git_repository *repo, git_index *index);
128135

129136
/**
130137
* Set a repository to be bare.

include/git2/tree.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,9 @@ GIT_EXTERN(int) git_treebuilder_new(
258258
* Clear all the entires in the builder
259259
*
260260
* @param bld Builder to clear
261+
* @return 0 on success; error code otherwise
261262
*/
262-
GIT_EXTERN(void) git_treebuilder_clear(git_treebuilder *bld);
263+
GIT_EXTERN(int) git_treebuilder_clear(git_treebuilder *bld);
263264

264265
/**
265266
* Get the number of entries listed in a treebuilder
@@ -357,8 +358,9 @@ typedef int GIT_CALLBACK(git_treebuilder_filter_cb)(
357358
* @param bld Tree builder
358359
* @param filter Callback to filter entries
359360
* @param payload Extra data to pass to filter callback
361+
* @return 0 on success, non-zero callback return value, or error code
360362
*/
361-
GIT_EXTERN(void) git_treebuilder_filter(
363+
GIT_EXTERN(int) git_treebuilder_filter(
362364
git_treebuilder *bld,
363365
git_treebuilder_filter_cb filter,
364366
void *payload);

0 commit comments

Comments
 (0)