Commit f49a2e49 by Vicent Marti

Give object structures more descriptive names

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>
parent a7a7ddbe
......@@ -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;
}
......
......@@ -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;
......
......@@ -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,
......
......@@ -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,
......
......@@ -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 {
......
......@@ -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.
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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;
......
......@@ -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;
......
......@@ -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
......@@ -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;
}
......
......@@ -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;
......
......@@ -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;
}
......@@ -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;
......
......@@ -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
......
......@@ -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));
......
......@@ -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));
......
......@@ -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);
......
......@@ -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));
......
......@@ -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;
......
......@@ -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__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment