Blob


1 /*
2 * Copyright (c) 2017 Stefan Sperling <stsp@openbsd.org>
3 *
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.
7 *
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.
15 */
17 struct got_object_id {
18 u_int8_t sha1[SHA1_DIGEST_LENGTH];
19 };
21 struct got_blob_object {
22 char *dummy;
23 };
25 struct got_tree_object {
26 char *dummy;
27 };
29 struct got_parent_id {
30 SIMPLEQ_ENTRY(got_parent_id) entry;
31 struct got_object_id id;
32 };
34 SIMPLEQ_HEAD(got_parent_id_list, got_parent_id);
36 struct got_commit_object {
37 struct got_object_id tree_id;
38 unsigned int nparents;
39 SIMPLEQ_HEAD(, got_parent_id) parent_ids;
40 char *author;
41 char *committer;
42 char *logmsg;
43 };
45 struct got_object {
46 int type;
47 #define GOT_OBJ_TYPE_COMMIT 1
48 #define GOT_OBJ_TYPE_TREE 2
49 #define GOT_OBJ_TYPE_BLOB 3
51 size_t hdrlen;
52 size_t size;
53 struct got_object_id id;
54 union {
55 struct got_blob_object blob;
56 struct got_tree_object tree;
57 struct got_commit_object commit;
58 } obj;
59 };
61 struct got_repository;
63 const char * got_object_id_str(struct got_object_id *, char *, size_t);
64 const struct got_error *got_object_open(struct got_object **,
65 struct got_repository *, struct got_object_id *);
66 void got_object_close(struct got_object *);
67 const struct got_error *got_object_commit_open(struct got_commit_object **,
68 struct got_repository *, struct got_object *);
69 void got_object_commit_close(struct got_commit_object *);