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