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