Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
object: deprecate git_object__size for removal
In #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.
  • Loading branch information
carlosmn committed Jul 29, 2019
commit c8e249b032f371b51d409052d571696798dbe862
12 changes: 12 additions & 0 deletions include/git2/deprecated.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,18 @@ GIT_EXTERN(int) git_index_add_frombuffer(
#define GIT_OBJ_OFS_DELTA GIT_OBJECT_OFS_DELTA
#define GIT_OBJ_REF_DELTA GIT_OBJECT_REF_DELTA

/**
* Get the size in bytes for the structure which
* acts as an in-memory representation of any given
* object type.
*
* For all the core types, this would the equivalent
* of calling `sizeof(git_commit)` if the core types
* were not opaque on the external API.
*
* @param type object type to get its size
* @return size in bytes of the object
*/
GIT_EXTERN(size_t) git_object__size(git_object_t type);

/**@}*/
Expand Down
14 changes: 0 additions & 14 deletions include/git2/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,20 +185,6 @@ GIT_EXTERN(git_object_t) git_object_string2type(const char *str);
*/
GIT_EXTERN(int) git_object_typeisloose(git_object_t type);

/**
* Get the size in bytes for the structure which
* acts as an in-memory representation of any given
* object type.
*
* For all the core types, this would the equivalent
* of calling `sizeof(git_commit)` if the core types
* were not opaque on the external API.
*
* @param type object type to get its size
* @return size in bytes of the object
*/
GIT_EXTERN(size_t) git_object_size(git_object_t type);

/**
* Recursively peel an object until an object of the specified type is met.
*
Expand Down
14 changes: 4 additions & 10 deletions src/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
bool git_object__strict_input_validation = true;

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

typedef struct {
const char *str; /* type name string */
Expand Down Expand Up @@ -75,7 +76,7 @@ int git_object__from_raw(
return GIT_ENOTFOUND;
}

if ((object_size = git_object_size(type)) == 0) {
if ((object_size = git_object__size(type)) == 0) {
git_error_set(GIT_ERROR_INVALID, "the requested type is invalid");
return GIT_ENOTFOUND;
}
Expand Down Expand Up @@ -123,7 +124,7 @@ int git_object__from_odb_object(
return GIT_ENOTFOUND;
}

if ((object_size = git_object_size(odb_obj->cached.type)) == 0) {
if ((object_size = git_object__size(odb_obj->cached.type)) == 0) {
git_error_set(GIT_ERROR_INVALID, "the requested type is invalid");
return GIT_ENOTFOUND;
}
Expand Down Expand Up @@ -316,7 +317,7 @@ int git_object_typeisloose(git_object_t type)
return (git_objects_table[type].size > 0) ? 1 : 0;
}

size_t git_object_size(git_object_t type)
size_t git_object__size(git_object_t type)
{
if (type < 0 || ((size_t) type) >= ARRAY_SIZE(git_objects_table))
return 0;
Expand Down Expand Up @@ -549,10 +550,3 @@ bool git_object__is_valid(

return true;
}

/* Deprecated functions */

size_t git_object__size(git_object_t type)
{
return git_object_size(type);
}