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 303e2782 2019-08-09 stsp struct got_tag_object;
20 4027f31a 2017-11-04 stsp
21 0c60ce5a 2018-04-02 stsp /* Open and close repositories. */
22 c9956ddf 2019-09-08 stsp const struct got_error *got_repo_open(struct got_repository**, const char *,
23 c9956ddf 2019-09-08 stsp const char *);
24 ad242220 2018-09-08 stsp const struct got_error *got_repo_close(struct got_repository*);
25 4027f31a 2017-11-04 stsp
26 4b0bb327 2019-01-06 stsp /* Obtain the on-disk path to the repository. */
27 7839bc15 2019-01-06 stsp const char *got_repo_get_path(struct got_repository *);
28 4b0bb327 2019-01-06 stsp
29 4b0bb327 2019-01-06 stsp /*
30 4b0bb327 2019-01-06 stsp * Obtain the path to a non-bare repository's .git directory.
31 4b0bb327 2019-01-06 stsp * For bare repositories, this returns the same result as got_repo_get_path().
32 4b0bb327 2019-01-06 stsp */
33 6e9da951 2019-01-06 stsp const char *got_repo_get_path_git_dir(struct got_repository *);
34 7839bc15 2019-01-06 stsp
35 aba9c984 2019-09-08 stsp /* Obtain the commit author name if parsed from gitconfig, else NULL. */
36 aba9c984 2019-09-08 stsp const char *got_repo_get_gitconfig_author_name(struct got_repository *);
37 aba9c984 2019-09-08 stsp
38 aba9c984 2019-09-08 stsp /* Obtain the commit author email if parsed from gitconfig, else NULL. */
39 aba9c984 2019-09-08 stsp const char *got_repo_get_gitconfig_author_email(struct got_repository *);
40 aba9c984 2019-09-08 stsp
41 c9956ddf 2019-09-08 stsp /* Obtain global commit author name parsed ~/.gitconfig, else NULL. */
42 c9956ddf 2019-09-08 stsp const char *got_repo_get_global_gitconfig_author_name(struct got_repository *);
43 c9956ddf 2019-09-08 stsp
44 c9956ddf 2019-09-08 stsp /* Obtain global commit author email parsed ~/.gitconfig, else NULL. */
45 c9956ddf 2019-09-08 stsp const char *got_repo_get_global_gitconfig_author_email(struct got_repository *);
46 c9956ddf 2019-09-08 stsp
47 9a1cc63f 2020-02-03 stsp /* Obtain repository owner name if parsed from gitconfig, else NULL. */
48 9a1cc63f 2020-02-03 stsp const char *got_repo_get_gitconfig_owner(struct got_repository *);
49 9a1cc63f 2020-02-03 stsp
50 cd95becd 2019-11-29 stsp /* Information about one remote repository. */
51 cd95becd 2019-11-29 stsp struct got_remote_repo {
52 cd95becd 2019-11-29 stsp char *name;
53 cd95becd 2019-11-29 stsp char *url;
54 cd95becd 2019-11-29 stsp };
55 cd95becd 2019-11-29 stsp
56 cd95becd 2019-11-29 stsp /* Obtain the list of remote repositories parsed from gitconfig. */
57 cd95becd 2019-11-29 stsp void got_repo_get_gitconfig_remotes(int *, struct got_remote_repo **,
58 cd95becd 2019-11-29 stsp struct got_repository *);
59 cd95becd 2019-11-29 stsp
60 0c60ce5a 2018-04-02 stsp /*
61 0c60ce5a 2018-04-02 stsp * Obtain paths to various directories within a repository.
62 0c60ce5a 2018-04-02 stsp * The caller must dispose of a path with free(3).
63 0c60ce5a 2018-04-02 stsp */
64 11995603 2017-11-05 stsp char *got_repo_get_path_objects(struct got_repository *);
65 a1fd68d8 2018-01-12 stsp char *got_repo_get_path_objects_pack(struct got_repository *);
66 11995603 2017-11-05 stsp char *got_repo_get_path_refs(struct got_repository *);
67 fb79db15 2019-02-01 stsp char *got_repo_get_path_packed_refs(struct got_repository *);
68 11995603 2017-11-05 stsp
69 11995603 2017-11-05 stsp struct got_reference;
70 11995603 2017-11-05 stsp
71 0c60ce5a 2018-04-02 stsp /*
72 0c60ce5a 2018-04-02 stsp * Obtain a reference, by name, from a repository.
73 0c60ce5a 2018-04-02 stsp * The caller must dispose of it with got_ref_close().
74 0c60ce5a 2018-04-02 stsp */
75 4027f31a 2017-11-04 stsp const struct got_error *got_repo_get_reference(struct got_reference **,
76 4027f31a 2017-11-04 stsp struct got_repository *, const char *);
77 04ca23f4 2018-07-16 stsp
78 04ca23f4 2018-07-16 stsp
79 04ca23f4 2018-07-16 stsp /* Indicate whether this is a bare repositiry (contains no git working tree). */
80 04ca23f4 2018-07-16 stsp int got_repo_is_bare(struct got_repository *);
81 04ca23f4 2018-07-16 stsp
82 04ca23f4 2018-07-16 stsp /* Attempt to map an arbitrary path to a path within the repository. */
83 04ca23f4 2018-07-16 stsp const struct got_error *got_repo_map_path(char **, struct got_repository *,
84 23721109 2018-10-22 stsp const char *, int);
85 2c7829a4 2019-06-17 stsp
86 2c7829a4 2019-06-17 stsp /* Create a new repository in an empty directory at a specified path. */
87 2c7829a4 2019-06-17 stsp const struct got_error *got_repo_init(const char *);
88 e09a504c 2019-06-28 stsp
89 e09a504c 2019-06-28 stsp /* Attempt to find a unique object ID for a given ID string prefix. */
90 e09a504c 2019-06-28 stsp const struct got_error *got_repo_match_object_id_prefix(struct got_object_id **,
91 dd88155e 2019-06-29 stsp const char *, int, struct got_repository *);
92 3ce1b845 2019-07-15 stsp
93 303e2782 2019-08-09 stsp /*
94 71a27632 2020-01-15 stsp * Given an object ID string or reference name, attempt to find a corresponding
95 71a27632 2020-01-15 stsp * commit object. Tags can optionally be ignored during matching.
96 71a27632 2020-01-15 stsp * The object type may be restricted to commit, tree, blob, or tag.
97 71a27632 2020-01-15 stsp * GOT_OBJ_TYPE_ANY will match any type of object.
98 71a27632 2020-01-15 stsp * A human-readable label can optionally be returned, which the caller should
99 71a27632 2020-01-15 stsp * dispose of with free(3).
100 71a27632 2020-01-15 stsp * Return GOT_ERR_NO_OBJ if no matching commit can be found.
101 71a27632 2020-01-15 stsp */
102 71a27632 2020-01-15 stsp const struct got_error *got_repo_match_object_id(struct got_object_id **,
103 71a27632 2020-01-15 stsp char **, const char *, int, int, struct got_repository *);
104 71a27632 2020-01-15 stsp
105 71a27632 2020-01-15 stsp /*
106 303e2782 2019-08-09 stsp * Attempt to find a tag object with a given name and target object type.
107 303e2782 2019-08-09 stsp * Return GOT_ERR_NO_OBJ if no matching tag can be found.
108 303e2782 2019-08-09 stsp */
109 303e2782 2019-08-09 stsp const struct got_error *got_repo_object_match_tag(struct got_tag_object **,
110 303e2782 2019-08-09 stsp const char *, int, struct got_repository *);
111 303e2782 2019-08-09 stsp
112 3ce1b845 2019-07-15 stsp /* A callback function which is invoked when a path is imported. */
113 3ce1b845 2019-07-15 stsp typedef const struct got_error *(*got_repo_import_cb)(void *, const char *);
114 3ce1b845 2019-07-15 stsp
115 3ce1b845 2019-07-15 stsp /*
116 3ce1b845 2019-07-15 stsp * Import an unversioned directory tree into the repository.
117 3ce1b845 2019-07-15 stsp * Creates a root commit, i.e. a commit with zero parents.
118 3ce1b845 2019-07-15 stsp */
119 3ce1b845 2019-07-15 stsp const struct got_error *got_repo_import(struct got_object_id **, const char *,
120 3ce1b845 2019-07-15 stsp const char *, const char *, struct got_pathlist_head *,
121 3ce1b845 2019-07-15 stsp struct got_repository *, got_repo_import_cb, void *);