plug some leak around imsg_init() error paths
[got-portable.git] / include / got_repository_admin.h
bloba1bb191618ec66c76deecf76d52349088c755a06
1 /*
2 * Copyright (c) 2021 Stefan Sperling <stsp@openbsd.org>
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 /* A callback function which gets invoked with progress information to print. */
18 typedef const struct got_error *(*got_pack_progress_cb)(void *arg,
19 int ncolored, int nfound, int ntrees, off_t packfile_size, int ncommits,
20 int nobj_total, int obj_deltify, int nobj_written);
23 * Attempt to pack objects reachable via 'include_refs' into a new packfile.
24 * If 'excluded_refs' is not an empty list, do not pack any objects
25 * reachable from the listed references.
26 * If loose_obj_only is zero, pack reachable objects even if they are
27 * already packed in another packfile. Otherwise, add only loose
28 * objects to the new pack file.
29 * Return an open file handle for the generated pack file.
30 * Return the hash digest of the resulting pack file in pack_hash which
31 * must freed by the caller when done.
33 const struct got_error *
34 got_repo_pack_objects(FILE **packfile, struct got_object_id **pack_hash,
35 struct got_reflist_head *include_refs,
36 struct got_reflist_head *exclude_refs, struct got_repository *repo,
37 int loose_obj_only, int force_refdelta,
38 got_pack_progress_cb progress_cb, void *progress_arg,
39 got_cancel_cb cancel_cb, void *cancel_arg);
42 * Attempt to open a pack file at the specified path. Return an open
43 * file handle and the expected hash of pack file contents.
45 const struct got_error *
46 got_repo_find_pack(FILE **packfile, struct got_object_id **pack_hash,
47 struct got_repository *repo, const char *packfile_path);
49 /* A callback function which gets invoked with progress information to print. */
50 typedef const struct got_error *(*got_pack_index_progress_cb)(void *arg,
51 off_t packfile_size, int nobj_total, int nobj_indexed,
52 int nobj_loose, int nobj_resolved);
54 /* (Re-)Index the pack file identified by the given hash. */
55 const struct got_error *
56 got_repo_index_pack(FILE *packfile, struct got_object_id *pack_hash,
57 struct got_repository *repo,
58 got_pack_index_progress_cb progress_cb, void *progress_arg,
59 got_cancel_cb cancel_cb, void *cancel_arg);
61 typedef const struct got_error *(*got_pack_list_cb)(void *arg,
62 struct got_object_id *id, int type, off_t offset, off_t size,
63 off_t base_offset, struct got_object_id *base_id);
65 /* List the pack file identified by the given hash. */
66 const struct got_error *
67 got_repo_list_pack(FILE *packfile, struct got_object_id *pack_hash,
68 struct got_repository *repo, got_pack_list_cb list_cb, void *list_arg,
69 got_cancel_cb cancel_cb, void *cancel_arg);
71 /* A callback function which gets invoked with cleanup information to print. */
72 typedef const struct got_error *(*got_cleanup_progress_cb)(void *arg,
73 int ncommits, int nloose, int npurged, int nredundant);
76 * Walk objects reachable via references to determine whether any loose
77 * objects can be removed from disk. Do remove such objects from disk
78 * unless the dry_run parameter is set.
79 * Do not remove objects with a modification timestamp above an
80 * implementation-defined timestamp threshold, unless ignore_mtime is set.
81 * Remove packfiles which objects are either unreachable or provided
82 * by biggest pack files.
83 * Return the disk space size occupied by loose objects and pack files
84 * before and after the operation.
85 * Return the number of loose objects which are also stored in a pack file.
87 const struct got_error *
88 got_repo_cleanup(struct got_repository *repo,
89 off_t *loose_before, off_t *loose_after,
90 off_t *pack_before, off_t *pack_after,
91 int *ncommits, int *nloose,
92 int *npacked, int dry_run, int ignore_mtime,
93 got_cleanup_progress_cb progress_cb, void *progress_arg,
94 got_cancel_cb cancel_cb, void *cancel_arg);
96 /* A callback function which gets invoked with cleanup information to print. */
97 typedef const struct got_error *(*got_lonely_packidx_progress_cb)(void *arg,
98 const char *path);
100 /* Remove pack index files which do not have a corresponding pack file. */
101 const struct got_error *
102 got_repo_remove_lonely_packidx(struct got_repository *repo, int dry_run,
103 got_lonely_packidx_progress_cb progress_cb, void *progress_arg,
104 got_cancel_cb cancel_cb, void *cancel_arg);