]> git.proxmox.com Git - libgit2.git/blob - src/pack-objects.h
Remove git_hash_ctx_new - callers now _ctx_init()
[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 #include "netops.h"
17
18 #include "git2/oid.h"
19
20 #define GIT_PACK_WINDOW 10 /* number of objects to possibly delta against */
21 #define GIT_PACK_DEPTH 50 /* max delta depth */
22 #define GIT_PACK_DELTA_CACHE_SIZE (256 * 1024 * 1024)
23 #define GIT_PACK_DELTA_CACHE_LIMIT 1000
24 #define GIT_PACK_BIG_FILE_THRESHOLD (512 * 1024 * 1024)
25
26 typedef struct git_pobject {
27 git_oid id;
28 git_otype type;
29 git_off_t offset;
30
31 size_t size;
32
33 unsigned int hash; /* name hint hash */
34
35 struct git_pobject *delta; /* delta base object */
36 struct git_pobject *delta_child; /* deltified objects who bases me */
37 struct git_pobject *delta_sibling; /* other deltified objects
38 * who uses the same base as
39 * me */
40
41 void *delta_data;
42 unsigned long delta_size;
43 unsigned long z_delta_size;
44
45 int written:1,
46 recursing: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 /* synchronization objects */
69 git_mutex cache_mutex;
70 git_mutex progress_mutex;
71 git_cond progress_cond;
72
73 /* configs */
74 unsigned long delta_cache_size;
75 unsigned long max_delta_cache_size;
76 unsigned long cache_max_small_delta_size;
77 unsigned long big_file_threshold;
78 unsigned long window_memory_limit;
79
80 int nr_threads; /* nr of threads to use */
81
82 bool done;
83 };
84
85 int git_packbuilder_send(git_packbuilder *pb, gitno_socket *s);
86 int git_packbuilder_write_buf(git_buf *buf, git_packbuilder *pb);
87
88 #endif /* INCLUDE_pack_objects_h__ */