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