Skip to content

Commit 19faf7c

Browse files
committed
object_type: update public API to use git_object_t
git_object_t is the future; update the public API to use it. This will also ensure that we can build our tests which make use of the old API without modification (and without compiler warnings).
1 parent 26b21b3 commit 19faf7c

File tree

8 files changed

+42
-42
lines changed

8 files changed

+42
-42
lines changed

include/git2/common.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,13 @@ typedef enum {
243243
* > `GIT_CONFIG_LEVEL_GLOBAL`, `GIT_CONFIG_LEVEL_XDG`, or
244244
* > `GIT_CONFIG_LEVEL_PROGRAMDATA`.
245245
*
246-
* * opts(GIT_OPT_SET_CACHE_OBJECT_LIMIT, git_otype type, size_t size)
246+
* * opts(GIT_OPT_SET_CACHE_OBJECT_LIMIT, git_object_t type, size_t size)
247247
*
248248
* > Set the maximum data size for the given type of object to be
249249
* > considered eligible for caching in memory. Setting to value to
250250
* > zero means that that type of object will not be cached.
251-
* > Defaults to 0 for GIT_OBJ_BLOB (i.e. won't cache blobs) and 4k
252-
* > for GIT_OBJ_COMMIT, GIT_OBJ_TREE, and GIT_OBJ_TAG.
251+
* > Defaults to 0 for GIT_OBJECT_BLOB (i.e. won't cache blobs) and 4k
252+
* > for GIT_OBJECT_COMMIT, GIT_OBJECT_TREE, and GIT_OBJECT_TAG.
253253
*
254254
* * opts(GIT_OPT_SET_CACHE_MAX_SIZE, ssize_t max_storage_bytes)
255255
*

include/git2/object.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ GIT_BEGIN_DECL
3030
*
3131
* The 'type' parameter must match the type of the object
3232
* in the odb; the method will fail otherwise.
33-
* The special value 'GIT_OBJ_ANY' may be passed to let
33+
* The special value 'GIT_OBJECT_ANY' may be passed to let
3434
* the method guess the object's type.
3535
*
3636
* @param object pointer to the looked-up object
@@ -43,7 +43,7 @@ GIT_EXTERN(int) git_object_lookup(
4343
git_object **object,
4444
git_repository *repo,
4545
const git_oid *id,
46-
git_otype type);
46+
git_object_t type);
4747

4848
/**
4949
* Lookup a reference to one of the objects in a repository,
@@ -62,7 +62,7 @@ GIT_EXTERN(int) git_object_lookup(
6262
*
6363
* The 'type' parameter must match the type of the object
6464
* in the odb; the method will fail otherwise.
65-
* The special value 'GIT_OBJ_ANY' may be passed to let
65+
* The special value 'GIT_OBJECT_ANY' may be passed to let
6666
* the method guess the object's type.
6767
*
6868
* @param object_out pointer where to store the looked-up object
@@ -77,7 +77,7 @@ GIT_EXTERN(int) git_object_lookup_prefix(
7777
git_repository *repo,
7878
const git_oid *id,
7979
size_t len,
80-
git_otype type);
80+
git_object_t type);
8181

8282

8383
/**
@@ -94,7 +94,7 @@ GIT_EXTERN(int) git_object_lookup_bypath(
9494
git_object **out,
9595
const git_object *treeish,
9696
const char *path,
97-
git_otype type);
97+
git_object_t type);
9898

9999
/**
100100
* Get the id (SHA1) of a repository object
@@ -124,7 +124,7 @@ GIT_EXTERN(int) git_object_short_id(git_buf *out, const git_object *obj);
124124
* @param obj the repository object
125125
* @return the object's type
126126
*/
127-
GIT_EXTERN(git_otype) git_object_type(const git_object *obj);
127+
GIT_EXTERN(git_object_t) git_object_type(const git_object *obj);
128128

129129
/**
130130
* Get the repository that owns this object
@@ -166,24 +166,24 @@ GIT_EXTERN(void) git_object_free(git_object *object);
166166
* @param type object type to convert.
167167
* @return the corresponding string representation.
168168
*/
169-
GIT_EXTERN(const char *) git_object_type2string(git_otype type);
169+
GIT_EXTERN(const char *) git_object_type2string(git_object_t type);
170170

171171
/**
172-
* Convert a string object type representation to it's git_otype.
172+
* Convert a string object type representation to it's git_object_t.
173173
*
174174
* @param str the string to convert.
175-
* @return the corresponding git_otype.
175+
* @return the corresponding git_object_t.
176176
*/
177-
GIT_EXTERN(git_otype) git_object_string2type(const char *str);
177+
GIT_EXTERN(git_object_t) git_object_string2type(const char *str);
178178

179179
/**
180-
* Determine if the given git_otype is a valid loose object type.
180+
* Determine if the given git_object_t is a valid loose object type.
181181
*
182182
* @param type object type to test.
183183
* @return true if the type represents a valid loose object type,
184184
* false otherwise.
185185
*/
186-
GIT_EXTERN(int) git_object_typeisloose(git_otype type);
186+
GIT_EXTERN(int) git_object_typeisloose(git_object_t type);
187187

188188
/**
189189
* Get the size in bytes for the structure which
@@ -197,7 +197,7 @@ GIT_EXTERN(int) git_object_typeisloose(git_otype type);
197197
* @param type object type to get its size
198198
* @return size in bytes of the object
199199
*/
200-
GIT_EXTERN(size_t) git_object__size(git_otype type);
200+
GIT_EXTERN(size_t) git_object__size(git_object_t type);
201201

202202
/**
203203
* Recursively peel an object until an object of the specified type is met.
@@ -206,7 +206,7 @@ GIT_EXTERN(size_t) git_object__size(git_otype type);
206206
* GIT_EINVALIDSPEC will be returned (e.g. trying to peel a blob to a
207207
* tree).
208208
*
209-
* If you pass `GIT_OBJ_ANY` as the target type, then the object will
209+
* If you pass `GIT_OBJECT_ANY` as the target type, then the object will
210210
* be peeled until the type changes. A tag will be peeled until the
211211
* referenced object is no longer a tag, and a commit will be peeled
212212
* to a tree. Any other object type will return GIT_EINVALIDSPEC.
@@ -219,13 +219,13 @@ GIT_EXTERN(size_t) git_object__size(git_otype type);
219219
*
220220
* @param peeled Pointer to the peeled git_object
221221
* @param object The object to be processed
222-
* @param target_type The type of the requested object (a GIT_OBJ_ value)
222+
* @param target_type The type of the requested object (a GIT_OBJECT_ value)
223223
* @return 0 on success, GIT_EINVALIDSPEC, GIT_EPEEL, or an error code
224224
*/
225225
GIT_EXTERN(int) git_object_peel(
226226
git_object **peeled,
227227
const git_object *object,
228-
git_otype target_type);
228+
git_object_t target_type);
229229

230230
/**
231231
* Create an in-memory copy of a Git object. The copy must be

include/git2/odb.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ GIT_EXTERN(int) git_odb_read_prefix(git_odb_object **out, git_odb *db, const git
146146
* - 0 if the object was read;
147147
* - GIT_ENOTFOUND if the object is not in the database.
148148
*/
149-
GIT_EXTERN(int) git_odb_read_header(size_t *len_out, git_otype *type_out, git_odb *db, const git_oid *id);
149+
GIT_EXTERN(int) git_odb_read_header(size_t *len_out, git_object_t *type_out, git_odb *db, const git_oid *id);
150150

151151
/**
152152
* Determine if the given object can be found in the object database.
@@ -189,9 +189,9 @@ typedef struct git_odb_expand_id {
189189

190190
/**
191191
* The (optional) type of the object to search for; leave as `0` or set
192-
* to `GIT_OBJ_ANY` to query for any object matching the ID.
192+
* to `GIT_OBJECT_ANY` to query for any object matching the ID.
193193
*/
194-
git_otype type;
194+
git_object_t type;
195195
} git_odb_expand_id;
196196

