Blame


1 718b3ab0 2018-03-17 stsp /*
2 5aa81393 2020-01-06 stsp * Copyright (c) 2018, 2019, 2020 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 c59b3346 2018-09-11 stsp int pack_idx; /* if packed */
33 718b3ab0 2018-03-17 stsp off_t pack_offset; /* if packed */
34 718b3ab0 2018-03-17 stsp struct got_delta_chain deltas; /* if deltified */
35 7bb0daa1 2018-06-21 stsp int refcnt; /* > 0 if open and/or cached */
36 718b3ab0 2018-03-17 stsp };
37 718b3ab0 2018-03-17 stsp
38 59d1e4a0 2021-03-10 stsp struct got_raw_object {
39 59d1e4a0 2021-03-10 stsp FILE *f;
40 59d1e4a0 2021-03-10 stsp uint8_t *data;
41 59d1e4a0 2021-03-10 stsp off_t size;
42 59d1e4a0 2021-03-10 stsp size_t hdrlen;
43 59d1e4a0 2021-03-10 stsp size_t blocksize;
44 59d1e4a0 2021-03-10 stsp uint8_t *read_buf;
45 59d1e4a0 2021-03-10 stsp };
46 59d1e4a0 2021-03-10 stsp
47 45d799e2 2018-12-23 stsp struct got_commit_object {
48 45d799e2 2018-12-23 stsp struct got_object_id *tree_id;
49 45d799e2 2018-12-23 stsp unsigned int nparents;
50 45d799e2 2018-12-23 stsp struct got_object_id_queue parent_ids;
51 45d799e2 2018-12-23 stsp char *author;
52 45d799e2 2018-12-23 stsp time_t author_time; /* UTC */
53 45d799e2 2018-12-23 stsp time_t author_gmtoff;
54 45d799e2 2018-12-23 stsp char *committer;
55 45d799e2 2018-12-23 stsp time_t committer_time; /* UTC */
56 45d799e2 2018-12-23 stsp time_t committer_gmtoff;
57 45d799e2 2018-12-23 stsp char *logmsg;
58 45d799e2 2018-12-23 stsp int refcnt; /* > 0 if open and/or cached */
59 ca6e02ac 2020-01-07 stsp
60 ca6e02ac 2020-01-07 stsp int flags;
61 ca6e02ac 2020-01-07 stsp #define GOT_COMMIT_FLAG_PACKED 0x01
62 45d799e2 2018-12-23 stsp };
63 45d799e2 2018-12-23 stsp
64 56e0773d 2019-11-28 stsp struct got_tree_entry {
65 56e0773d 2019-11-28 stsp mode_t mode;
66 2c98ee28 2019-11-29 stsp char name[NAME_MAX + 1 /* NUL */];
67 56e0773d 2019-11-28 stsp struct got_object_id id;
68 56e0773d 2019-11-28 stsp int idx;
69 56e0773d 2019-11-28 stsp };
70 56e0773d 2019-11-28 stsp
71 883f0469 2018-06-23 stsp struct got_tree_object {
72 56e0773d 2019-11-28 stsp int nentries;
73 56e0773d 2019-11-28 stsp struct got_tree_entry *entries;
74 883f0469 2018-06-23 stsp int refcnt;
75 883f0469 2018-06-23 stsp };
76 883f0469 2018-06-23 stsp
77 718b3ab0 2018-03-17 stsp struct got_blob_object {
78 718b3ab0 2018-03-17 stsp FILE *f;
79 ac544f8c 2019-01-13 stsp uint8_t *data;
80 718b3ab0 2018-03-17 stsp size_t hdrlen;
81 718b3ab0 2018-03-17 stsp size_t blocksize;
82 718b3ab0 2018-03-17 stsp uint8_t *read_buf;
83 718b3ab0 2018-03-17 stsp struct got_object_id id;
84 718b3ab0 2018-03-17 stsp };
85 f4a881ce 2018-11-17 stsp
86 f4a881ce 2018-11-17 stsp struct got_tag_object {
87 f4a881ce 2018-11-17 stsp struct got_object_id id;
88 f4a881ce 2018-11-17 stsp int obj_type;
89 f4a881ce 2018-11-17 stsp char *tag;
90 f4a881ce 2018-11-17 stsp time_t tagger_time;
91 f4a881ce 2018-11-17 stsp time_t tagger_gmtoff;
92 f4a881ce 2018-11-17 stsp char *tagger;
93 f4a881ce 2018-11-17 stsp char *tagmsg;
94 f4a881ce 2018-11-17 stsp int refcnt; /* > 0 if open and/or cached */
95 f4a881ce 2018-11-17 stsp };
96 15a94983 2018-12-23 stsp
97 15a94983 2018-12-23 stsp struct got_object_id *got_object_get_id(struct got_object *);
98 15a94983 2018-12-23 stsp const struct got_error *got_object_get_id_str(char **, struct got_object *);
99 90bdb554 2019-04-11 stsp const struct got_error *got_object_get_path(char **, struct got_object_id *,
100 90bdb554 2019-04-11 stsp struct got_repository *);
101 762d73f4 2021-04-10 stsp const struct got_error *got_object_open_loose_fd(int *, struct got_object_id *,
102 762d73f4 2021-04-10 stsp struct got_repository *);
103 b3d68e7f 2021-07-03 stsp const struct got_error *got_object_open_packed(struct got_object **,
104 b3d68e7f 2021-07-03 stsp struct got_object_id *, struct got_repository *);
105 b3d68e7f 2021-07-03 stsp const struct got_error *got_object_read_header_privsep(struct got_object **,
106 d5c81d44 2021-07-08 stsp struct got_object_id *, struct got_repository *, int);
107 15a94983 2018-12-23 stsp const struct got_error *got_object_open(struct got_object **,
108 15a94983 2018-12-23 stsp struct got_repository *, struct got_object_id *);
109 59d1e4a0 2021-03-10 stsp const struct got_error *got_object_raw_open(struct got_raw_object **,
110 59d1e4a0 2021-03-10 stsp struct got_repository *, struct got_object_id *, size_t);
111 59d1e4a0 2021-03-10 stsp void got_object_raw_rewind(struct got_raw_object *);
112 59d1e4a0 2021-03-10 stsp size_t got_object_raw_get_hdrlen(struct got_raw_object *);
113 59d1e4a0 2021-03-10 stsp const uint8_t *got_object_raw_get_read_buf(struct got_raw_object *);
114 59d1e4a0 2021-03-10 stsp const struct got_error * got_object_raw_read_block(size_t *,
115 59d1e4a0 2021-03-10 stsp struct got_raw_object *);
116 59d1e4a0 2021-03-10 stsp const struct got_error *got_object_raw_close(struct got_raw_object *);
117 15a94983 2018-12-23 stsp const struct got_error *got_object_open_by_id_str(struct got_object **,
118 15a94983 2018-12-23 stsp struct got_repository *, const char *);
119 15a94983 2018-12-23 stsp void got_object_close(struct got_object *);
120 15a94983 2018-12-23 stsp const struct got_error *got_object_commit_open(struct got_commit_object **,
121 15a94983 2018-12-23 stsp struct got_repository *, struct got_object *);
122 15a94983 2018-12-23 stsp const struct got_error *got_object_tree_open(struct got_tree_object **,
123 15a94983 2018-12-23 stsp struct got_repository *, struct got_object *);
124 15a94983 2018-12-23 stsp const struct got_error *got_object_blob_open(struct got_blob_object **,
125 15a94983 2018-12-23 stsp struct got_repository *, struct got_object *, size_t);
126 ddf1c734 2018-12-23 stsp char *got_object_blob_id_str(struct got_blob_object*, char *, size_t);
127 15a94983 2018-12-23 stsp const struct got_error *got_object_tag_open(struct got_tag_object **,
128 15a94983 2018-12-23 stsp struct got_repository *, struct got_object *);
129 ed175427 2019-05-09 stsp const struct got_error *got_object_tree_entry_dup(struct got_tree_entry **,
130 ed175427 2019-05-09 stsp struct got_tree_entry *);
131 ca6e02ac 2020-01-07 stsp
132 ca6e02ac 2020-01-07 stsp const struct got_error *got_traverse_packed_commits(
133 ca6e02ac 2020-01-07 stsp struct got_object_id_queue *, struct got_object_id *, const char *,
134 ca6e02ac 2020-01-07 stsp struct got_repository *);