Hash :
f335b42c
Author :
Date :
2011-03-05T01:17:59
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
#ifndef INCLUDE_repository_h__
#define INCLUDE_repository_h__
#include "git2/common.h"
#include "git2/oid.h"
#include "git2/odb.h"
#include "git2/repository.h"
#include "git2/object.h"
#include "hashtable.h"
#include "index.h"
#include "refs.h"
#define DOT_GIT ".git"
#define GIT_DIR DOT_GIT "/"
#define GIT_OBJECTS_DIR "objects/"
#define GIT_INDEX_FILE "index"
typedef struct {
git_rawobj raw;
void *write_ptr;
size_t written_bytes;
int open:1;
} git_odb_source;
struct git_object {
git_oid id;
git_repository *repo;
git_odb_source source;
unsigned short refcount;
unsigned char in_memory, modified;
};
struct git_repository {
git_odb *db;
git_index *index;
git_hashtable *objects;
git_vector memory_objects;
git_refcache references;
char *path_repository;
char *path_index;
char *path_odb;
char *path_workdir;
unsigned is_bare:1, gc_enabled:1;
};
int git_object__source_open(git_object *object);
void git_object__source_close(git_object *object);
/* fully free the object; internal method, do not
* export */
void git_object__free(git_object *object);
int git__source_printf(git_odb_source *source, const char *format, ...);
int git__source_write(git_odb_source *source, const void *bytes, size_t len);
int git__parse_oid(git_oid *oid, char **buffer_out, const char *buffer_end, const char *header);
int git__write_oid(git_odb_source *src, const char *header, const git_oid *oid);
#define GIT_OBJECT_INCREF(repo, ob) git_object__incref((repo), (git_object *)(ob))
#define GIT_OBJECT_DECREF(repo, ob) git_object__decref((repo), (git_object *)(ob))
GIT_INLINE(void) git_object__incref(git_repository *repo, struct git_object *object)
{
if (repo && repo->gc_enabled && object)
object->refcount++;
}
GIT_INLINE(void) git_object__decref(git_repository *repo, struct git_object *object)
{
if (repo && repo->gc_enabled && object)
git_object_close(object);
}
#endif