197197
/**
@@ -270,7 +270,7 @@ GIT_EXTERN(int) git_odb_foreach(git_odb *db, git_odb_foreach_cb cb, void *payloa
270270
* @param type type of the data to store
271271
* @return 0 or an error code
272272
*/
273-
GIT_EXTERN(int) git_odb_write(git_oid *out, git_odb *odb, const void *data, size_t len, git_otype type);
273+
GIT_EXTERN(int) git_odb_write(git_oid *out, git_odb *odb, const void *data, size_t len, git_object_t type);
274274

275275
/**
276276
* Open a stream to write an object into the ODB
@@ -293,7 +293,7 @@ GIT_EXTERN(int) git_odb_write(git_oid *out, git_odb *odb, const void *data, size
293293
* @param type type of the object that will be written
294294
* @return 0 if the stream was created; error code otherwise
295295
*/
296-
GIT_EXTERN(int) git_odb_open_wstream(git_odb_stream **out, git_odb *db, git_off_t size, git_otype type);
296+
GIT_EXTERN(int) git_odb_open_wstream(git_odb_stream **out, git_odb *db, git_off_t size, git_object_t type);
297297

298298
/**
299299
* Write to an odb stream
@@ -366,7 +366,7 @@ GIT_EXTERN(void) git_odb_stream_free(git_odb_stream *stream);
366366
GIT_EXTERN(int) git_odb_open_rstream(
367367
git_odb_stream **out,
368368
size_t *len,
369-
git_otype *type,
369+
git_object_t *type,
370370
git_odb *db,
371371
const git_oid *oid);
372372

@@ -406,7 +406,7 @@ GIT_EXTERN(int) git_odb_write_pack(
406406
* @param type of the data to hash
407407
* @return 0 or an error code
408408
*/
409-
GIT_EXTERN(int) git_odb_hash(git_oid *out, const void *data, size_t len, git_otype type);
409+
GIT_EXTERN(int) git_odb_hash(git_oid *out, const void *data, size_t len, git_object_t type);
410410

