]>
Commit | Line | Data |
---|---|---|
0a32dca5 | 1 | /* |
359fc2d2 | 2 | * Copyright (C) the libgit2 contributors. All rights reserved. |
0a32dca5 MS |
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" | |
0cf49e10 | 15 | #include "oidmap.h" |
41fb1ca0 | 16 | #include "netops.h" |
52a8a130 | 17 | #include "zstream.h" |
04a36fef | 18 | #include "pool.h" |
0a32dca5 MS |
19 | |
20 | #include "git2/oid.h" | |
b176eded | 21 | #include "git2/pack.h" |
0a32dca5 MS |
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; | |
60e15ecd ET |
45 | size_t delta_size; |
46 | size_t z_delta_size; | |
0a32dca5 MS |
47 | |
48 | int written:1, | |
49 | recursing:1, | |
0a32dca5 MS |
50 | tagged:1, |
51 | filled:1; | |
52 | } git_pobject; | |
53 | ||
04a36fef CMN |
54 | typedef struct { |
55 | git_oid id; | |
56 | unsigned int uninteresting:1, | |
57 | seen:1; | |
58 | } git_walk_object; | |
59 | ||
0a32dca5 MS |
60 | struct git_packbuilder { |
61 | git_repository *repo; /* associated repository */ | |
62 | git_odb *odb; /* associated object database */ | |
63 | ||
603bee07 | 64 | git_hash_ctx ctx; |
52a8a130 | 65 | git_zstream zstream; |
0a32dca5 MS |
66 | |
67 | uint32_t nr_objects, | |
60e15ecd ET |
68 | nr_deltified, |
69 | nr_written, | |
70 | nr_remaining; | |
71 | ||
72 | size_t nr_alloc; | |
0a32dca5 MS |
73 | |
74 | git_pobject *object_list; | |
75 | ||
0cf49e10 | 76 | git_oidmap *object_ix; |
0a32dca5 | 77 | |
04a36fef CMN |
78 | git_oidmap *walk_objects; |
79 | git_pool object_pool; | |
80 | ||
0a32dca5 MS |
81 | git_oid pack_oid; /* hash of written pack */ |
82 | ||
b4491b99 PK |
83 | /* synchronization objects */ |
84 | git_mutex cache_mutex; | |
85 | git_mutex progress_mutex; | |
86 | git_cond progress_cond; | |
87 | ||
0a32dca5 | 88 | /* configs */ |
60e15ecd ET |
89 | size_t delta_cache_size; |
90 | size_t max_delta_cache_size; | |
91 | size_t cache_max_small_delta_size; | |
92 | size_t big_file_threshold; | |
93 | size_t window_memory_limit; | |
0a32dca5 | 94 | |
60e15ecd | 95 | unsigned int nr_threads; /* nr of threads to use */ |
0a32dca5 | 96 | |
b176eded JM |
97 | git_packbuilder_progress progress_cb; |
98 | void *progress_cb_payload; | |
99 | double last_progress_report_time; /* the time progress was last reported */ | |
100 | ||
0a32dca5 MS |
101 | bool done; |
102 | }; | |
103 | ||
0a32dca5 MS |
104 | int git_packbuilder_write_buf(git_buf *buf, git_packbuilder *pb); |
105 | ||
b4491b99 | 106 | #endif /* INCLUDE_pack_objects_h__ */ |