Blame


1 7b19e0f1 2017-11-05 stsp /*
2 5d56da81 2019-01-13 stsp * Copyright (c) 2018, 2019 Stefan Sperling <stsp@openbsd.org>
3 7b19e0f1 2017-11-05 stsp *
4 7b19e0f1 2017-11-05 stsp * Permission to use, copy, modify, and distribute this software for any
5 7b19e0f1 2017-11-05 stsp * purpose with or without fee is hereby granted, provided that the above
6 7b19e0f1 2017-11-05 stsp * copyright notice and this permission notice appear in all copies.
7 7b19e0f1 2017-11-05 stsp *
8 7b19e0f1 2017-11-05 stsp * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 7b19e0f1 2017-11-05 stsp * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 7b19e0f1 2017-11-05 stsp * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 7b19e0f1 2017-11-05 stsp * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 7b19e0f1 2017-11-05 stsp * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 7b19e0f1 2017-11-05 stsp * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 7b19e0f1 2017-11-05 stsp * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 7b19e0f1 2017-11-05 stsp */
16 7b19e0f1 2017-11-05 stsp
17 3b339b2f 2018-02-12 stsp struct got_repository;
18 3ce1b845 2019-07-15 stsp struct got_pathlist_head;
19 4027f31a 2017-11-04 stsp
20 0c60ce5a 2018-04-02 stsp /* Open and close repositories. */
21 4027f31a 2017-11-04 stsp const struct got_error *got_repo_open(struct got_repository**, const char *);
22 ad242220 2018-09-08 stsp const struct got_error *got_repo_close(struct got_repository*);
23 4027f31a 2017-11-04 stsp
24 4b0bb327 2019-01-06 stsp /* Obtain the on-disk path to the repository. */
25 7839bc15 2019-01-06 stsp const char *got_repo_get_path(struct got_repository *);
26 4b0bb327 2019-01-06 stsp
27 4b0bb327 2019-01-06 stsp /*
28 4b0bb327 2019-01-06 stsp * Obtain the path to a non-bare repository's .git directory.
29 4b0bb327 2019-01-06 stsp * For bare repositories, this returns the same result as got_repo_get_path().
30 4b0bb327 2019-01-06 stsp */
31 6e9da951 2019-01-06 stsp const char *got_repo_get_path_git_dir(struct got_repository *);
32 7839bc15 2019-01-06 stsp
33 0c60ce5a 2018-04-02 stsp /*
34 0c60ce5a 2018-04-02 stsp * Obtain paths to various directories within a repository.
35 0c60ce5a 2018-04-02 stsp * The caller must dispose of a path with free(3).
36 0c60ce5a 2018-04-02 stsp */
37 11995603 2017-11-05 stsp char *got_repo_get_path_objects(struct got_repository *);
38 a1fd68d8 2018-01-12 stsp char *got_repo_get_path_objects_pack(struct got_repository *);
39 11995603 2017-11-05 stsp char *got_repo_get_path_refs(struct got_repository *);
40 fb79db15 2019-02-01 stsp char *got_repo_get_path_packed_refs(struct got_repository *);
41 11995603 2017-11-05 stsp
42 11995603 2017-11-05 stsp struct got_reference;
43 11995603 2017-11-05 stsp
44 0c60ce5a 2018-04-02 stsp /*
45 0c60ce5a 2018-04-02 stsp * Obtain a reference, by name, from a repository.
46 0c60ce5a 2018-04-02 stsp * The caller must dispose of it with got_ref_close().
47 0c60ce5a 2018-04-02 stsp */
48 4027f31a 2017-11-04 stsp const struct got_error *got_repo_get_reference(struct got_reference **,
49 4027f31a 2017-11-04 stsp struct got_repository *, const char *);
50 04ca23f4 2018-07-16 stsp
51 04ca23f4 2018-07-16 stsp
52 04ca23f4 2018-07-16 stsp /* Indicate whether this is a bare repositiry (contains no git working tree). */
53 04ca23f4 2018-07-16 stsp int got_repo_is_bare(struct got_repository *);
54 04ca23f4 2018-07-16 stsp
55 04ca23f4 2018-07-16 stsp /* Attempt to map an arbitrary path to a path within the repository. */
56 04ca23f4 2018-07-16 stsp const struct got_error *got_repo_map_path(char **, struct got_repository *,
57 23721109 2018-10-22 stsp const char *, int);
58 2c7829a4 2019-06-17 stsp
59 2c7829a4 2019-06-17 stsp /* Create a new repository in an empty directory at a specified path. */
60 2c7829a4 2019-06-17 stsp const struct got_error *got_repo_init(const char *);
61 e09a504c 2019-06-28 stsp
62 e09a504c 2019-06-28 stsp /* Attempt to find a unique object ID for a given ID string prefix. */
63 e09a504c 2019-06-28 stsp const struct got_error *got_repo_match_object_id_prefix(struct got_object_id **,
64 dd88155e 2019-06-29 stsp const char *, int, struct got_repository *);
65 3ce1b845 2019-07-15 stsp
66 3ce1b845 2019-07-15 stsp /* A callback function which is invoked when a path is imported. */
67 3ce1b845 2019-07-15 stsp typedef const struct got_error *(*got_repo_import_cb)(void *, const char *);
68 3ce1b845 2019-07-15 stsp
69 3ce1b845 2019-07-15 stsp /*
70 3ce1b845 2019-07-15 stsp * Import an unversioned directory tree into the repository.
71 3ce1b845 2019-07-15 stsp * Creates a root commit, i.e. a commit with zero parents.
72 3ce1b845 2019-07-15 stsp */
73 3ce1b845 2019-07-15 stsp const struct got_error *got_repo_import(struct got_object_id **, const char *,
74 3ce1b845 2019-07-15 stsp const char *, const char *, struct got_pathlist_head *,
75 3ce1b845 2019-07-15 stsp struct got_repository *, got_repo_import_cb, void *);