]> git.proxmox.com Git - libgit2.git/blob - src/pack-objects.h
Merge pull request #803 from schu/gsoc-pack-objects
[libgit2.git] / src / pack-objects.h
1 /*
2 * Copyright (C) 2009-2012 the libgit2 contributors
3 *
4 * This file is part of libgit2, distributed under the GNU GPL v2 with
5 * a Linking Exception. For full terms see the included COPYING file.
6 */
7
8 #ifndef INCLUDE_pack_objects_h__
9 #define INCLUDE_pack_objects_h__
10
11 #include "common.h"
12
13 #include "buffer.h"
14 #include "hash.h"
15 #include "oidmap.h"
16
17 #include "git2/oid.h"
18
19 #define GIT_PACK_WINDOW 10 /* number of objects to possibly delta against */
20 #define GIT_PACK_DEPTH 50 /* max delta depth */
21 #define GIT_PACK_DELTA_CACHE_SIZE (256 * 1024 * 1024)
22 #define GIT_PACK_DELTA_CACHE_LIMIT 1000
23 #define GIT_PACK_BIG_FILE_THRESHOLD (512 * 1024 * 1024)
24
25 typedef struct git_pobject {
26 git_oid id;
27 git_otype type;
28 git_off_t offset;
29
30 size_t size;
31
32 unsigned int hash; /* name hint hash */
33
34 struct git_pobject *delta; /* delta base object */
35 struct git_pobject *delta_child; /* deltified objects who bases me */
36 struct git_pobject *delta_sibling; /* other deltified objects
37 * who uses the same base as
38 * me */
39
40 void *delta_data;
41 unsigned long delta_size;
42 unsigned long z_delta_size;
43
44 int written:1,
45 recursing:1,
46 no_try_delta:1,
47 tagged:1,
48 filled:1;
49 } git_pobject;
50
51 struct git_packbuilder {
52 git_repository *repo; /* associated repository */
53 git_odb *odb; /* associated object database */
54
55 git_hash_ctx *ctx;
56
57 uint32_t nr_objects,
58 nr_alloc,
59 nr_written,
60 nr_remaining;
61
62 git_pobject *object_list;
63
64 git_oidmap *object_ix;
65
66 git_oid pack_oid; /* hash of written pack */
67
68 /* configs */
69 unsigned long delta_cache_size;
70 unsigned long max_delta_cache_size;
71 unsigned long cache_max_small_delta_size;
72 unsigned long big_file_threshold;
73 unsigned long window_memory_limit;
74
75 int nr_threads; /* nr of threads to use */
76
77 bool done;
78 };
79
80
81 int git_packbuilder_send(git_packbuilder *pb, git_transport *t);
82 int git_packbuilder_write_buf(git_buf *buf, git_packbuilder *pb);
83
84 #endif