411411
/**
412412
* Read a file from disk and fill a git_oid with the object id
@@ -421,7 +421,7 @@ GIT_EXTERN(int) git_odb_hash(git_oid *out, const void *data, size_t len, git_oty
421421
* @param type the type of the object that will be hashed
422422
* @return 0 or an error code
423423
*/
424-
GIT_EXTERN(int) git_odb_hashfile(git_oid *out, const char *path, git_otype type);
424+
GIT_EXTERN(int) git_odb_hashfile(git_oid *out, const char *path, git_object_t type);
425425

426426
/**
427427
* Create a copy of an odb_object
@@ -487,7 +487,7 @@ GIT_EXTERN(size_t) git_odb_object_size(git_odb_object *object);
487487
* @param object the object
488488
* @return the type
489489
*/
490-
GIT_EXTERN(git_otype) git_odb_object_type(git_odb_object *object);
490+
GIT_EXTERN(git_object_t) git_odb_object_type(git_odb_object *object);
491491

492492
/**
493493
* Add a custom backend to an existing Object DB

include/git2/refs.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -699,19 +699,19 @@ GIT_EXTERN(int) git_reference_normalize_name(
699699
* The retrieved `peeled` object is owned by the repository
700700
* and should be closed with the `git_object_free` method.
701701
*
702-
* If you pass `GIT_OBJ_ANY` as the target type, then the object
702+
* If you pass `GIT_OBJECT_ANY` as the target type, then the object
703703
* will be peeled until a non-tag object is met.
704704
*
705705
* @param out Pointer to the peeled git_object
706706
* @param ref The reference to be processed
707-
* @param type The type of the requested object (GIT_OBJ_COMMIT,
708-
* GIT_OBJ_TAG, GIT_OBJ_TREE, GIT_OBJ_BLOB or GIT_OBJ_ANY).
707+
* @param type The type of the requested object (GIT_OBJECT_COMMIT,
708+
* GIT_OBJECT_TAG, GIT_OBJECT_TREE, GIT_OBJECT_BLOB or GIT_OBJECT_ANY).
709709
* @return 0 on success, GIT_EAMBIGUOUS, GIT_ENOTFOUND or an error code
710710
*/
711711
GIT_EXTERN(int) git_reference_peel(
712712
git_object **out,
713713
git_reference *ref,
714-
git_otype type);
714+
git_object_t type);
715715

