]> git.proxmox.com Git - libgit2.git/commitdiff
Give object structures more descriptive names
authorVicent Marti <tanoku@gmail.com>
Sun, 19 Sep 2010 00:21:06 +0000 (03:21 +0300)
committerVicent Marti <tanoku@gmail.com>
Sun, 19 Sep 2010 00:21:06 +0000 (03:21 +0300)
The 'git_obj' structure is now called 'git_rawobj', since
it represents a raw object read from the ODB.

The 'git_repository_object' structure is now called 'git_object',
since it's the base object class for all objects.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
23 files changed:
src/commit.c
src/commit.h
src/delta-apply.c
src/delta-apply.h
src/git/common.h
src/git/odb.h
src/git/repository.h
src/git/tag.h
src/git/tree.h
src/odb.c
src/repository.c
src/repository.h
src/tag.c
src/tag.h
src/tree.c
src/tree.h
tests/t0103-objhash.c
tests/t0202-readloose.c
tests/t0203-readloose.c
tests/t0204-readpack.c
tests/t0301-write.c
tests/test_helpers.c
tests/test_helpers.h

index ce3a4184c6392d6db61777dd919c552b73331a3a..ad89088ae0fec1975bd854a3a85ff9c141be8500 100644 (file)
@@ -69,14 +69,14 @@ int git_commit__parse(git_commit *commit, unsigned int parse_flags, int close_db
 {
        int error = 0;
 
-       if ((error = git_repository__dbo_open((git_repository_object *)commit)) < 0)
+       if ((error = git_object__source_open((git_object *)commit)) < 0)
                return error;
 
        error = git_commit__parse_buffer(commit,
-                       commit->object.dbo.data, commit->object.dbo.len, parse_flags);
+                       commit->object.source.raw.data, commit->object.source.raw.len, parse_flags);
 
        if (close_db_object)
-               git_repository__dbo_close((git_repository_object *)commit);
+               git_object__source_close((git_object *)commit);
 
        return error;
 }
