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