Skip to content

Commit c8e249b

Browse files
committed
object: deprecate git_object__size for removal
In libgit2#5118 we remove the double-underscore to make it a normally-named public function. However, this is not an interesting function outside of the library and it takes up a name for something that could be more useful. Remove the single-underscore version as we have not done any releases with it.
1 parent e3adc99 commit c8e249b

File tree

3 files changed

+16
-24
lines changed

3 files changed

+16
-24
lines changed

include/git2/deprecated.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,18 @@ GIT_EXTERN(int) git_index_add_frombuffer(
301301
#define GIT_OBJ_OFS_DELTA GIT_OBJECT_OFS_DELTA
302302
#define GIT_OBJ_REF_DELTA GIT_OBJECT_REF_DELTA
303303

304+
/**
305+
* Get the size in bytes for the structure which
306+
* acts as an in-memory representation of any given
307+
* object type.
308+
*
309+
* For all the core types, this would the equivalent
310+
* of calling `sizeof(git_commit)` if the core types
311+
* were not opaque on the external API.
312+
*
313+
* @param type object type to get its size
314+
* @return size in bytes of the object
315+
*/
304316
GIT_EXTERN(size_t) git_object__size(git_object_t type);
305317

306318
/**@}*/

include/git2/object.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -185,20 +185,6 @@ GIT_EXTERN(git_object_t) git_object_string2type(const char *str);
185185
*/
186186
GIT_EXTERN(int) git_object_typeisloose(git_object_t type);
187187

188-
/**
189-
* Get the size in bytes for the structure which
190-
* acts as an in-memory representation of any given
191-
* object type.
192-
*
193-
* For all the core types, this would the equivalent
194-
* of calling `sizeof(git_commit)` if the core types
195-
* were not opaque on the external API.
196-
*
197-
* @param type object type to get its size
198-
* @return size in bytes of the object
199-
*/
200-
GIT_EXTERN(size_t) git_object_size(git_object_t type);
201-
202188
/**
203189
* Recursively peel an object until an object of the specified type is met.
204190
*

src/object.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
bool git_object__strict_input_validation = true;
2222

2323
extern int git_odb_hash(git_oid *out, const void *data, size_t len, git_object_t type);
24+
size_t git_object__size(git_object_t type);
2425

2526
typedef struct {
2627
const char *str; /* type name string */
@@ -75,7 +76,7 @@ int git_object__from_raw(
7576
return GIT_ENOTFOUND;
7677
}
7778

78-
if ((object_size = git_object_size(type)) == 0) {
79+
if ((object_size = git_object__size(type)) == 0) {
7980
git_error_set(GIT_ERROR_INVALID, "the requested type is invalid");
8081
return GIT_ENOTFOUND;
8182
}
@@ -123,7 +124,7 @@ int git_object__from_odb_object(
123124
return GIT_ENOTFOUND;
124125
}
125126

126-
if ((object_size = git_object_size(odb_obj->cached.type)) == 0) {
127+
if ((object_size = git_object__size(odb_obj->cached.type)) == 0) {
127128
git_error_set(GIT_ERROR_INVALID, "the requested type is invalid");
128129
return GIT_ENOTFOUND;
129130
}
@@ -316,7 +317,7 @@ int git_object_typeisloose(git_object_t type)
316317
return (git_objects_table[type].size > 0) ? 1 : 0;
317318
}
318319

319-
size_t git_object_size(git_object_t type)
320+
size_t git_object__size(git_object_t type)
320321
{
321322
if (type < 0 || ((size_t) type) >= ARRAY_SIZE(git_objects_table))
322323
return 0;
@@ -549,10 +550,3 @@ bool git_object__is_valid(
549550

550551
return true;
551552
}
552-
553-
/* Deprecated functions */
554-
555-
size_t git_object__size(git_object_t type)
556-
{
557-
return git_object_size(type);
558-
}

0 commit comments

Comments
 (0)