Duplicated type object
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
diff --git a/src/cache.h b/src/cache.h
index 3633f62..d57f244 100644
--- a/src/cache.h
+++ b/src/cache.h
@@ -22,9 +22,9 @@ enum {
typedef struct {
git_oid oid;
- int32_t type;
+ int16_t type;
+ uint16_t flags;
size_t size;
- uint32_t flags;
git_atomic refcount;
} git_cached_obj;
diff --git a/src/object.c b/src/object.c
index 2667fca..80b765e 100644
--- a/src/object.c
+++ b/src/object.c
@@ -71,8 +71,6 @@ static int create_object(git_object **object_out, git_otype type)
return -1;
}
- object->type = type;
-
*object_out = object;
return 0;
}
@@ -92,17 +90,16 @@ int git_object__from_odb_object(
return GIT_ENOTFOUND;
}
- type = odb_obj->cached.type;
-
- if ((error = create_object(&object, type)) < 0)
+ if ((error = create_object(&object, odb_obj->cached.type)) < 0)
return error;
/* Initialize parent object */
git_oid_cpy(&object->cached.oid, &odb_obj->cached.oid);
object->cached.size = odb_obj->cached.size;
+ object->cached.type = odb_obj->cached.type;
object->repo = repo;
- switch (type) {
+ switch (object->cached.type) {
case GIT_OBJ_COMMIT:
error = git_commit__parse((git_commit *)object, odb_obj);
break;
@@ -167,7 +164,7 @@ int git_object_lookup_prefix(
if (cached->flags == GIT_CACHE_STORE_PARSED) {
object = (git_object *)cached;
- if (type != GIT_OBJ_ANY && type != object->type) {
+ if (type != GIT_OBJ_ANY && type != object->cached.type) {
git_object_free(object);
giterr_set(GITERR_INVALID,
"The requested type does not match the type in ODB");
@@ -231,7 +228,7 @@ void git_object__free(void *_obj)
assert(object);
- switch (object->type) {
+ switch (object->cached.type) {
case GIT_OBJ_COMMIT:
git_commit__free((git_commit *)object);
break;
@@ -271,7 +268,7 @@ const git_oid *git_object_id(const git_object *obj)
git_otype git_object_type(const git_object *obj)
{
assert(obj);
- return obj->type;
+ return obj->cached.type;
}
git_repository *git_object_owner(const git_object *obj)
diff --git a/src/object.h b/src/object.h
index c1e5059..d187c55 100644
--- a/src/object.h
+++ b/src/object.h
@@ -11,7 +11,6 @@
struct git_object {
git_cached_obj cached;
git_repository *repo;
- git_otype type;
};
/* fully free the object; internal method, DO NOT EXPORT */