]> git.proxmox.com Git - libgit2.git/blob - src/pack-objects.h
Merge branch 'pr/3957'
[libgit2.git] / src / pack-objects.h
1 /*
2 * Copyright (C) the libgit2 contributors. All rights reserved.
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 #include "zstream.h"
18 #include "pool.h"
19 #include "indexer.h"
20
21 #include "git2/oid.h"
22 #include "git2/pack.h"
23
24 #define GIT_PACK_WINDOW 10 /* number of objects to possibly delta against */
25 #define GIT_PACK_DEPTH 50 /* max delta depth */
26 #define GIT_PACK_DELTA_CACHE_SIZE (256 * 1024 * 1024)
27 #define GIT_PACK_DELTA_CACHE_LIMIT 1000
28 #define GIT_PACK_BIG_FILE_THRESHOLD (512 * 1024 * 1024)
29
30 typedef struct git_pobject {
31 git_oid id;
32 git_otype type;
33 git_off_t offset;
34
35 size_t size;
36
37 unsigned int hash; /* name hint hash */
38
39 struct git_pobject *delta; /* delta base object */
40 struct git_pobject *delta_child; /* deltified objects who bases me */
41 struct git_pobject *delta_sibling; /* other deltified objects
42 * who uses the same base as
43 * me */
44
45 void *delta_data;
46 size_t delta_size;
47 size_t z_delta_size;
48
49 int written:1,
50 recursing:1,
51 tagged:1,
52 filled:1;
53 } git_pobject;
54
55 typedef struct {
56 git_oid id;
57 unsigned int uninteresting:1,
58 seen:1;
59 } git_walk_object;
60
61 struct git_packbuilder {
62 git_repository *repo; /* associated repository */
63 git_odb *odb; /* associated object database */
64
65 git_hash_ctx ctx;
66 git_zstream zstream;
67
68 uint32_t nr_objects,
69 nr_deltified,
70 nr_written,
71 nr_remaining;
72
73 size_t nr_alloc;
74
75 git_pobject *object_list;
76
77 git_oidmap *object_ix;
78
79 git_oidmap *walk_objects;
80 git_pool object_pool;
81
82 git_oid pack_oid; /* hash of written pack */
83
84 /* synchronization objects */
85 git_mutex cache_mutex;
86 git_mutex progress_mutex;
87 git_cond progress_cond;
88
89 /* configs */
90 size_t delta_cache_size;
91 size_t max_delta_cache_size;
92 size_t cache_max_small_delta_size;
93 size_t big_file_threshold;
94 size_t window_memory_limit;
95
96 unsigned int nr_threads; /* nr of threads to use */
97
98 git_packbuilder_progress progress_cb;
99 void *progress_cb_payload;
100 double last_progress_report_time; /* the time progress was last reported */
101
102 bool done;
103 };
104
105 int git_packbuilder_write_buf(git_buf *buf, git_packbuilder *pb);
106
107 #endif /* INCLUDE_pack_objects_h__ */