summaryrefslogtreecommitdiff
path: root/src/pack.h
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2013-04-16 17:46:41 +0200
committerVicent Marti <tanoku@gmail.com>2013-04-16 17:46:41 +0200
commita50086d174658914d4d6462afbc83b02825b1f5b (patch)
treee8daa1c7bf678222cf351445179837bed7db3a72 /src/pack.h
parent5b9fac39d8a76b9139667c26a63e6b3f204b3977 (diff)
parentf124ebd457bfbf43de3516629aaba5a279636e04 (diff)
downloadlibgit2-0.18.0.tar.gz
Merge branch 'development'v0.18.0
Diffstat (limited to 'src/pack.h')
-rw-r--r--src/pack.h58
1 files changed, 54 insertions, 4 deletions
diff --git a/src/pack.h b/src/pack.h
index cd7a4d2e1..8d7e33dfe 100644
--- a/src/pack.h
+++ b/src/pack.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2012 the libgit2 contributors
+ * Copyright (C) the libgit2 contributors. All rights reserved.
*
* This file is part of libgit2, distributed under the GNU GPL v2 with
* a Linking Exception. For full terms see the included COPYING file.
@@ -8,12 +8,15 @@
#ifndef INCLUDE_pack_h__
#define INCLUDE_pack_h__
+#include <zlib.h>
+
#include "git2/oid.h"
#include "common.h"
#include "map.h"
#include "mwindow.h"
#include "odb.h"
+#include "oidmap.h"
#define GIT_PACK_FILE_MODE 0444
@@ -51,6 +54,28 @@ struct git_pack_idx_header {
uint32_t idx_version;
};
+typedef struct git_pack_cache_entry {
+ size_t last_usage; /* enough? */
+ git_atomic refcount;
+ git_rawobj raw;
+} git_pack_cache_entry;
+
+#include "offmap.h"
+
+GIT__USE_OFFMAP;
+GIT__USE_OIDMAP;
+
+#define GIT_PACK_CACHE_MEMORY_LIMIT 16 * 1024 * 1024
+#define GIT_PACK_CACHE_SIZE_LIMIT 1024 * 1024 /* don't bother caching anything over 1MB */
+
+typedef struct {
+ size_t memory_used;
+ size_t memory_limit;
+ size_t use_ctr;
+ git_mutex lock;
+ git_offmap *entries;
+} git_pack_cache;
+
struct git_pack_file {
git_mwindow_file mwf;
git_map index_map;
@@ -63,7 +88,10 @@ struct git_pack_file {
git_time_t mtime;
unsigned pack_local:1, pack_keep:1, has_cache:1;
git_oid sha1;
- git_vector cache;
+ git_oidmap *idx_cache;
+ git_oid **oids;
+
+ git_pack_cache bases; /* delta base cache */
/* something like ".git/objects/pack/xxxxx.pack" */
char pack_name[GIT_FLEX_ARRAY]; /* more */
@@ -75,6 +103,14 @@ struct git_pack_entry {
struct git_pack_file *p;
};
+typedef struct git_packfile_stream {
+ git_off_t curpos;
+ int done;
+ z_stream zstream;
+ struct git_pack_file *p;
+ git_mwindow *mw;
+} git_packfile_stream;
+
int git_packfile_unpack_header(
size_t *size_p,
git_otype *type_p,
@@ -82,6 +118,12 @@ int git_packfile_unpack_header(
git_mwindow **w_curs,
git_off_t *curpos);
+int git_packfile_resolve_header(
+ size_t *size_p,
+ git_otype *type_p,
+ struct git_pack_file *p,
+ git_off_t offset);
+
int git_packfile_unpack(git_rawobj *obj, struct git_pack_file *p, git_off_t *obj_offset);
int packfile_unpack_compressed(
git_rawobj *obj,
@@ -91,16 +133,24 @@ int packfile_unpack_compressed(
size_t size,
git_otype type);
+int git_packfile_stream_open(git_packfile_stream *obj, struct git_pack_file *p, git_off_t curpos);
+ssize_t git_packfile_stream_read(git_packfile_stream *obj, void *buffer, size_t len);
+void git_packfile_stream_free(git_packfile_stream *obj);
+
git_off_t get_delta_base(struct git_pack_file *p, git_mwindow **w_curs,
git_off_t *curpos, git_otype type,
git_off_t delta_obj_offset);
-void packfile_free(struct git_pack_file *p);
+void git_packfile_free(struct git_pack_file *p);
int git_packfile_check(struct git_pack_file **pack_out, const char *path);
int git_pack_entry_find(
struct git_pack_entry *e,
struct git_pack_file *p,
const git_oid *short_oid,
- unsigned int len);
+ size_t len);
+int git_pack_foreach_entry(
+ struct git_pack_file *p,
+ git_odb_foreach_cb cb,
+ void *data);
#endif