]> git.proxmox.com Git - libgit2.git/blame - src/pack-objects.h
New upstream version 0.27.7+dfsg.1
[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"
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
30typedef struct git_pobject {
31 git_oid id;
32 git_otype type;
33 git_off_t offset;
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
MS
48
49 int written:1,
50 recursing:1,
0a32dca5
MS
51 tagged:1,
52 filled:1;
53} git_pobject;
54
04a36fef
CMN
55typedef struct {
56 git_oid id;
57 unsigned int uninteresting:1,
58 seen:1;
59} git_walk_object;
60
0a32dca5
MS
61struct git_packbuilder {
62 git_repository *repo; /* associated repository */
63 git_odb *odb; /* associated object database */
64
603bee07 65 git_hash_ctx ctx;
52a8a130 66 git_zstream zstream;
0a32dca5
MS
67
68 uint32_t nr_objects,
60e15ecd
ET
69 nr_deltified,
70 nr_written,
71 nr_remaining;
72
73 size_t nr_alloc;
0a32dca5
MS
74
75 git_pobject *object_list;
76
0cf49e10 77 git_oidmap *object_ix;
0a32dca5 78
04a36fef
CMN
79 git_oidmap *walk_objects;
80 git_pool object_pool;
81
0a32dca5
MS
82 git_oid pack_oid; /* hash of written pack */
83
b4491b99
PK
84 /* synchronization objects */
85 git_mutex cache_mutex;
86 git_mutex progress_mutex;
87 git_cond progress_cond;
88
0a32dca5 89 /* configs */
60e15ecd
ET
90 size_t delta_cache_size;
91 size_t max_delta_cache_size;
92 size_t cache_max_small_delta_size;
93 size_t big_file_threshold;
94 size_t window_memory_limit;
0a32dca5 95
60e15ecd 96 unsigned int nr_threads; /* nr of threads to use */
0a32dca5 97
b176eded
JM
98 git_packbuilder_progress progress_cb;
99 void *progress_cb_payload;
100 double last_progress_report_time; /* the time progress was last reported */
101
0a32dca5
MS
102 bool done;
103};
104
0a32dca5
MS
105int git_packbuilder_write_buf(git_buf *buf, git_packbuilder *pb);
106
eae0bfdc 107#endif