716716
/**
717717
* Ensure the reference name is well-formed.

include/git2/repository.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ GIT_EXTERN(int) git_repository_mergehead_foreach(
685685
* @param repo Repository pointer
686686
* @param path Path to file on disk whose contents should be hashed. If the
687687
* repository is not NULL, this can be a relative path.
688-
* @param type The object type to hash as (e.g. GIT_OBJ_BLOB)
688+
* @param type The object type to hash as (e.g. GIT_OBJECT_BLOB)
689689
* @param as_path The path to use to look up filtering rules. If this is
690690
* NULL, then the `path` parameter will be used instead. If
691691
* this is passed as the empty string, then no filters will be
@@ -696,7 +696,7 @@ GIT_EXTERN(int) git_repository_hashfile(
696696
git_oid *out,
697697
git_repository *repo,
698698
const char *path,
699-
git_otype type,
699+
git_object_t type,
700700
const char *as_path);
701701

702702
/**

include/git2/sys/odb_backend.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,30 +33,30 @@ struct git_odb_backend {
3333
* the function git_odb_backend_malloc to ensure that it can
3434
* be safely freed later. */
3535
int (* read)(
36-
void **, size_t *, git_otype *, git_odb_backend *, const git_oid *);
36+
void **, size_t *, git_object_t *, git_odb_backend *, const git_oid *);
3737

3838
/* To find a unique object given a prefix of its oid. The oid given
3939
* must be so that the remaining (GIT_OID_HEXSZ - len)*4 bits are 0s.
4040
*/
4141
int (* read_prefix)(
42-
git_oid *, void **, size_t *, git_otype *,
42+
git_oid *, void **, size_t *, git_object_t *,
4343
git_odb_backend *, const git_oid *, size_t);
4444

4545
int (* read_header)(
46-
size_t *, git_otype *, git_odb_backend *, const git_oid *);
46+
size_t *, git_object_t *, git_odb_backend *, const git_oid *);
4747

4848
/**
4949
* Write an object into the backend. The id of the object has
5050
* already been calculated and is passed in.
5151
*/
5252
int (* write)(
53-
git_odb_backend *, const git_oid *, const void *, size_t, git_otype);
53+
git_odb_backend *, const git_oid *, const void *, size_t, git_object_t);
5454

5555
int (* writestream)(
56-
git_odb_stream **, git_odb_backend *, git_off_t, git_otype);
56+
git_odb_stream **, git_odb_backend *, git_off_t, git_object_t);
5757

5858
int (* readstream)(
59-
git_odb_stream **, size_t *, git_otype *,
59+
git_odb_stream **, size_t *, git_object_t *,
6060
git_odb_backend *, const git_oid *);
6161

6262
int (* exists)(

include/git2/tag.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ GIT_EXTERN(const git_oid *) git_tag_target_id(const git_tag *tag);
102102
* @param tag a previously loaded tag.
103103
* @return type of the tagged object
104104
*/
105-
GIT_EXTERN(git_otype) git_tag_target_type(const git_tag *tag);
105+
GIT_EXTERN(git_object_t) git_tag_target_type(const git_tag *tag);
106106

107107
/**
108108
* Get the name of a tag

include/git2/tree.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ GIT_EXTERN(const git_oid *) git_tree_entry_id(const git_tree_entry *entry);
189189
* @param entry a tree entry
190190
* @return the type of the pointed object
191191
*/
192-
GIT_EXTERN(git_otype) git_tree_entry_type(const git_tree_entry *entry);
192+
GIT_EXTERN(git_object_t) git_tree_entry_type(const git_tree_entry *entry);
193193

194194
/**
195195
* Get the UNIX file attributes of a tree entry

0 commit comments

Comments
 (0)