index ae4f06d65b2aa82a761ca03baec9e879b8a0285d..4e883c0747a7c6fead93f81af7700bf997bdd61d 100644 (file)
@@ -22,7 +22,7 @@ typedef struct git_commit_parents {
 } git_commit_parents;
 
 struct git_commit {
-       git_repository_object object;
+       git_object object;
 
        time_t commit_time;
        git_commit_parents *parents;
index 4915947ace431f2d1b4fe920d4cc446ca2388169..769e97344c58bee2dd17dcac81b6b596113c6828 100644 (file)
@@ -31,7 +31,7 @@ static int hdr_sz(
 }
 
 int git__delta_apply(
-       git_obj *out,
+       git_rawobj *out,
        const unsigned char *base,
        size_t base_len,
        const unsigned char *delta,
index 498bccdfec1fc223c27c0d84030ff419058e452d..642442de0d813bf37d89213b3fcaef7aad94c767 100644 (file)
@@ -16,7 +16,7 @@
  * - GIT_ERROR if the delta is corrupt or doesn't match the base.
  */
 extern int git__delta_apply(
-       git_obj *out,
+       git_rawobj *out,
        const unsigned char *base,
        size_t base_len,
        const unsigned char *delta,
index b43f4ee018bbacc80a510082ca100b6b47970454..faf9702a75f16795c41cbfed5428cd4a4295a549 100644 (file)
@@ -92,7 +92,7 @@ GIT_BEGIN_DECL
 typedef struct git_repository git_repository;
 
 /* Representation of a generic object in a repository */
-typedef struct git_repository_object git_repository_object;
+typedef struct git_object git_object;
 
 /** Parsed representation of a person */
 typedef struct git_person {
index 5d105ba70fb42f41a3a257b9ea8dca5e5fa1d8e6..a132346c66848df261cb2195c130163ae26e62ed 100644 (file)
@@ -52,7 +52,7 @@ typedef struct {
        void *data;          /**< Raw, decompressed object data. */
        size_t len;          /**< Total number of bytes in data. */
        git_otype type;      /**< Type of this object. */
-} git_obj;
+} git_rawobj;
 
 /**
  * Read an object from the database.
@@ -66,7 +66,7 @@ typedef struct {
  * - GIT_SUCCESS if the object was read;
  * - GIT_ENOTFOUND if the object is not in the database.
  */
-GIT_EXTERN(int) git_odb_read(git_obj *out, git_odb *db, const git_oid *id);
+GIT_EXTERN(int) git_odb_read(git_rawobj *out, git_odb *db, const git_oid *id);
 
 /**
  * Read an object from the database using only pack files.
@@ -80,7 +80,7 @@ GIT_EXTERN(int) git_odb_read(git_obj *out, git_odb *db, const git_oid *id);
  * - GIT_SUCCESS if the object was read.
  * - GIT_ENOTFOUND if the object is not in the database.
  */
-GIT_EXTERN(int) git_odb__read_packed(git_obj *out, git_odb *db, const git_oid *id);
+GIT_EXTERN(int) git_odb__read_packed(git_rawobj *out, git_odb *db, const git_oid *id);
 
 /**
  * Read an object from the database using only loose object files.
@@ -94,7 +94,7 @@ GIT_EXTERN(int) git_odb__read_packed(git_obj *out, git_odb *db, const git_oid *i
  * - GIT_SUCCESS if the object was read.
  * - GIT_ENOTFOUND if the object is not in the database.
  */
-GIT_EXTERN(int) git_odb__read_loose(git_obj *out, git_odb *db, const git_oid *id);
+GIT_EXTERN(int) git_odb__read_loose(git_rawobj *out, git_odb *db, const git_oid *id);
 
 /**
  * Write an object to the database.
@@ -106,7 +106,7 @@ GIT_EXTERN(int) git_odb__read_loose(git_obj *out, git_odb *db, const git_oid *id
  * - GIT_SUCCESS if the object was written;
  * - GIT_ERROR otherwise.
  */
-GIT_EXTERN(int) git_odb_write(git_oid *id, git_odb *db, git_obj *obj);
+GIT_EXTERN(int) git_odb_write(git_oid *id, git_odb *db, git_rawobj *obj);
 
 /**
  * Release all memory used by the obj structure.
@@ -117,7 +117,7 @@ GIT_EXTERN(int) git_odb_write(git_oid *id, git_odb *db, git_obj *obj);
  *
  * @param obj object descriptor to free.
  */
-GIT_INLINE(void) git_obj_close(git_obj *obj)
+GIT_INLINE(void) git_obj_close(git_rawobj *obj)
 {
        free(obj->data);
        obj->data = NULL;
@@ -152,7 +152,7 @@ GIT_EXTERN(git_otype) git_obj_string_to_type(const char *str);
 GIT_EXTERN(int) git_obj__loose_object_type(git_otype type);
 
 /**
- * Determine the object-ID (sha1 hash) of the given git_obj.
+ * Determine the object-ID (sha1 hash) of the given git_rawobj.
  *
  * The input obj must be a valid loose object type and the data
  * pointer must not be NULL, unless the len field is also zero.
@@ -163,7 +163,7 @@ GIT_EXTERN(int) git_obj__loose_object_type(git_otype type);
  * - GIT_SUCCESS if the object-ID was correctly determined.
  * - GIT_ERROR if the given object is malformed.
  */
-GIT_EXTERN(int) git_obj_hash(git_oid *id, git_obj *obj);
+GIT_EXTERN(int) git_obj_hash(git_oid *id, git_rawobj *obj);
 
 /**
  * Determine if the given object can be found in the object database.
index a61e5b6cc8ecdd82e5c0de6825ad5c61c1585472..33bb2fcef98ff9b627bbbf320ac12748a49a13de 100644 (file)
@@ -47,7 +47,7 @@ GIT_EXTERN(git_repository *) git_repository_alloc(git_odb *odb);
  * @param type the type of the object
  * @return a reference to the object
  */
-GIT_EXTERN(git_repository_object *) git_repository_lookup(git_repository *repo, const git_oid *id, git_otype type);
+GIT_EXTERN(git_object *) git_repository_lookup(git_repository *repo, const git_oid *id, git_otype type);
 
 /**
  * Get the object database behind a Git repository
@@ -63,7 +63,7 @@ GIT_EXTERN(git_odb *) git_repository_database(git_repository *repo);
  * @param obj the repository object
  * @return the SHA1 id
  */
-const git_oid *git_repository_object_id(git_repository_object *obj);
+const git_oid *git_object_id(git_object *obj);
 
 /**
  * Get the object type of an object
@@ -71,7 +71,7 @@ const git_oid *git_repository_object_id(git_repository_object *obj);
  * @param obj the repository object
  * @return the object's type
  */
-git_otype git_repository_object_type(git_repository_object *obj);
+git_otype git_object_type(git_object *obj);
 
 /**
  * Free a reference to one of the objects in the repostory.
@@ -85,7 +85,7 @@ git_otype git_repository_object_type(git_repository_object *obj);
  *
  * @param object the object to free
  */
-GIT_EXTERN(void) git_repository_object_free(git_repository_object *object);
+GIT_EXTERN(void) git_object_free(git_object *object);
 
 /**
  * Free a previously allocated repository
index d94083b11be88f3ca70f2f9645e69d978104d44e..a6efabb0e4521064c2ac4fc39ea3b25f705c6622 100644 (file)
@@ -41,7 +41,7 @@ GIT_EXTERN(const git_oid *) git_tag_id(git_tag *tag);
  * @param tag a previously loaded tag.
  * @return reference to a repository object
  */
-GIT_EXTERN(const git_repository_object *) git_tag_target(git_tag *t);
+GIT_EXTERN(const git_object *) git_tag_target(git_tag *t);
 
 /**
  * Get the type of a tag's tagged object
index fcc38d5e0af242045f6e5580c7f60d218f445305..646c085bb6a47f8db85cefde07f9f8916acd7d32 100644 (file)
@@ -85,11 +85,11 @@ GIT_EXTERN(const char *) git_tree_entry_name(const git_tree_entry *entry);
 GIT_EXTERN(const git_oid *) git_tree_entry_id(const git_tree_entry *entry);
 
 /**
- * Convert a tree entry to the git_repository_object it points too.
+ * Convert a tree entry to the git_object it points too.
  * @param entry a tree entry
  * @return a reference to the pointed object in the repository
  */
-GIT_EXTERN(git_repository_object *) git_tree_entry_2object(const git_tree_entry *entry);
+GIT_EXTERN(git_object *) git_tree_entry_2object(const git_tree_entry *entry);
 
 /** @} */
 GIT_END_DECL
index be896cc57f42ac2f94397da7a83e256cdb2a2457..5c59a4f40032ca6370f1abd9e9e3503803525170 100644 (file)
--- a/src/odb.c
+++ b/src/odb.c
@@ -187,7 +187,7 @@ int git_obj__loose_object_type(git_otype type)
        return obj_type_table[type].loose;
 }
 
-static int format_object_header(char *hdr, size_t n, git_obj *obj)
+static int format_object_header(char *hdr, size_t n, git_rawobj *obj)
 {
        const char *type_str = git_obj_type_to_string(obj->type);
        int len = snprintf(hdr, n, "%s %"PRIuZ, type_str, obj->len);
@@ -200,7 +200,7 @@ static int format_object_header(char *hdr, size_t n, git_obj *obj)
        return len+1;
 }
 
-static int hash_obj(git_oid *id, char *hdr, size_t n, int *len, git_obj *obj)
+static int hash_obj(git_oid *id, char *hdr, size_t n, int *len, git_rawobj *obj)
 {
        git_buf_vec vec[2];
        int  hdrlen;
@@ -228,7 +228,7 @@ static int hash_obj(git_oid *id, char *hdr, size_t n, int *len, git_obj *obj)
        return GIT_SUCCESS;
 }
 
-int git_obj_hash(git_oid *id, git_obj *obj)
+int git_obj_hash(git_oid *id, git_rawobj *obj)
 {
        char hdr[64];
        int  hdrlen;
@@ -456,7 +456,7 @@ static int inflate_buffer(void *in, size_t inlen, void *out, size_t outlen)
  * of loose object data into packs. This format is no longer used, but
  * we must still read it.
  */
-static int inflate_packlike_loose_disk_obj(git_obj *out, gitfo_buf *obj)
+static int inflate_packlike_loose_disk_obj(git_rawobj *out, gitfo_buf *obj)
 {
        unsigned char *in, *buf;
        obj_hdr hdr;
@@ -494,7 +494,7 @@ static int inflate_packlike_loose_disk_obj(git_obj *out, gitfo_buf *obj)
        return GIT_SUCCESS;
 }
 
-static int inflate_disk_obj(git_obj *out, gitfo_buf *obj)
+static int inflate_disk_obj(git_rawobj *out, gitfo_buf *obj)
 {
        unsigned char head[64], *buf;
        z_stream zs;
@@ -579,7 +579,7 @@ static int deflate_buf(z_stream *s, void *in, size_t len, int flush)
        return status;
 }
 
-static int deflate_obj(gitfo_buf *buf, char *hdr, int hdrlen, git_obj *obj, int level)
+static int deflate_obj(gitfo_buf *buf, char *hdr, int hdrlen, git_rawobj *obj, int level)
 {
        z_stream zs;
        int status;
@@ -1441,7 +1441,7 @@ void git_odb_close(git_odb *db)
 }
 
 int git_odb_read(
-       git_obj *out,
+       git_rawobj *out,
        git_odb *db,
        const git_oid *id)
 {
@@ -1457,7 +1457,7 @@ attempt:
        return GIT_ENOTFOUND;
 }
 
-int git_odb__read_loose(git_obj *out, git_odb *db, const git_oid *id)
+int git_odb__read_loose(git_rawobj *out, git_odb *db, const git_oid *id)
 {
        char file[GIT_PATH_MAX];
        gitfo_buf obj = GITFO_BUF_INIT;
@@ -1484,9 +1484,9 @@ int git_odb__read_loose(git_obj *out, git_odb *db, const git_oid *id)
        return GIT_SUCCESS;
 }
 
-static int unpack_object(git_obj *out, git_pack *p, index_entry *e);
+static int unpack_object(git_rawobj *out, git_pack *p, index_entry *e);
 
-static int unpack_object_delta(git_obj *out, git_pack *p, 
+static int unpack_object_delta(git_rawobj *out, git_pack *p, 
                index_entry *base_entry, 
                uint8_t *delta_buffer, 
                size_t delta_deflated_size,
@@ -1494,7 +1494,7 @@ static int unpack_object_delta(git_obj *out, git_pack *p,
 {
        int res = 0;
        uint8_t *delta = NULL;
-       git_obj base_obj;
+       git_rawobj base_obj;
 
        base_obj.data = NULL;
        base_obj.type = GIT_OBJ_BAD;
@@ -1519,7 +1519,7 @@ cleanup:
        return res;
 }
 
-static int unpack_object(git_obj *out, git_pack *p, index_entry *e)
+static int unpack_object(git_rawobj *out, git_pack *p, index_entry *e)
 {
        git_otype object_type;
        size_t inflated_size, deflated_size, shift;
@@ -1623,7 +1623,7 @@ static int unpack_object(git_obj *out, git_pack *p, index_entry *e)
        return GIT_SUCCESS;
 }
 
-static int read_packed(git_obj *out, git_pack *p, const git_oid *id)
+static int read_packed(git_rawobj *out, git_pack *p, const git_oid *id)
 {
        uint32_t n;
        index_entry e;
@@ -1646,7 +1646,7 @@ static int read_packed(git_obj *out, git_pack *p, const git_oid *id)
        return res;
 }
 
-int git_odb__read_packed(git_obj *out, git_odb *db, const git_oid *id)
+int git_odb__read_packed(git_rawobj *out, git_odb *db, const git_oid *id)
 {
        git_packlist *pl = packlist_get(db);
        size_t j;
@@ -1671,7 +1671,7 @@ int git_odb__read_packed(git_obj *out, git_odb *db, const git_oid *id)
        return GIT_ENOTFOUND;
 }
 
-int git_odb_write(git_oid *id, git_odb *db, git_obj *obj)
+int git_odb_write(git_oid *id, git_odb *db, git_rawobj *obj)
 {
        char hdr[64];
        int  hdrlen;
index 4436971552de482039cb2f11801875b1d89e9dd3..e921c3454860b0c39ad53c0eca2edf3b12cbe0ed 100644 (file)
@@ -31,7 +31,7 @@
 static const int default_table_size = 32;
 static const double max_load_factor = 0.65;
 
-uint32_t git_repository_object_hash(const void *key)
+uint32_t git_object_hash(const void *key)
 {
        uint32_t r;
        git_oid *id;
@@ -41,12 +41,12 @@ uint32_t git_repository_object_hash(const void *key)
        return r;
 }
 
-int git_repository_object_haskey(void *object, const void *key)
+int git_object_haskey(void *object, const void *key)
 {
-       git_repository_object *obj;
+       git_object *obj;
        git_oid *oid;
 
-       obj = (git_repository_object *)object;
+       obj = (git_object *)object;
        oid = (git_oid *)key;
 
        return (git_oid_cmp(oid, &obj->id) == 0);
@@ -62,8 +62,8 @@ git_repository *git_repository_alloc(git_odb *odb)
 
        repo->objects = git_hashtable_alloc(
                        default_table_size, 
-                       git_repository_object_hash,
-                       git_repository_object_haskey);
+                       git_object_hash,
+                       git_object_haskey);
 
        if (repo->objects == NULL) {
                free(repo);
@@ -78,128 +78,126 @@ git_repository *git_repository_alloc(git_odb *odb)
 void git_repository_free(git_repository *repo)
 {
        git_hashtable_iterator it;
-       git_repository_object *object;
+       git_object *object;
 
        git_hashtable_iterator_init(repo->objects, &it);
 
-       while ((object = (git_repository_object *)
+       while ((object = (git_object *)
                                git_hashtable_iterator_next(&it)) != NULL)
-               git_repository_object_free(object);
+               git_object_free(object);
 
        git_hashtable_free(repo->objects);
        /* TODO: free odb */
        free(repo);
 }
 
-void git_repository__dbo_prepare_write(git_repository_object *object)
+void git_object__source_prepare_write(git_object *object)
 {
        size_t base_size = 512;
 
-       if (object->writeback.write_ptr != NULL || object->dbo_open)
-               git_repository__dbo_close(object);
+       if (object->source.write_ptr != NULL || object->source.open)
+               git_object__source_close(object);
 
        /* TODO: proper size calculation */
-       object->dbo.data = git__malloc(base_size);
-       object->dbo.len = 0;
+       object->source.raw.data = git__malloc(base_size);
+       object->source.raw.len = base_size;
 
-       object->writeback.write_ptr = object->dbo.data;
-       object->writeback.ptr_size = base_size;
-       object->writeback.written_bytes = 0;
+       object->source.write_ptr = object->source.raw.data;
+       object->source.written_bytes = 0;
 
-       object->dbo_open = 1;
-       object->out_of_sync = 1;
+       object->source.open = 1;
+       object->source.out_of_sync = 1;
 }
 
-int git_repository__dbo_write(git_repository_object *object, const void *bytes, size_t len)
+int git_object__source_write(git_object *object, const void *bytes, size_t len)
 {
        assert(object);
 
-       if (!object->dbo_open || object->writeback.write_ptr == NULL)
+       if (!object->source.open || object->source.write_ptr == NULL)
                return GIT_ERROR;
 
        /* TODO: resize buffer on overflow */
-       if (object->writeback.written_bytes + len >= object->writeback.ptr_size)
+       if (object->source.written_bytes + len >= object->source.raw.len)
                return GIT_ENOMEM;
 
-       memcpy(object->writeback.write_ptr, bytes, len);
-       object->writeback.write_ptr += len;
-       object->writeback.written_bytes += len;
+       memcpy(object->source.write_ptr, bytes, len);
+       object->source.write_ptr += len;
+       object->source.written_bytes += len;
 
        return GIT_SUCCESS;
 }
 
-int git_repository__dbo_writeback(git_repository_object *object)
+int git_object__source_writeback(git_object *object)
 {
        int error;
        git_oid new_id;
 
        assert(object);
 
-       if (!object->dbo_open)
+       if (!object->source.open)
                return GIT_ERROR;
 
-       if (!object->out_of_sync)
+       if (!object->source.out_of_sync)
                return GIT_SUCCESS;
        
-       object->dbo.len = object->writeback.written_bytes;
+       object->source.raw.len = object->source.written_bytes;
 
-       git_obj_hash(&new_id, &object->dbo);
+       git_obj_hash(&new_id, &object->source.raw);
 
-       if ((error = git_odb_write(&new_id, object->repo->db, &object->dbo)) < 0)
+       if ((error = git_odb_write(&new_id, object->repo->db, &object->source.raw)) < 0)
                return error;
 
        git_hashtable_remove(object->repo->objects, &object->id);
        git_oid_cpy(&object->id, &new_id);
        git_hashtable_insert(object->repo->objects, &object->id, object);
 
-       object->writeback.write_ptr = NULL;
-       object->writeback.ptr_size = 0;
-       object->writeback.written_bytes = 0;
+       object->source.write_ptr = NULL;
+       object->source.written_bytes = 0;
 
-       git_repository__dbo_close(object);
+       git_object__source_close(object);
        return GIT_SUCCESS;
 }
 
-int git_repository__dbo_open(git_repository_object *object)
+int git_object__source_open(git_object *object)
 {
        int error;
 
        assert(object);
 
-       if (object->dbo_open && object->out_of_sync)
-               git_repository__dbo_close(object);
+       if (object->source.open && object->source.out_of_sync)
+               git_object__source_close(object);
 
-       if (object->dbo_open)
+       if (object->source.open)
                return GIT_SUCCESS;
 
-       error = git_odb_read(&object->dbo, object->repo->db, &object->id);
+       error = git_odb_read(&object->source.raw, object->repo->db, &object->id);
        if (error < 0)
                return error;
 
-       object->dbo_open = 1;
-       object->out_of_sync = 0;
+       object->source.open = 1;
+       object->source.out_of_sync = 0;
        return GIT_SUCCESS;
 }
 
-void git_repository__dbo_close(git_repository_object *object)
+void git_object__source_close(git_object *object)
 {
        assert(object);
 
-       if (!object->dbo_open) {
-               git_obj_close(&object->dbo);
-               object->dbo_open = 0;
-               object->out_of_sync = 0;
+       if (!object->source.open) {
+               git_obj_close(&object->source.raw);
+               object->source.open = 0;
+               object->source.out_of_sync = 0;
        }
 }
 
-void git_repository_object_free(git_repository_object *object)
+void git_object_free(git_object *object)
 {
        assert(object);
 
        git_hashtable_remove(object->repo->objects, &object->id);
-       git_obj_close(&object->dbo);
+       git_obj_close(&object->source.raw);
 
-       switch (object->dbo.type) {
+       switch (object->source.raw.type) {
        case GIT_OBJ_COMMIT:
                git_commit__free((git_commit *)object);
                break;
@@ -224,30 +222,30 @@ git_odb *git_repository_database(git_repository *repo)
        return repo->db;
 }
 
-const git_oid *git_repository_object_id(git_repository_object *obj)
+const git_oid *git_object_id(git_object *obj)
 {
        assert(obj);
        return &obj->id;
 }
 
-git_otype git_repository_object_type(git_repository_object *obj)
+git_otype git_object_type(git_object *obj)
 {
        assert(obj);
-       return obj->dbo.type;
+       return obj->source.raw.type;
 }
 
-git_repository_object *git_repository_lookup(git_repository *repo, const git_oid *id, git_otype type)
+git_object *git_repository_lookup(git_repository *repo, const git_oid *id, git_otype type)
 {
        static const size_t object_sizes[] = {
                0,
                sizeof(git_commit),
                sizeof(git_tree),
-               sizeof(git_repository_object), /* TODO: sizeof(git_blob) */ 
+               sizeof(git_object), /* TODO: sizeof(git_blob) */ 
                sizeof(git_tag)
        };
 
-       git_repository_object *object = NULL;
-       git_obj obj_file;
+       git_object *object = NULL;
+       git_rawobj obj_file;
 
        assert(repo);
 
@@ -273,8 +271,8 @@ git_repository_object *git_repository_lookup(git_repository *repo, const git_oid
        /* Initialize parent object */
        git_oid_cpy(&object->id, id);
        object->repo = repo;
-       object->dbo_open = 1;
-       memcpy(&object->dbo, &obj_file, sizeof(git_obj));
+       object->source.open = 1;
+       memcpy(&object->source.raw, &obj_file, sizeof(git_rawobj));
 
        switch (type) {
 
@@ -307,8 +305,8 @@ git_repository_object *git_repository_lookup(git_repository *repo, const git_oid
                break;
        }
 
-       git_obj_close(&object->dbo);
-       object->dbo_open = 0;
+       git_obj_close(&object->source.raw);
+       object->source.open = 0;
 
        git_hashtable_insert(repo->objects, &object->id, object);
        return object;
index 1b5e6a041827e5df26cfb5e1d3b38f627a3e21bb..476ca546b3aba3714428305f6773bf8c78915b0e 100644 (file)
@@ -8,18 +8,17 @@
 
 #include "hashtable.h"
 
-struct git_repository_object {
+typedef struct {
+       git_rawobj raw;
+       void *write_ptr;
+       size_t written_bytes;
+       int open:1, out_of_sync:1;
+} git_odb_source;
+
+struct git_object {
        git_oid id;
        git_repository *repo;
-       git_obj dbo;
-
-       struct {
-               void *write_ptr;
-               size_t ptr_size;
-               size_t written_bytes;
-       } writeback;
-
-       int dbo_open:1, out_of_sync:1;
+       git_odb_source source;
 };
 
 struct git_repository {
@@ -28,10 +27,10 @@ struct git_repository {
 };
 
 
-int git_repository__dbo_open(git_repository_object *object);
-void git_repository__dbo_close(git_repository_object *object);
-void git_repository__dbo_prepare_write(git_repository_object *object);
-int git_repository__dbo_write(git_repository_object *object, const void *bytes, size_t len);
-int git_repository__dbo_writeback(git_repository_object *object);
+int git_object__source_open(git_object *object);
+void git_object__source_close(git_object *object);
+void git_object__source_prepare_write(git_object *object);
+int git_object__source_write(git_object *object, const void *bytes, size_t len);
+int git_object__source_writeback(git_object *object);
 
 #endif
index ec0531b6e37609175b041f0e5b222575442ec96e..13679ecc90f088f6068534765264ba50d7d88312 100644 (file)
--- a/src/tag.c
+++ b/src/tag.c
@@ -43,7 +43,7 @@ const git_oid *git_tag_id(git_tag *t)
        return &t->object.id;
 }
 
-const git_repository_object *git_tag_target(git_tag *t)
+const git_object *git_tag_target(git_tag *t)
 {
        return t->target;
 }
@@ -161,13 +161,13 @@ int git_tag__parse(git_tag *tag)
 {
        int error = 0;
 
-       error = git_repository__dbo_open((git_repository_object *)tag);
+       error = git_object__source_open((git_object *)tag);
        if (error < 0)
                return error;
 
-       error = parse_tag_buffer(tag, tag->object.dbo.data, tag->object.dbo.data + tag->object.dbo.len);
+       error = parse_tag_buffer(tag, tag->object.source.raw.data, tag->object.source.raw.data + tag->object.source.raw.len);
 
-       git_repository__dbo_close((git_repository_object *)tag);
+       git_object__source_close((git_object *)tag);
        return error;
 }
 
index df03e2ad1976036a6b56aef11d746bc5bb6b31fa..6d9cd823228fd51ebfd4088ba8e70c1e74fe563b 100644 (file)
--- a/src/tag.h
+++ b/src/tag.h
@@ -5,9 +5,9 @@
 #include "repository.h"
 
 struct git_tag {
-       git_repository_object object;
+       git_object object;
 
-       git_repository_object *target;
+       git_object *target;
        git_otype type;
        char *tag_name;
        git_person *tagger;
index 7599c3fc23c638f1b4a708863ccc56b6dcc938b1..f1c191c32857201241aa8b53dce032f92d185a11 100644 (file)
@@ -65,7 +65,7 @@ const git_oid *git_tree_entry_id(const git_tree_entry *entry)
        return &entry->oid;
 }
 
-git_repository_object *git_tree_entry_2object(const git_tree_entry *entry)
+git_object *git_tree_entry_2object(const git_tree_entry *entry)
 {
        return git_repository_lookup(entry->owner->object.repo, &entry->oid, GIT_OBJ_ANY);
 }
@@ -107,15 +107,15 @@ int git_tree__parse(git_tree *tree)
        if (tree->entries != NULL)
                return GIT_SUCCESS;
 
-       error = git_repository__dbo_open((git_repository_object *)tree);
+       error = git_object__source_open((git_object *)tree);
        if (error < 0)
                return error;
 
-       buffer = tree->object.dbo.data;
-       buffer_end = buffer + tree->object.dbo.len;
+       buffer = tree->object.source.raw.data;
+       buffer_end = buffer + tree->object.source.raw.len;
 
        tree->entry_count = 0;
-       entries_size = (tree->object.dbo.len / avg_entry_size) + 1;
+       entries_size = (tree->object.source.raw.len / avg_entry_size) + 1;
        tree->entries = git__malloc(entries_size * sizeof(git_tree_entry));
 
        while (buffer < buffer_end) {
@@ -155,6 +155,6 @@ int git_tree__parse(git_tree *tree)
                buffer += GIT_OID_RAWSZ;
        }
 
-       git_repository__dbo_close((git_repository_object *)tree);
+       git_object__source_close((git_object *)tree);
        return error;
 }
index 4c0be2ae0526b261f50e61497651e4c52b8cf5d8..dd15b9b9bd56073baec992f60fedc8ff9a034370 100644 (file)
@@ -13,7 +13,7 @@ struct git_tree_entry {
 };
 
 struct git_tree {
-       git_repository_object object;
+       git_object object;
 
        git_tree_entry *entries;
        size_t entry_count;
index 83131fe4c37bbc26706764ee63732315906beb89..8d0ba903e71be8cfd2099cfcec9ac8d88dadc451 100644 (file)
@@ -52,7 +52,7 @@ static unsigned char commit_data[] = {
     0x3e, 0x0a,
 };
 
-static git_obj commit_obj = {
+static git_rawobj commit_obj = {
        commit_data,
        sizeof(commit_data),
        GIT_OBJ_COMMIT
@@ -79,7 +79,7 @@ static unsigned char tree_data[] = {
     0xd8, 0xc2, 0xe4, 0x8c, 0x53, 0x91,
 };
 
-static git_obj tree_obj = {
+static git_rawobj tree_obj = {
        tree_data,
        sizeof(tree_data),
        GIT_OBJ_TREE
@@ -112,7 +112,7 @@ static unsigned char tag_data[] = {
     0x2e, 0x30, 0x2e, 0x31, 0x0a,
 };
 
-static git_obj tag_obj = {
+static git_rawobj tag_obj = {
        tag_data,
        sizeof(tag_data),
        GIT_OBJ_TAG
@@ -124,7 +124,7 @@ static unsigned char zero_data[] = {
     0x00  /* dummy data */
 };
 
-static git_obj zero_obj = {
+static git_rawobj zero_obj = {
        zero_data,
        0,
        GIT_OBJ_BLOB
@@ -136,7 +136,7 @@ static unsigned char one_data[] = {
     0x0a,
 };
 
-static git_obj one_obj = {
+static git_rawobj one_obj = {
        one_data,
        sizeof(one_data),
        GIT_OBJ_BLOB
@@ -148,7 +148,7 @@ static unsigned char two_data[] = {
     0x61, 0x0a,
 };
 
-static git_obj two_obj = {
+static git_rawobj two_obj = {
        two_data,
        sizeof(two_data),
        GIT_OBJ_BLOB
@@ -306,13 +306,13 @@ static unsigned char some_data[] = {
     0x0a,
 };
 
-static git_obj some_obj = {
+static git_rawobj some_obj = {
        some_data,
        sizeof(some_data),
        GIT_OBJ_BLOB
 };
 
-static git_obj junk_obj = {
+static git_rawobj junk_obj = {
        NULL,
        0,
        GIT_OBJ_BAD
index 6e9fb9dad8184cde865b1b062163dc209042f88d..3cb99e4daa5ebda98e56001a840a01b3e0a1987f 100644 (file)
@@ -526,7 +526,7 @@ static object_data some = {
 BEGIN_TEST(read_loose_commit)
     git_odb *db;
     git_oid id;
-    git_obj obj;
+    git_rawobj obj;
 
     must_pass(write_object_files(odb_dir, &commit));
     must_pass(git_odb_open(&db, odb_dir));
@@ -543,7 +543,7 @@ END_TEST
 BEGIN_TEST(read_loose_tree)
     git_odb *db;
     git_oid id;
-    git_obj obj;
+    git_rawobj obj;
 
     must_pass(write_object_files(odb_dir, &tree));
     must_pass(git_odb_open(&db, odb_dir));
@@ -560,7 +560,7 @@ END_TEST
 BEGIN_TEST(read_loose_tag)
     git_odb *db;
     git_oid id;
-    git_obj obj;
+    git_rawobj obj;
 
     must_pass(write_object_files(odb_dir, &tag));
     must_pass(git_odb_open(&db, odb_dir));
@@ -577,7 +577,7 @@ END_TEST
 BEGIN_TEST(read_loose_zero)
     git_odb *db;
     git_oid id;
-    git_obj obj;
+    git_rawobj obj;
 
     must_pass(write_object_files(odb_dir, &zero));
     must_pass(git_odb_open(&db, odb_dir));
@@ -594,7 +594,7 @@ END_TEST
 BEGIN_TEST(read_loose_one)
     git_odb *db;
     git_oid id;
-    git_obj obj;
+    git_rawobj obj;
 
     must_pass(write_object_files(odb_dir, &one));
     must_pass(git_odb_open(&db, odb_dir));
@@ -611,7 +611,7 @@ END_TEST
 BEGIN_TEST(read_loose_two)
     git_odb *db;
     git_oid id;
-    git_obj obj;
+    git_rawobj obj;
 
     must_pass(write_object_files(odb_dir, &two));
     must_pass(git_odb_open(&db, odb_dir));
@@ -628,7 +628,7 @@ END_TEST
 BEGIN_TEST(read_loose_some)
     git_odb *db;
     git_oid id;
-    git_obj obj;
+    git_rawobj obj;
 
     must_pass(write_object_files(odb_dir, &some));
     must_pass(git_odb_open(&db, odb_dir));
index 77bad856f6306f1c1243ce0f4e363477205d3cbb..5952c2ee38808817ded7e43d20a1204aaff0c5db 100644 (file)
@@ -527,7 +527,7 @@ static object_data some = {
 BEGIN_TEST(read_loose_commit)
     git_odb *db;
     git_oid id;
-    git_obj obj;
+    git_rawobj obj;
 
     must_pass(write_object_files(odb_dir, &commit));
     must_pass(git_odb_open(&db, odb_dir));
@@ -544,7 +544,7 @@ END_TEST
 BEGIN_TEST(read_loose_tree)
     git_odb *db;
     git_oid id;
-    git_obj obj;
+    git_rawobj obj;
 
     must_pass(write_object_files(odb_dir, &tree));
     must_pass(git_odb_open(&db, odb_dir));
@@ -561,7 +561,7 @@ END_TEST
 BEGIN_TEST(read_loose_tag)
     git_odb *db;
     git_oid id;
-    git_obj obj;
+    git_rawobj obj;
 
     must_pass(write_object_files(odb_dir, &tag));
     must_pass(git_odb_open(&db, odb_dir));
@@ -578,7 +578,7 @@ END_TEST
 BEGIN_TEST(read_loose_zero)
     git_odb *db;
     git_oid id;
-    git_obj obj;
+    git_rawobj obj;
 
     must_pass(write_object_files(odb_dir, &zero));
     must_pass(git_odb_open(&db, odb_dir));
@@ -595,7 +595,7 @@ END_TEST
 BEGIN_TEST(read_loose_one)
     git_odb *db;
     git_oid id;
-    git_obj obj;
+    git_rawobj obj;
 
     must_pass(write_object_files(odb_dir, &one));
     must_pass(git_odb_open(&db, odb_dir));
@@ -612,7 +612,7 @@ END_TEST
 BEGIN_TEST(read_loose_two)
     git_odb *db;
     git_oid id;
-    git_obj obj;
+    git_rawobj obj;
 
     must_pass(write_object_files(odb_dir, &two));
     must_pass(git_odb_open(&db, odb_dir));
@@ -629,7 +629,7 @@ END_TEST
 BEGIN_TEST(read_loose_some)
     git_odb *db;
     git_oid id;
-    git_obj obj;
+    git_rawobj obj;
 
     must_pass(write_object_files(odb_dir, &some));
     must_pass(git_odb_open(&db, odb_dir));
index 49ae9af1bb52f9c8224df0485a368a2f8561cce0..8310ea3d91da79d8cfe00fd083a9f3867576d228 100644 (file)
@@ -141,7 +141,7 @@ BEGIN_TEST(readpacked_test)
 
        for (i = 0; i < ARRAY_SIZE(packed_objects); ++i) {
                git_oid id;
-               git_obj obj;
+               git_rawobj obj;
 
                must_pass(git_oid_mkstr(&id, packed_objects[i]));
                must_be_true(git_odb_exists(db, &id) == 1);
index b4440c0becb8f009bab65b3b3c901a409c49add2..6c995bb5a2cb05e52a2986df21e5185c7eb2ec07 100644 (file)
@@ -65,7 +65,7 @@ static unsigned char commit_data[] = {
     0x3e, 0x0a,
 };
 
-static git_obj commit_obj = {
+static git_rawobj commit_obj = {
        commit_data,
        sizeof(commit_data),
        GIT_OBJ_COMMIT
@@ -96,7 +96,7 @@ static unsigned char tree_data[] = {
     0xd8, 0xc2, 0xe4, 0x8c, 0x53, 0x91,
 };
 
-static git_obj tree_obj = {
+static git_rawobj tree_obj = {
        tree_data,
        sizeof(tree_data),
        GIT_OBJ_TREE
@@ -133,7 +133,7 @@ static unsigned char tag_data[] = {
     0x2e, 0x30, 0x2e, 0x31, 0x0a,
 };
 
-static git_obj tag_obj = {
+static git_rawobj tag_obj = {
        tag_data,
        sizeof(tag_data),
        GIT_OBJ_TAG
@@ -149,7 +149,7 @@ static unsigned char zero_data[] = {
     0x00  /* dummy data */
 };
 
-static git_obj zero_obj = {
+static git_rawobj zero_obj = {
        zero_data,
        0,
        GIT_OBJ_BLOB
@@ -165,7 +165,7 @@ static unsigned char one_data[] = {
     0x0a,
 };
 
-static git_obj one_obj = {
+static git_rawobj one_obj = {
        one_data,
        sizeof(one_data),
        GIT_OBJ_BLOB
@@ -181,7 +181,7 @@ static unsigned char two_data[] = {
     0x61, 0x0a,
 };
 
-static git_obj two_obj = {
+static git_rawobj two_obj = {
        two_data,
        sizeof(two_data),
        GIT_OBJ_BLOB
@@ -343,7 +343,7 @@ static unsigned char some_data[] = {
     0x0a,
 };
 
-static git_obj some_obj = {
+static git_rawobj some_obj = {
        some_data,
        sizeof(some_data),
        GIT_OBJ_BLOB
@@ -390,7 +390,7 @@ static int check_object_files(object_data *d)
        return 0;
 }
 
-static int cmp_objects(git_obj *o1, git_obj *o2)
+static int cmp_objects(git_rawobj *o1, git_rawobj *o2)
 {
        if (o1->type != o2->type)
                return -1;
@@ -404,7 +404,7 @@ static int cmp_objects(git_obj *o1, git_obj *o2)
 BEGIN_TEST(write_commit)
     git_odb *db;
     git_oid id1, id2;
-    git_obj obj;
+    git_rawobj obj;
 
     must_pass(make_odb_dir());
     must_pass(git_odb_open(&db, odb_dir));
@@ -425,7 +425,7 @@ END_TEST
 BEGIN_TEST(write_tree)
     git_odb *db;
     git_oid id1, id2;
-    git_obj obj;
+    git_rawobj obj;
 
     must_pass(make_odb_dir());
     must_pass(git_odb_open(&db, odb_dir));
@@ -446,7 +446,7 @@ END_TEST
 BEGIN_TEST(write_tag)
     git_odb *db;
     git_oid id1, id2;
-    git_obj obj;
+    git_rawobj obj;
 
     must_pass(make_odb_dir());
     must_pass(git_odb_open(&db, odb_dir));
@@ -467,7 +467,7 @@ END_TEST
 BEGIN_TEST(write_zero)
     git_odb *db;
     git_oid id1, id2;
-    git_obj obj;
+    git_rawobj obj;
 
     must_pass(make_odb_dir());
     must_pass(git_odb_open(&db, odb_dir));
@@ -488,7 +488,7 @@ END_TEST
 BEGIN_TEST(write_one)
     git_odb *db;
     git_oid id1, id2;
-    git_obj obj;
+    git_rawobj obj;
 
     must_pass(make_odb_dir());
     must_pass(git_odb_open(&db, odb_dir));
@@ -509,7 +509,7 @@ END_TEST
 BEGIN_TEST(write_two)
     git_odb *db;
     git_oid id1, id2;
-    git_obj obj;
+    git_rawobj obj;
 
     must_pass(make_odb_dir());
     must_pass(git_odb_open(&db, odb_dir));
@@ -530,7 +530,7 @@ END_TEST
 BEGIN_TEST(write_some)
     git_odb *db;
     git_oid id1, id2;
-    git_obj obj;
+    git_rawobj obj;
 
     must_pass(make_odb_dir());
     must_pass(git_odb_open(&db, odb_dir));
index 46a29b40df56c1885fcc16a59a95bf319048fcdf..e7c26926ed3c6aa3cc11bc1d1536d700cca3daeb 100644 (file)
@@ -82,7 +82,7 @@ int remove_object_files(const char *odb_dir, object_data *d)
        return 0;
 }
 
-int cmp_objects(git_obj *o, object_data *d)
+int cmp_objects(git_rawobj *o, object_data *d)
 {
        if (o->type != git_obj_string_to_type(d->type))
                return -1;
index 2c09181f38234634e478130191323c7f74958c33..342a8528774f2bdcad46a3dce57a779e314cd15d 100644 (file)
@@ -47,7 +47,7 @@ extern int write_object_files(const char *odb_dir, object_data *d);
 
 extern int remove_object_files(const char *odb_dir, object_data *d);
 
-extern int cmp_objects(git_obj *o, object_data *d);
+extern int cmp_objects(git_rawobj *o, object_data *d);
 
 #endif
 /* INCLUDE_test_helpers_h__ */