Blame


1 e6bcace5 2021-06-22 stsp /*
2 e6bcace5 2021-06-22 stsp * Copyright (c) 2021 Stefan Sperling <stsp@openbsd.org>
3 e6bcace5 2021-06-22 stsp *
4 e6bcace5 2021-06-22 stsp * Permission to use, copy, modify, and distribute this software for any
5 e6bcace5 2021-06-22 stsp * purpose with or without fee is hereby granted, provided that the above
6 e6bcace5 2021-06-22 stsp * copyright notice and this permission notice appear in all copies.
7 e6bcace5 2021-06-22 stsp *
8 e6bcace5 2021-06-22 stsp * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 e6bcace5 2021-06-22 stsp * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 e6bcace5 2021-06-22 stsp * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 e6bcace5 2021-06-22 stsp * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 e6bcace5 2021-06-22 stsp * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 e6bcace5 2021-06-22 stsp * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 e6bcace5 2021-06-22 stsp * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 e6bcace5 2021-06-22 stsp */
16 e6bcace5 2021-06-22 stsp
17 e6bcace5 2021-06-22 stsp /*
18 e6bcace5 2021-06-22 stsp * Write pack file data into the provided open packfile handle, for all
19 e6bcace5 2021-06-22 stsp * objects reachable via the commits listed in 'ours'.
20 e6bcace5 2021-06-22 stsp * Exclude any objects for commits listed in 'theirs' if 'theirs' is not NULL.
21 e6bcace5 2021-06-22 stsp * Return the SHA1 digest of the resulting pack file in pack_sha1 which must
22 e6bcace5 2021-06-22 stsp * be pre-allocated by the caller with at least SHA1_DIGEST_LENGTH bytes.
23 e6bcace5 2021-06-22 stsp */
24 894e4711 2022-10-15 stsp const struct got_error *got_pack_create(uint8_t *pack_sha1, int packfd,
25 a32780aa 2022-10-15 stsp FILE *delta_cache, struct got_object_id **theirs, int ntheirs,
26 e6bcace5 2021-06-22 stsp struct got_object_id **ours, int nours,
27 f8a36e22 2021-08-26 stsp struct got_repository *repo, int loose_obj_only, int allow_empty,
28 c7a4fcc8 2023-02-17 op int force_refdelta, got_pack_progress_cb progress_cb, void *progress_arg,
29 cae60ab8 2022-10-18 stsp struct got_ratelimit *, got_cancel_cb cancel_cb, void *cancel_arg);
30 301e83b3 2022-10-16 stsp
31 301e83b3 2022-10-16 stsp const struct got_error *
32 301e83b3 2022-10-16 stsp got_pack_cache_pack_for_packidx(struct got_pack **pack,
33 301e83b3 2022-10-16 stsp struct got_packidx *packidx, struct got_repository *repo);
34 301e83b3 2022-10-16 stsp
35 301e83b3 2022-10-16 stsp const struct got_error *
36 301e83b3 2022-10-16 stsp got_pack_find_pack_for_commit_painting(struct got_packidx **best_packidx,
37 301e83b3 2022-10-16 stsp struct got_object_id_queue *ids, int nids, struct got_repository *repo);
38 301e83b3 2022-10-16 stsp const struct got_error *got_pack_find_pack_for_reuse(
39 301e83b3 2022-10-16 stsp struct got_packidx **best_packidx, struct got_repository *repo);
40 301e83b3 2022-10-16 stsp
41 301e83b3 2022-10-16 stsp struct got_ratelimit;
42 301e83b3 2022-10-16 stsp const struct got_error *got_pack_paint_commits(int *ncolored,
43 301e83b3 2022-10-16 stsp struct got_object_id_queue *ids, int nids,
44 301e83b3 2022-10-16 stsp struct got_object_idset *keep, struct got_object_idset *drop,
45 301e83b3 2022-10-16 stsp struct got_object_idset *skip, struct got_repository *repo,
46 301e83b3 2022-10-16 stsp got_pack_progress_cb progress_cb, void *progress_arg,
47 301e83b3 2022-10-16 stsp struct got_ratelimit *rl, got_cancel_cb cancel_cb, void *cancel_arg);
48 301e83b3 2022-10-16 stsp
49 301e83b3 2022-10-16 stsp enum got_pack_findtwixt_color {
50 301e83b3 2022-10-16 stsp COLOR_KEEP = 0,
51 301e83b3 2022-10-16 stsp COLOR_DROP,
52 301e83b3 2022-10-16 stsp COLOR_SKIP,
53 301e83b3 2022-10-16 stsp COLOR_MAX,
54 301e83b3 2022-10-16 stsp };
55 301e83b3 2022-10-16 stsp
56 301e83b3 2022-10-16 stsp const struct got_error *got_pack_paint_commit(struct got_object_qid *qid,
57 301e83b3 2022-10-16 stsp intptr_t color);
58 301e83b3 2022-10-16 stsp const struct got_error *got_pack_queue_commit_id(
59 301e83b3 2022-10-16 stsp struct got_object_id_queue *ids, struct got_object_id *id, intptr_t color,
60 301e83b3 2022-10-16 stsp struct got_repository *repo);
61 301e83b3 2022-10-16 stsp
62 301e83b3 2022-10-16 stsp struct got_pack_metavec {
63 301e83b3 2022-10-16 stsp struct got_pack_meta **meta;
64 301e83b3 2022-10-16 stsp int nmeta;
65 301e83b3 2022-10-16 stsp int metasz;
66 301e83b3 2022-10-16 stsp };
67 301e83b3 2022-10-16 stsp
68 301e83b3 2022-10-16 stsp struct got_pack_meta {
69 301e83b3 2022-10-16 stsp struct got_object_id id;
70 301e83b3 2022-10-16 stsp uint32_t path_hash;
71 301e83b3 2022-10-16 stsp int obj_type;
72 301e83b3 2022-10-16 stsp off_t size;
73 301e83b3 2022-10-16 stsp time_t mtime;
74 301e83b3 2022-10-16 stsp
75 301e83b3 2022-10-16 stsp /* The best delta we picked */
76 301e83b3 2022-10-16 stsp struct got_pack_meta *head;
77 301e83b3 2022-10-16 stsp struct got_pack_meta *prev;
78 301e83b3 2022-10-16 stsp unsigned char *delta_buf; /* if encoded in memory (compressed) */
79 301e83b3 2022-10-16 stsp off_t delta_offset; /* offset in delta cache file (compressed) */
80 301e83b3 2022-10-16 stsp off_t delta_len; /* encoded delta length */
81 301e83b3 2022-10-16 stsp off_t delta_compressed_len; /* encoded+compressed delta length */
82 301e83b3 2022-10-16 stsp int nchain;
83 301e83b3 2022-10-16 stsp
84 301e83b3 2022-10-16 stsp off_t reused_delta_offset; /* offset of delta in reused pack file */
85 301e83b3 2022-10-16 stsp struct got_object_id *base_obj_id;
86 301e83b3 2022-10-16 stsp
87 301e83b3 2022-10-16 stsp /* Only used for delta window */
88 301e83b3 2022-10-16 stsp struct got_delta_table *dtab;
89 301e83b3 2022-10-16 stsp
90 301e83b3 2022-10-16 stsp /* Only used for writing offset deltas */
91 301e83b3 2022-10-16 stsp off_t off;
92 301e83b3 2022-10-16 stsp };
93 301e83b3 2022-10-16 stsp
94 301e83b3 2022-10-16 stsp const struct got_error *got_pack_add_meta(struct got_pack_meta *m,
95 301e83b3 2022-10-16 stsp struct got_pack_metavec *v);
96 301e83b3 2022-10-16 stsp
97 301e83b3 2022-10-16 stsp const struct got_error *
98 24b7de1c 2022-12-03 stsp got_pack_search_deltas(struct got_packidx **packidx, struct got_pack **pack,
99 24b7de1c 2022-12-03 stsp struct got_pack_metavec *v, struct got_object_idset *idset,
100 301e83b3 2022-10-16 stsp int ncolored, int nfound, int ntrees, int ncommits,
101 301e83b3 2022-10-16 stsp struct got_repository *repo,
102 301e83b3 2022-10-16 stsp got_pack_progress_cb progress_cb, void *progress_arg,
103 301e83b3 2022-10-16 stsp struct got_ratelimit *rl, got_cancel_cb cancel_cb, void *cancel_arg);
104 301e83b3 2022-10-16 stsp
105 301e83b3 2022-10-16 stsp const struct got_error *
106 301e83b3 2022-10-16 stsp got_pack_report_progress(got_pack_progress_cb progress_cb, void *progress_arg,
107 301e83b3 2022-10-16 stsp struct got_ratelimit *rl, int ncolored, int nfound, int ntrees,
108 301e83b3 2022-10-16 stsp off_t packfile_size, int ncommits, int nobj_total, int obj_deltify,
109 301e83b3 2022-10-16 stsp int nobj_written);
110 301e83b3 2022-10-16 stsp
111 301e83b3 2022-10-16 stsp const struct got_error *
112 301e83b3 2022-10-16 stsp got_pack_load_packed_object_ids(int *found_all_objects,
113 301e83b3 2022-10-16 stsp struct got_object_id **ours, int nours,
114 301e83b3 2022-10-16 stsp struct got_object_id **theirs, int ntheirs,
115 301e83b3 2022-10-16 stsp int want_meta, uint32_t seed, struct got_object_idset *idset,
116 301e83b3 2022-10-16 stsp struct got_object_idset *idset_exclude, int loose_obj_only,
117 301e83b3 2022-10-16 stsp struct got_repository *repo, struct got_packidx *packidx,
118 301e83b3 2022-10-16 stsp int *ncolored, int *nfound, int *ntrees,
119 301e83b3 2022-10-16 stsp got_pack_progress_cb progress_cb, void *progress_arg,
120 301e83b3 2022-10-16 stsp struct got_ratelimit *rl, got_cancel_cb cancel_cb, void *cancel_arg);
121 301e83b3 2022-10-16 stsp
122 301e83b3 2022-10-16 stsp const struct got_error *
123 301e83b3 2022-10-16 stsp got_pack_load_tree_entries(struct got_object_id_queue *ids, int want_meta,
124 301e83b3 2022-10-16 stsp struct got_object_idset *idset, struct got_object_idset *idset_exclude,
125 301e83b3 2022-10-16 stsp struct got_tree_object *tree,
126 301e83b3 2022-10-16 stsp const char *dpath, time_t mtime, uint32_t seed, struct got_repository *repo,
127 301e83b3 2022-10-16 stsp int loose_obj_only, int *ncolored, int *nfound, int *ntrees,
128 301e83b3 2022-10-16 stsp got_pack_progress_cb progress_cb, void *progress_arg,
129 301e83b3 2022-10-16 stsp struct got_ratelimit *rl, got_cancel_cb cancel_cb, void *cancel_arg);
130 301e83b3 2022-10-16 stsp
131 301e83b3 2022-10-16 stsp const struct got_error *
132 301e83b3 2022-10-16 stsp got_pack_load_tree(int want_meta, struct got_object_idset *idset,
133 301e83b3 2022-10-16 stsp struct got_object_idset *idset_exclude,
134 301e83b3 2022-10-16 stsp struct got_object_id *tree_id, const char *dpath, time_t mtime,
135 301e83b3 2022-10-16 stsp uint32_t seed, struct got_repository *repo, int loose_obj_only,
136 301e83b3 2022-10-16 stsp int *ncolored, int *nfound, int *ntrees,
137 301e83b3 2022-10-16 stsp got_pack_progress_cb progress_cb, void *progress_arg,
138 301e83b3 2022-10-16 stsp struct got_ratelimit *rl, got_cancel_cb cancel_cb, void *cancel_arg);
139 301e83b3 2022-10-16 stsp
140 301e83b3 2022-10-16 stsp const struct got_error *
141 301e83b3 2022-10-16 stsp got_pack_add_object(int want_meta, struct got_object_idset *idset,
142 301e83b3 2022-10-16 stsp struct got_object_id *id, const char *path, int obj_type,
143 301e83b3 2022-10-16 stsp time_t mtime, uint32_t seed, int loose_obj_only,
144 301e83b3 2022-10-16 stsp struct got_repository *repo, int *ncolored, int *nfound, int *ntrees,
145 301e83b3 2022-10-16 stsp got_pack_progress_cb progress_cb, void *progress_arg,
146 301e83b3 2022-10-16 stsp struct got_ratelimit *rl);