Blame


1 718b3ab0 2018-03-17 stsp /*
2 5d56da81 2019-01-13 stsp * Copyright (c) 2018, 2019 Stefan Sperling <stsp@openbsd.org>
3 718b3ab0 2018-03-17 stsp *
4 718b3ab0 2018-03-17 stsp * Permission to use, copy, modify, and distribute this software for any
5 718b3ab0 2018-03-17 stsp * purpose with or without fee is hereby granted, provided that the above
6 718b3ab0 2018-03-17 stsp * copyright notice and this permission notice appear in all copies.
7 718b3ab0 2018-03-17 stsp *
8 718b3ab0 2018-03-17 stsp * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 718b3ab0 2018-03-17 stsp * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 718b3ab0 2018-03-17 stsp * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 718b3ab0 2018-03-17 stsp * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 718b3ab0 2018-03-17 stsp * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 718b3ab0 2018-03-17 stsp * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 718b3ab0 2018-03-17 stsp * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 718b3ab0 2018-03-17 stsp */
16 718b3ab0 2018-03-17 stsp
17 718b3ab0 2018-03-17 stsp struct got_object_id {
18 718b3ab0 2018-03-17 stsp u_int8_t sha1[SHA1_DIGEST_LENGTH];
19 718b3ab0 2018-03-17 stsp };
20 718b3ab0 2018-03-17 stsp
21 718b3ab0 2018-03-17 stsp struct got_object {
22 718b3ab0 2018-03-17 stsp int type;
23 15a94983 2018-12-23 stsp
24 718b3ab0 2018-03-17 stsp int flags;
25 718b3ab0 2018-03-17 stsp #define GOT_OBJ_FLAG_PACKED 0x01
26 718b3ab0 2018-03-17 stsp #define GOT_OBJ_FLAG_DELTIFIED 0x02
27 718b3ab0 2018-03-17 stsp
28 718b3ab0 2018-03-17 stsp size_t hdrlen;
29 718b3ab0 2018-03-17 stsp size_t size;
30 718b3ab0 2018-03-17 stsp struct got_object_id id;
31 718b3ab0 2018-03-17 stsp
32 718b3ab0 2018-03-17 stsp char *path_packfile; /* if packed */
33 c59b3346 2018-09-11 stsp int pack_idx; /* if packed */
34 718b3ab0 2018-03-17 stsp off_t pack_offset; /* if packed */
35 718b3ab0 2018-03-17 stsp struct got_delta_chain deltas; /* if deltified */
36 7bb0daa1 2018-06-21 stsp int refcnt; /* > 0 if open and/or cached */
37 718b3ab0 2018-03-17 stsp };
38 718b3ab0 2018-03-17 stsp
39 45d799e2 2018-12-23 stsp struct got_commit_object {
40 45d799e2 2018-12-23 stsp struct got_object_id *tree_id;
41 45d799e2 2018-12-23 stsp unsigned int nparents;
42 45d799e2 2018-12-23 stsp struct got_object_id_queue parent_ids;
43 45d799e2 2018-12-23 stsp char *author;
44 45d799e2 2018-12-23 stsp time_t author_time; /* UTC */
45 45d799e2 2018-12-23 stsp time_t author_gmtoff;
46 45d799e2 2018-12-23 stsp char *committer;
47 45d799e2 2018-12-23 stsp time_t committer_time; /* UTC */
48 45d799e2 2018-12-23 stsp time_t committer_gmtoff;
49 45d799e2 2018-12-23 stsp char *logmsg;
50 45d799e2 2018-12-23 stsp int refcnt; /* > 0 if open and/or cached */
51 45d799e2 2018-12-23 stsp };
52 45d799e2 2018-12-23 stsp
53 883f0469 2018-06-23 stsp struct got_tree_object {
54 883f0469 2018-06-23 stsp struct got_tree_entries entries;
55 883f0469 2018-06-23 stsp int refcnt;
56 883f0469 2018-06-23 stsp };
57 883f0469 2018-06-23 stsp
58 718b3ab0 2018-03-17 stsp struct got_blob_object {
59 718b3ab0 2018-03-17 stsp FILE *f;
60 ac544f8c 2019-01-13 stsp uint8_t *data;
61 718b3ab0 2018-03-17 stsp size_t hdrlen;
62 718b3ab0 2018-03-17 stsp size_t blocksize;
63 718b3ab0 2018-03-17 stsp uint8_t *read_buf;
64 718b3ab0 2018-03-17 stsp struct got_object_id id;
65 718b3ab0 2018-03-17 stsp };
66 f4a881ce 2018-11-17 stsp
67 f4a881ce 2018-11-17 stsp struct got_tag_object {
68 f4a881ce 2018-11-17 stsp struct got_object_id id;
69 f4a881ce 2018-11-17 stsp int obj_type;
70 f4a881ce 2018-11-17 stsp char *tag;
71 f4a881ce 2018-11-17 stsp time_t tagger_time;
72 f4a881ce 2018-11-17 stsp time_t tagger_gmtoff;
73 f4a881ce 2018-11-17 stsp char *tagger;
74 f4a881ce 2018-11-17 stsp char *tagmsg;
75 f4a881ce 2018-11-17 stsp int refcnt; /* > 0 if open and/or cached */
76 f4a881ce 2018-11-17 stsp };
77 15a94983 2018-12-23 stsp
78 e02fc99f 2019-03-19 stsp #define GOT_OBJ_LABEL_COMMIT "commit"
79 e02fc99f 2019-03-19 stsp #define GOT_OBJ_LABEL_TREE "tree"
80 e02fc99f 2019-03-19 stsp #define GOT_OBJ_LABEL_BLOB "blob"
81 e02fc99f 2019-03-19 stsp #define GOT_OBJ_LABEL_TAG "tag"
82 e02fc99f 2019-03-19 stsp
83 e02fc99f 2019-03-19 stsp #define GOT_COMMIT_LABEL_TREE "tree "
84 e02fc99f 2019-03-19 stsp #define GOT_COMMIT_LABEL_PARENT "parent "
85 e02fc99f 2019-03-19 stsp #define GOT_COMMIT_LABEL_AUTHOR "author "
86 e02fc99f 2019-03-19 stsp #define GOT_COMMIT_LABEL_COMMITTER "committer "
87 e02fc99f 2019-03-19 stsp
88 e02fc99f 2019-03-19 stsp #define GOT_TAG_LABEL_OBJECT "object "
89 e02fc99f 2019-03-19 stsp #define GOT_TAG_LABEL_TYPE "type "
90 e02fc99f 2019-03-19 stsp #define GOT_TAG_LABEL_TAG "tag "
91 e02fc99f 2019-03-19 stsp #define GOT_TAG_LABEL_TAGGER "tagger "
92 e02fc99f 2019-03-19 stsp
93 15a94983 2018-12-23 stsp struct got_object_id *got_object_get_id(struct got_object *);
94 15a94983 2018-12-23 stsp const struct got_error *got_object_get_id_str(char **, struct got_object *);
95 90bdb554 2019-04-11 stsp const struct got_error *got_object_get_path(char **, struct got_object_id *,
96 90bdb554 2019-04-11 stsp struct got_repository *);
97 15a94983 2018-12-23 stsp const struct got_error *got_object_open(struct got_object **,
98 15a94983 2018-12-23 stsp struct got_repository *, struct got_object_id *);
99 15a94983 2018-12-23 stsp const struct got_error *got_object_open_by_id_str(struct got_object **,
100 15a94983 2018-12-23 stsp struct got_repository *, const char *);
101 15a94983 2018-12-23 stsp void got_object_close(struct got_object *);
102 15a94983 2018-12-23 stsp const struct got_error *got_object_commit_open(struct got_commit_object **,
103 15a94983 2018-12-23 stsp struct got_repository *, struct got_object *);
104 15a94983 2018-12-23 stsp const struct got_error *got_object_tree_open(struct got_tree_object **,
105 15a94983 2018-12-23 stsp struct got_repository *, struct got_object *);
106 15a94983 2018-12-23 stsp const struct got_error *got_object_blob_open(struct got_blob_object **,
107 15a94983 2018-12-23 stsp struct got_repository *, struct got_object *, size_t);
108 ddf1c734 2018-12-23 stsp char *got_object_blob_id_str(struct got_blob_object*, char *, size_t);
109 15a94983 2018-12-23 stsp const struct got_error *got_object_tag_open(struct got_tag_object **,
110 15a94983 2018-12-23 stsp struct got_repository *, struct got_object *);
111 ed175427 2019-05-09 stsp const struct got_error *got_object_tree_entry_dup(struct got_tree_entry **,
112 ed175427 2019-05-09 stsp struct got_tree_entry *);