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