Blame


1 7b19e0f1 2017-11-05 stsp /*
2 a1fd68d8 2018-01-12 stsp * Copyright (c) 2018 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 bbc740ac 2023-02-04 op
17 bbc740ac 2023-02-04 op #define GOT_OBJECT_ID_HEX_MAXLEN SHA1_DIGEST_STRING_LENGTH
18 7b19e0f1 2017-11-05 stsp
19 87a3ab84 2023-02-23 op enum got_hash_algorithm {
20 87a3ab84 2023-02-23 op GOT_HASH_SHA1,
21 87a3ab84 2023-02-23 op GOT_HASH_SHA256,
22 87a3ab84 2023-02-23 op };
23 87a3ab84 2023-02-23 op
24 d7b5a0e8 2022-04-20 stsp struct got_object_id {
25 d7b5a0e8 2022-04-20 stsp u_int8_t sha1[SHA1_DIGEST_LENGTH];
26 d7b5a0e8 2022-04-20 stsp };
27 d71d75ad 2017-11-05 stsp
28 f934cf2c 2018-02-12 stsp struct got_blob_object;
29 883f0469 2018-06-23 stsp struct got_tree_object;
30 56e0773d 2019-11-28 stsp struct got_tree_entry;
31 f4a881ce 2018-11-17 stsp struct got_tag_object;
32 45d799e2 2018-12-23 stsp struct got_commit_object;
33 d1cda826 2017-11-06 stsp
34 79f35eb3 2018-06-11 stsp struct got_object_qid {
35 dbdddfee 2021-06-23 naddy STAILQ_ENTRY(got_object_qid) entry;
36 d7b5a0e8 2022-04-20 stsp struct got_object_id id;
37 74a2356f 2021-06-18 stsp void *data; /* managed by API user */
38 d1cda826 2017-11-06 stsp };
39 d1cda826 2017-11-06 stsp
40 dbdddfee 2021-06-23 naddy STAILQ_HEAD(got_object_id_queue, got_object_qid);
41 b43fbaa0 2018-06-11 stsp
42 dbc6a6b6 2018-07-12 stsp const struct got_error *got_object_qid_alloc(struct got_object_qid **,
43 dbc6a6b6 2018-07-12 stsp struct got_object_id *);
44 dbc6a6b6 2018-07-12 stsp void got_object_qid_free(struct got_object_qid *);
45 dd88155e 2019-06-29 stsp void got_object_id_queue_free(struct got_object_id_queue *);
46 dbc6a6b6 2018-07-12 stsp
47 9ca9aafb 2021-06-18 stsp /*
48 9ca9aafb 2021-06-18 stsp * Deep-copy elements from ID queue src to ID queue dest. Do not copy any
49 9ca9aafb 2021-06-18 stsp * qid->data pointers! This is the caller's responsibility if needed.
50 9ca9aafb 2021-06-18 stsp */
51 9ca9aafb 2021-06-18 stsp const struct got_error *got_object_id_queue_copy(
52 9ca9aafb 2021-06-18 stsp const struct got_object_id_queue *src, struct got_object_id_queue *dest);
53 9ca9aafb 2021-06-18 stsp
54 15a94983 2018-12-23 stsp /* Object types. */
55 dd88155e 2019-06-29 stsp #define GOT_OBJ_TYPE_ANY 0 /* wildcard value at run-time */
56 9b1d5162 2017-12-03 stsp #define GOT_OBJ_TYPE_COMMIT 1
57 9b1d5162 2017-12-03 stsp #define GOT_OBJ_TYPE_TREE 2
58 9b1d5162 2017-12-03 stsp #define GOT_OBJ_TYPE_BLOB 3
59 9b1d5162 2017-12-03 stsp #define GOT_OBJ_TYPE_TAG 4
60 f9a4270b 2017-12-03 stsp /* 5 is reserved */
61 9b1d5162 2017-12-03 stsp #define GOT_OBJ_TYPE_OFFSET_DELTA 6
62 9b1d5162 2017-12-03 stsp #define GOT_OBJ_TYPE_REF_DELTA 7
63 ab9a70b2 2017-11-06 stsp
64 8aa93786 2019-08-22 stsp /*
65 8aa93786 2019-08-22 stsp * Labels used in object data.
66 8aa93786 2019-08-22 stsp */
67 8aa93786 2019-08-22 stsp
68 8aa93786 2019-08-22 stsp #define GOT_OBJ_LABEL_COMMIT "commit"
69 8aa93786 2019-08-22 stsp #define GOT_OBJ_LABEL_TREE "tree"
70 8aa93786 2019-08-22 stsp #define GOT_OBJ_LABEL_BLOB "blob"
71 8aa93786 2019-08-22 stsp #define GOT_OBJ_LABEL_TAG "tag"
72 8aa93786 2019-08-22 stsp
73 8aa93786 2019-08-22 stsp #define GOT_COMMIT_LABEL_TREE "tree "
74 8aa93786 2019-08-22 stsp #define GOT_COMMIT_LABEL_PARENT "parent "
75 8aa93786 2019-08-22 stsp #define GOT_COMMIT_LABEL_AUTHOR "author "
76 8aa93786 2019-08-22 stsp #define GOT_COMMIT_LABEL_COMMITTER "committer "
77 8aa93786 2019-08-22 stsp
78 8aa93786 2019-08-22 stsp #define GOT_TAG_LABEL_OBJECT "object "
79 8aa93786 2019-08-22 stsp #define GOT_TAG_LABEL_TYPE "type "
80 8aa93786 2019-08-22 stsp #define GOT_TAG_LABEL_TAG "tag "
81 8aa93786 2019-08-22 stsp #define GOT_TAG_LABEL_TAGGER "tagger "
82 8aa93786 2019-08-22 stsp
83 ab9a70b2 2017-11-06 stsp struct got_repository;
84 ab9a70b2 2017-11-06 stsp
85 0c60ce5a 2018-04-02 stsp /*
86 0c60ce5a 2018-04-02 stsp * Obtain a string representation of an object ID. The output depends on
87 0c60ce5a 2018-04-02 stsp * the hash function used by the repository format (currently SHA1).
88 0c60ce5a 2018-04-02 stsp */
89 ef0981d5 2018-02-12 stsp const struct got_error *got_object_id_str(char **, struct got_object_id *);
90 0c60ce5a 2018-04-02 stsp
91 0c60ce5a 2018-04-02 stsp /*
92 0c60ce5a 2018-04-02 stsp * Compare two object IDs. Return value behaves like memcmp(3).
93 0c60ce5a 2018-04-02 stsp */
94 984e8a45 2018-11-05 stsp int got_object_id_cmp(const struct got_object_id *,
95 984e8a45 2018-11-05 stsp const struct got_object_id *);
96 0c60ce5a 2018-04-02 stsp
97 0c60ce5a 2018-04-02 stsp /*
98 0c60ce5a 2018-04-02 stsp * Created a newly allocated copy of an object ID.
99 0c60ce5a 2018-04-02 stsp * The caller should dispose of it with free(3).
100 0c60ce5a 2018-04-02 stsp */
101 8bf5b3c9 2018-03-17 stsp struct got_object_id *got_object_id_dup(struct got_object_id *);
102 0c60ce5a 2018-04-02 stsp
103 0c60ce5a 2018-04-02 stsp /*
104 27d434c2 2018-09-15 stsp * Get a newly allocated ID of the object which resides at the specified
105 67b631c9 2021-10-10 stsp * path in the specified tree.
106 67b631c9 2021-10-10 stsp * The caller should dispose of it with free(3).
107 67b631c9 2021-10-10 stsp */
108 67b631c9 2021-10-10 stsp const struct got_error *got_object_tree_find_path(struct got_object_id **id,
109 67b631c9 2021-10-10 stsp mode_t *mode, struct got_repository *repo, struct got_tree_object *tree,
110 67b631c9 2021-10-10 stsp const char *path);
111 67b631c9 2021-10-10 stsp
112 67b631c9 2021-10-10 stsp /*
113 67b631c9 2021-10-10 stsp * Get a newly allocated ID of the object which resides at the specified
114 27d434c2 2018-09-15 stsp * path in the tree of the specified commit.
115 27d434c2 2018-09-15 stsp * The caller should dispose of it with free(3).
116 27d434c2 2018-09-15 stsp */
117 6c34b1aa 2019-03-18 stsp const struct got_error *got_object_id_by_path(struct got_object_id **,
118 a44927cc 2022-04-07 stsp struct got_repository *, struct got_commit_object *, const char *);
119 27d434c2 2018-09-15 stsp
120 27d434c2 2018-09-15 stsp /*
121 0c60ce5a 2018-04-02 stsp * Obtain the type of an object.
122 0c60ce5a 2018-04-02 stsp * Returns one of the GOT_OBJ_TYPE_x values (see above).
123 0c60ce5a 2018-04-02 stsp */
124 15a94983 2018-12-23 stsp const struct got_error *got_object_get_type(int *, struct got_repository *,
125 15a94983 2018-12-23 stsp struct got_object_id *);
126 0c60ce5a 2018-04-02 stsp
127 0c60ce5a 2018-04-02 stsp /*
128 15a94983 2018-12-23 stsp * Attempt to resolve the textual representation of an object ID
129 15a94983 2018-12-23 stsp * to the ID of an existing object in the repository.
130 15a94983 2018-12-23 stsp * The caller should dispose of the ID with free(3).
131 0c60ce5a 2018-04-02 stsp */
132 6c34b1aa 2019-03-18 stsp const struct got_error *got_object_resolve_id_str(struct got_object_id **,
133 6c34b1aa 2019-03-18 stsp struct got_repository *, const char *);
134 0c60ce5a 2018-04-02 stsp
135 0c60ce5a 2018-04-02 stsp /*
136 0c60ce5a 2018-04-02 stsp * Attempt to open a commit object in a repository.
137 0c60ce5a 2018-04-02 stsp * The caller must dispose of the commit with got_object_commit_close().
138 0c60ce5a 2018-04-02 stsp */
139 6c34b1aa 2019-03-18 stsp const struct got_error *got_object_open_as_commit(struct got_commit_object **,
140 15a94983 2018-12-23 stsp struct got_repository *, struct got_object_id *);
141 0c60ce5a 2018-04-02 stsp
142 0c60ce5a 2018-04-02 stsp /* Dispose of a commit object. */
143 d1cda826 2017-11-06 stsp void got_object_commit_close(struct got_commit_object *);
144 0c60ce5a 2018-04-02 stsp
145 45d799e2 2018-12-23 stsp /* Obtain the ID of the tree created in a commit. */
146 45d799e2 2018-12-23 stsp struct got_object_id *got_object_commit_get_tree_id(struct got_commit_object *);
147 45d799e2 2018-12-23 stsp
148 45d799e2 2018-12-23 stsp /* Obtain the number of parent commits of a commit. */
149 45d799e2 2018-12-23 stsp int got_object_commit_get_nparents(struct got_commit_object *);
150 45d799e2 2018-12-23 stsp
151 45d799e2 2018-12-23 stsp /* Obtain the list of parent commits of a commit. */
152 45d799e2 2018-12-23 stsp const struct got_object_id_queue *got_object_commit_get_parent_ids(
153 45d799e2 2018-12-23 stsp struct got_commit_object *);
154 45d799e2 2018-12-23 stsp
155 45d799e2 2018-12-23 stsp /* Get the author's name and email address. */
156 45d799e2 2018-12-23 stsp const char *got_object_commit_get_author(struct got_commit_object *);
157 45d799e2 2018-12-23 stsp
158 2df4e4ff 2018-12-23 stsp /* Get an author's commit timestamp in UTC. */
159 45d799e2 2018-12-23 stsp time_t got_object_commit_get_author_time(struct got_commit_object *);
160 45d799e2 2018-12-23 stsp
161 45d799e2 2018-12-23 stsp /* Get an author's timezone offset. */
162 45d799e2 2018-12-23 stsp time_t got_object_commit_get_author_gmtoff(struct got_commit_object *);
163 45d799e2 2018-12-23 stsp
164 45d799e2 2018-12-23 stsp /* Get the committer's name and email address. */
165 45d799e2 2018-12-23 stsp const char *got_object_commit_get_committer(struct got_commit_object *);
166 45d799e2 2018-12-23 stsp
167 450eaa8b 2018-12-23 stsp /* Get a committer's commit timestamp in UTC. */
168 45d799e2 2018-12-23 stsp time_t got_object_commit_get_committer_time(struct got_commit_object *);
169 45d799e2 2018-12-23 stsp
170 450eaa8b 2018-12-23 stsp /* Get a committer's timezone offset. */
171 45d799e2 2018-12-23 stsp time_t got_object_commit_get_committer_gmtoff(struct got_commit_object *);
172 45d799e2 2018-12-23 stsp
173 24ea5512 2019-08-22 stsp /*
174 24ea5512 2019-08-22 stsp * Get the commit log message.
175 24ea5512 2019-08-22 stsp * PGP-signatures contained in the log message will be stripped.
176 24ea5512 2019-08-22 stsp * The caller must dispose of it with free(3).
177 24ea5512 2019-08-22 stsp */
178 5943eee2 2019-08-13 stsp const struct got_error *got_object_commit_get_logmsg(char **,
179 5943eee2 2019-08-13 stsp struct got_commit_object *);
180 45d799e2 2018-12-23 stsp
181 24ea5512 2019-08-22 stsp /* Get the raw commit log message.*/
182 24ea5512 2019-08-22 stsp const char *got_object_commit_get_logmsg_raw(struct got_commit_object *);
183 24ea5512 2019-08-22 stsp
184 0c60ce5a 2018-04-02 stsp /*
185 0c60ce5a 2018-04-02 stsp * Attempt to open a tree object in a repository.
186 0c60ce5a 2018-04-02 stsp * The caller must dispose of the tree with got_object_tree_close().
187 0c60ce5a 2018-04-02 stsp */
188 6c34b1aa 2019-03-18 stsp const struct got_error *got_object_open_as_tree(struct got_tree_object **,
189 15a94983 2018-12-23 stsp struct got_repository *, struct got_object_id *);
190 0c60ce5a 2018-04-02 stsp
191 0c60ce5a 2018-04-02 stsp /* Dispose of a tree object. */
192 0ffeb3c2 2017-11-26 stsp void got_object_tree_close(struct got_tree_object *);
193 0c60ce5a 2018-04-02 stsp
194 56e0773d 2019-11-28 stsp /* Get the number of entries in this tree object. */
195 56e0773d 2019-11-28 stsp int got_object_tree_get_nentries(struct got_tree_object *);
196 883f0469 2018-06-23 stsp
197 56e0773d 2019-11-28 stsp /* Get the first tree entry from a tree, or NULL if there is none. */
198 c0df5966 2021-12-31 stsp struct got_tree_entry *got_object_tree_get_first_entry(
199 c0df5966 2021-12-31 stsp struct got_tree_object *);
200 56e0773d 2019-11-28 stsp
201 56e0773d 2019-11-28 stsp /* Get the last tree entry from a tree, or NULL if there is none. */
202 56e0773d 2019-11-28 stsp struct got_tree_entry *got_object_tree_get_last_entry(struct got_tree_object *);
203 56e0773d 2019-11-28 stsp
204 56e0773d 2019-11-28 stsp /* Get the entry with the specified index from a tree object. */
205 56e0773d 2019-11-28 stsp struct got_tree_entry *got_object_tree_get_entry(
206 56e0773d 2019-11-28 stsp struct got_tree_object *, int);
207 56e0773d 2019-11-28 stsp
208 56e0773d 2019-11-28 stsp /* Find a particular entry in a tree by name. */
209 56e0773d 2019-11-28 stsp struct got_tree_entry *got_object_tree_find_entry(
210 a129376b 2019-03-28 stsp struct got_tree_object *, const char *);
211 a129376b 2019-03-28 stsp
212 56e0773d 2019-11-28 stsp /* Get the file permission mode of a tree entry. */
213 56e0773d 2019-11-28 stsp mode_t got_tree_entry_get_mode(struct got_tree_entry *);
214 56e0773d 2019-11-28 stsp
215 56e0773d 2019-11-28 stsp /* Get the name of a tree entry. */
216 56e0773d 2019-11-28 stsp const char *got_tree_entry_get_name(struct got_tree_entry *);
217 56e0773d 2019-11-28 stsp
218 56e0773d 2019-11-28 stsp /* Get the object ID of a tree entry. */
219 56e0773d 2019-11-28 stsp struct got_object_id *got_tree_entry_get_id(struct got_tree_entry *);
220 56e0773d 2019-11-28 stsp
221 0d6c6ee3 2020-05-20 stsp /*
222 0d6c6ee3 2020-05-20 stsp * Get a string containing the target path of a given a symlink tree entry.
223 0d6c6ee3 2020-05-20 stsp * The caller should dispose of it with free(3).
224 0d6c6ee3 2020-05-20 stsp */
225 0d6c6ee3 2020-05-20 stsp const struct got_error *got_tree_entry_get_symlink_target(char **,
226 0d6c6ee3 2020-05-20 stsp struct got_tree_entry *, struct got_repository *);
227 0d6c6ee3 2020-05-20 stsp
228 56e0773d 2019-11-28 stsp /* Get the index of a tree entry. */
229 56e0773d 2019-11-28 stsp int got_tree_entry_get_index(struct got_tree_entry *);
230 56e0773d 2019-11-28 stsp
231 56e0773d 2019-11-28 stsp /* Get the next tree entry from a tree, or NULL if there is none. */
232 56e0773d 2019-11-28 stsp struct got_tree_entry *got_tree_entry_get_next(struct got_tree_object *,
233 56e0773d 2019-11-28 stsp struct got_tree_entry *);
234 56e0773d 2019-11-28 stsp
235 56e0773d 2019-11-28 stsp /* Get the previous tree entry from a tree, or NULL if there is none. */
236 56e0773d 2019-11-28 stsp struct got_tree_entry *got_tree_entry_get_prev(struct got_tree_object *,
237 56e0773d 2019-11-28 stsp struct got_tree_entry *);
238 56e0773d 2019-11-28 stsp
239 63c5ca5d 2019-08-24 stsp /* Return non-zero if the specified tree entry is a Git submodule. */
240 56e0773d 2019-11-28 stsp int got_object_tree_entry_is_submodule(struct got_tree_entry *);
241 63c5ca5d 2019-08-24 stsp
242 e40622f4 2020-07-23 stsp /* Return non-zero if the specified tree entry is a symbolic link. */
243 e40622f4 2020-07-23 stsp int got_object_tree_entry_is_symlink(struct got_tree_entry *);
244 e40622f4 2020-07-23 stsp
245 0c60ce5a 2018-04-02 stsp /*
246 e40622f4 2020-07-23 stsp * Resolve an in-repository symlink at the specified path in the tree
247 e40622f4 2020-07-23 stsp * corresponding to the specified commit. If the specified path is not
248 e40622f4 2020-07-23 stsp * a symlink then set *link_target to NULL.
249 e40622f4 2020-07-23 stsp * Otherwise, resolve symlinks recursively and return the final link
250 5e91dae4 2022-08-30 stsp * target path. The caller must dispose of it with free(3).
251 e40622f4 2020-07-23 stsp */
252 e40622f4 2020-07-23 stsp const struct got_error *got_object_resolve_symlinks(char **, const char *,
253 a44927cc 2022-04-07 stsp struct got_commit_object *, struct got_repository *);
254 e40622f4 2020-07-23 stsp
255 e40622f4 2020-07-23 stsp /*
256 07862c20 2018-09-15 stsp * Compare two trees and indicate whether the entry at the specified path
257 31cedeaf 2018-09-15 stsp * differs between them. The path must not be the root path "/"; the function
258 31cedeaf 2018-09-15 stsp * got_object_id_cmp() should be used instead to compare the tree roots.
259 07862c20 2018-09-15 stsp */
260 07862c20 2018-09-15 stsp const struct got_error *got_object_tree_path_changed(int *,
261 07862c20 2018-09-15 stsp struct got_tree_object *, struct got_tree_object *, const char *,
262 07862c20 2018-09-15 stsp struct got_repository *);
263 07862c20 2018-09-15 stsp
264 07862c20 2018-09-15 stsp /*
265 0c60ce5a 2018-04-02 stsp * Attempt to open a blob object in a repository.
266 0c60ce5a 2018-04-02 stsp * The size_t argument specifies the block size of an associated read buffer.
267 0c60ce5a 2018-04-02 stsp * The caller must dispose of the blob with got_object_blob_close().
268 0c60ce5a 2018-04-02 stsp */
269 6c34b1aa 2019-03-18 stsp const struct got_error *got_object_open_as_blob(struct got_blob_object **,
270 eb81bc23 2022-06-28 tracey struct got_repository *, struct got_object_id *, size_t, int);
271 0c60ce5a 2018-04-02 stsp
272 0c60ce5a 2018-04-02 stsp /* Dispose of a blob object. */
273 fb43ecf1 2019-02-11 stsp const struct got_error *got_object_blob_close(struct got_blob_object *);
274 0c60ce5a 2018-04-02 stsp
275 0c60ce5a 2018-04-02 stsp /*
276 0c60ce5a 2018-04-02 stsp * Get the length of header data at the beginning of the blob's read buffer.
277 0c60ce5a 2018-04-02 stsp * Note that header data is only present upon the first invocation of
278 0c60ce5a 2018-04-02 stsp * got_object_blob_read_block() after the blob is opened.
279 0c60ce5a 2018-04-02 stsp */
280 f934cf2c 2018-02-12 stsp size_t got_object_blob_get_hdrlen(struct got_blob_object *);
281 0c60ce5a 2018-04-02 stsp
282 0c60ce5a 2018-04-02 stsp /*
283 0c60ce5a 2018-04-02 stsp * Get a pointer to the blob's read buffer.
284 0c60ce5a 2018-04-02 stsp * The read buffer is filled by got_object_blob_read_block().
285 0c60ce5a 2018-04-02 stsp */
286 f934cf2c 2018-02-12 stsp const uint8_t *got_object_blob_get_read_buf(struct got_blob_object *);
287 0c60ce5a 2018-04-02 stsp
288 0c60ce5a 2018-04-02 stsp /*
289 0c60ce5a 2018-04-02 stsp * Read the next chunk of data from a blob, up to the blob's read buffer
290 0c60ce5a 2018-04-02 stsp * block size. The size_t output argument indicates how many bytes have
291 0c60ce5a 2018-04-02 stsp * been read into the blob's read buffer. Zero bytes will be reported if
292 0c60ce5a 2018-04-02 stsp * all data in the blob has been read.
293 0c60ce5a 2018-04-02 stsp */
294 eb651edf 2018-02-11 stsp const struct got_error *got_object_blob_read_block(size_t *,
295 eb651edf 2018-02-11 stsp struct got_blob_object *);
296 be6a1b5a 2018-06-11 stsp
297 8ba819a3 2020-07-23 stsp /* Rewind an open blob's data stream back to the beginning. */
298 8ba819a3 2020-07-23 stsp void got_object_blob_rewind(struct got_blob_object *);
299 8ba819a3 2020-07-23 stsp
300 35e9ba5d 2018-06-21 stsp /*
301 0d569390 2023-01-04 op * Heuristic to check whether the blob contains binary data. Rewinds
302 0d569390 2023-01-04 op * the blob's data stream back after the header.
303 0d569390 2023-01-04 op */
304 0d569390 2023-01-04 op const struct got_error *got_object_blob_is_binary(int *,
305 0d569390 2023-01-04 op struct got_blob_object *);
306 389a68d8 2023-01-05 op
307 389a68d8 2023-01-05 op /*
308 389a68d8 2023-01-05 op * getline(3) for blobs.
309 389a68d8 2023-01-05 op */
310 389a68d8 2023-01-05 op const struct got_error *got_object_blob_getline(char **, ssize_t *,
311 389a68d8 2023-01-05 op size_t *, struct got_blob_object *);
312 0d569390 2023-01-04 op
313 0d569390 2023-01-04 op /*
314 35e9ba5d 2018-06-21 stsp * Read the entire content of a blob and write it to the specified file.
315 84451b3e 2018-07-10 stsp * Flush and rewind the file as well. Indicate the amount of bytes
316 6c4c42e0 2019-06-24 stsp * written in the size_t output argument, and the number of lines in the
317 0f6650ff 2019-08-14 stsp * file in the int argument, and line offsets in the off_t argument
318 6c4c42e0 2019-06-24 stsp * (NULL can be passed for any output argument).
319 35e9ba5d 2018-06-21 stsp */
320 be659d10 2020-11-18 stsp const struct got_error *got_object_blob_dump_to_file(off_t *, int *,
321 6c4c42e0 2019-06-24 stsp off_t **, FILE *, struct got_blob_object *);
322 af57b12a 2020-07-23 stsp
323 af57b12a 2020-07-23 stsp /*
324 af57b12a 2020-07-23 stsp * Read the entire content of a blob into a newly allocated string buffer
325 af57b12a 2020-07-23 stsp * and terminate it with '\0'. This is intended for blobs which contain a
326 af57b12a 2020-07-23 stsp * symlink target path. It should not be used to process arbitrary blobs.
327 af57b12a 2020-07-23 stsp * Use got_object_blob_dump_to_file() or got_tree_entry_get_symlink_target()
328 af57b12a 2020-07-23 stsp * instead if possible. The caller must dispose of the string with free(3).
329 af57b12a 2020-07-23 stsp */
330 af57b12a 2020-07-23 stsp const struct got_error *got_object_blob_read_to_str(char **,
331 af57b12a 2020-07-23 stsp struct got_blob_object *);
332 35e9ba5d 2018-06-21 stsp
333 f4a881ce 2018-11-17 stsp /*
334 f4a881ce 2018-11-17 stsp * Attempt to open a tag object in a repository.
335 01073a5d 2019-08-22 stsp * The caller must dispose of the tree with got_tag_object_close().
336 f4a881ce 2018-11-17 stsp */
337 15a94983 2018-12-23 stsp const struct got_error *got_object_open_as_tag(struct got_tag_object **,
338 15a94983 2018-12-23 stsp struct got_repository *, struct got_object_id *);
339 f4a881ce 2018-11-17 stsp
340 f4a881ce 2018-11-17 stsp /* Dispose of a tag object. */
341 f4a881ce 2018-11-17 stsp void got_object_tag_close(struct got_tag_object *);
342 f4a881ce 2018-11-17 stsp
343 d24820bf 2019-08-11 stsp /* Get the name of a tag. */
344 d24820bf 2019-08-11 stsp const char *got_object_tag_get_name(struct got_tag_object *);
345 d24820bf 2019-08-11 stsp
346 0bd18d37 2019-02-01 stsp /* Get type of the object a tag points to. */
347 0bd18d37 2019-02-01 stsp int got_object_tag_get_object_type(struct got_tag_object *);
348 0bd18d37 2019-02-01 stsp
349 0bd18d37 2019-02-01 stsp /*
350 0bd18d37 2019-02-01 stsp * Get ID of the object a tag points to.
351 0bd18d37 2019-02-01 stsp * This must not be freed by the caller. Use got_object_id_dup() if needed.
352 0bd18d37 2019-02-01 stsp */
353 0bd18d37 2019-02-01 stsp struct got_object_id *got_object_tag_get_object_id(struct got_tag_object *);
354 0bd18d37 2019-02-01 stsp
355 01073a5d 2019-08-22 stsp
356 01073a5d 2019-08-22 stsp /* Get the timestamp of the tag. */
357 01073a5d 2019-08-22 stsp time_t got_object_tag_get_tagger_time(struct got_tag_object *);
358 01073a5d 2019-08-22 stsp
359 01073a5d 2019-08-22 stsp /* Get the tag's timestamp's GMT offset. */
360 01073a5d 2019-08-22 stsp time_t got_object_tag_get_tagger_gmtoff(struct got_tag_object *);
361 01073a5d 2019-08-22 stsp
362 01073a5d 2019-08-22 stsp /* Get the author of the tag. */
363 01073a5d 2019-08-22 stsp const char *got_object_tag_get_tagger(struct got_tag_object *);
364 01073a5d 2019-08-22 stsp
365 01073a5d 2019-08-22 stsp /* Get the tag message associated with the tag. */
366 01073a5d 2019-08-22 stsp const char *got_object_tag_get_message(struct got_tag_object *);
367 01073a5d 2019-08-22 stsp
368 bff6ca00 2018-04-23 stsp const struct got_error *got_object_commit_add_parent(struct got_commit_object *,
369 bff6ca00 2018-04-23 stsp const char *);
370 8e7bd50a 2019-08-22 stsp
371 8e7bd50a 2019-08-22 stsp /* Create a new tag object in the repository. */
372 8e7bd50a 2019-08-22 stsp const struct got_error *got_object_tag_create(struct got_object_id **,
373 8e7bd50a 2019-08-22 stsp const char *, struct got_object_id *, const char *,
374 4d5ee956 2022-07-02 jrick time_t, const char *, const char *, struct got_repository *, int verbosity);
375 568eae95 2022-09-11 mark
376 34a842a4 2022-09-18 mark /* Increment commit object reference counter. */
377 34a842a4 2022-09-18 mark void got_object_commit_retain(struct got_commit_object *);