Blame


1 7b19e0f1 2017-11-05 stsp /*
2 5aa81393 2020-01-06 stsp * Copyright (c) 2018, 2019, 2020 Stefan Sperling <stsp@openbsd.org>
3 93658fb9 2020-03-18 stsp * Copyright (c) 2020 Ori Bernstein <ori@openbsd.org>
4 7b19e0f1 2017-11-05 stsp *
5 7b19e0f1 2017-11-05 stsp * Permission to use, copy, modify, and distribute this software for any
6 7b19e0f1 2017-11-05 stsp * purpose with or without fee is hereby granted, provided that the above
7 7b19e0f1 2017-11-05 stsp * copyright notice and this permission notice appear in all copies.
8 7b19e0f1 2017-11-05 stsp *
9 7b19e0f1 2017-11-05 stsp * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 7b19e0f1 2017-11-05 stsp * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 7b19e0f1 2017-11-05 stsp * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 7b19e0f1 2017-11-05 stsp * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 7b19e0f1 2017-11-05 stsp * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 7b19e0f1 2017-11-05 stsp * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 7b19e0f1 2017-11-05 stsp * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 7b19e0f1 2017-11-05 stsp */
17 dd038bc6 2021-09-21 thomas.ad
18 dd038bc6 2021-09-21 thomas.ad #include "got_compat.h"
19 4027f31a 2017-11-04 stsp
20 4027f31a 2017-11-04 stsp /* Error codes */
21 0a585a0d 2018-03-17 stsp #define GOT_ERR_OK 0
22 0a585a0d 2018-03-17 stsp #define GOT_ERR_ERRNO 1
23 a1fd68d8 2018-01-12 stsp #define GOT_ERR_NOT_GIT_REPO 2
24 f7b97ccb 2020-04-14 stsp #define GOT_ERR_BAD_FILETYPE 3
25 a1fd68d8 2018-01-12 stsp #define GOT_ERR_BAD_PATH 4
26 a1fd68d8 2018-01-12 stsp #define GOT_ERR_NOT_REF 5
27 a1fd68d8 2018-01-12 stsp #define GOT_ERR_IO 6
28 a1fd68d8 2018-01-12 stsp #define GOT_ERR_EOF 7
29 a1fd68d8 2018-01-12 stsp #define GOT_ERR_DECOMPRESSION 8
30 a1fd68d8 2018-01-12 stsp #define GOT_ERR_NO_SPACE 9
31 a1fd68d8 2018-01-12 stsp #define GOT_ERR_BAD_OBJ_HDR 10
32 a1fd68d8 2018-01-12 stsp #define GOT_ERR_OBJ_TYPE 11
33 a1fd68d8 2018-01-12 stsp #define GOT_ERR_BAD_OBJ_DATA 12
34 e09a504c 2019-06-28 stsp #define GOT_ERR_AMBIGUOUS_ID 13
35 a1fd68d8 2018-01-12 stsp #define GOT_ERR_BAD_PACKIDX 14
36 a1fd68d8 2018-01-12 stsp #define GOT_ERR_PACKIDX_CSUM 15
37 a1fd68d8 2018-01-12 stsp #define GOT_ERR_BAD_PACKFILE 16
38 a1fd68d8 2018-01-12 stsp #define GOT_ERR_NO_OBJ 17
39 a487c1d0 2018-01-14 stsp #define GOT_ERR_NOT_IMPL 18
40 3ee5fc21 2018-01-17 stsp #define GOT_ERR_OBJ_NOT_PACKED 19
41 96f5e8b3 2018-01-23 stsp #define GOT_ERR_BAD_DELTA_CHAIN 20
42 885d3e02 2018-01-27 stsp #define GOT_ERR_BAD_DELTA 21
43 885d3e02 2018-01-27 stsp #define GOT_ERR_COMPRESSION 22
44 59ece79d 2018-02-12 stsp #define GOT_ERR_BAD_OBJ_ID_STR 23
45 86c3caaf 2018-03-09 stsp #define GOT_ERR_WORKTREE_EXISTS 26
46 09fe317a 2018-03-11 stsp #define GOT_ERR_WORKTREE_META 27
47 6d9d28c3 2018-03-11 stsp #define GOT_ERR_WORKTREE_VERS 28
48 6d9d28c3 2018-03-11 stsp #define GOT_ERR_WORKTREE_BUSY 29
49 9d31a1d8 2018-03-11 stsp #define GOT_ERR_DIR_OBSTRUCTED 30
50 9d31a1d8 2018-03-11 stsp #define GOT_ERR_FILE_OBSTRUCTED 31
51 5b7e13a7 2018-04-02 stsp #define GOT_ERR_RECURSION 32
52 2178c42e 2018-04-22 stsp #define GOT_ERR_TIMEOUT 33
53 2178c42e 2018-04-22 stsp #define GOT_ERR_INTERRUPT 34
54 2178c42e 2018-04-22 stsp #define GOT_ERR_PRIVSEP_READ 35
55 2178c42e 2018-04-22 stsp #define GOT_ERR_PRIVSEP_LEN 36
56 2178c42e 2018-04-22 stsp #define GOT_ERR_PRIVSEP_PIPE 37
57 2178c42e 2018-04-22 stsp #define GOT_ERR_PRIVSEP_NO_FD 38
58 8c580685 2018-04-22 stsp #define GOT_ERR_PRIVSEP_MSG 39
59 b419fc47 2018-04-26 stsp #define GOT_ERR_PRIVSEP_DIED 40
60 b419fc47 2018-04-26 stsp #define GOT_ERR_PRIVSEP_EXIT 41
61 0c048b15 2018-04-27 stsp #define GOT_ERR_PACK_OFFSET 42
62 54be8251 2018-06-04 stsp #define GOT_ERR_OBJ_EXISTS 43
63 54be8251 2018-06-04 stsp #define GOT_ERR_BAD_OBJ_ID 44
64 3d509237 2020-01-04 stsp #define GOT_ERR_ITER_BUSY 45
65 9ba79e04 2018-06-11 stsp #define GOT_ERR_ITER_COMPLETED 46
66 730c718b 2018-06-21 stsp #define GOT_ERR_RANGE 47
67 89817b30 2018-11-11 stsp #define GOT_ERR_EXPECTED 48 /* for use in regress tests only */
68 99437157 2018-11-11 stsp #define GOT_ERR_CANCELLED 49
69 d1451975 2018-11-11 stsp #define GOT_ERR_NO_TREE_ENTRY 50
70 52a74475 2018-12-24 stsp #define GOT_ERR_FILEIDX_SIG 51
71 52a74475 2018-12-24 stsp #define GOT_ERR_FILEIDX_VER 52
72 52a74475 2018-12-24 stsp #define GOT_ERR_FILEIDX_CSUM 53
73 49520a32 2018-12-29 stsp #define GOT_ERR_PATH_PREFIX 54
74 be7061eb 2018-12-30 stsp #define GOT_ERR_ANCESTRY 55
75 27793341 2019-01-12 stsp #define GOT_ERR_FILEIDX_BAD 56
76 a808cfa5 2019-02-03 stsp #define GOT_ERR_BAD_REF_DATA 57
77 f5d3d7af 2019-02-05 stsp #define GOT_ERR_TREE_DUP_ENTRY 58
78 f5d3d7af 2019-02-05 stsp #define GOT_ERR_DIR_DUP_ENTRY 59
79 247140b2 2019-02-05 stsp #define GOT_ERR_NOT_WORKTREE 60
80 09589288 2019-03-10 stsp #define GOT_ERR_UUID_VERSION 61
81 09589288 2019-03-10 stsp #define GOT_ERR_UUID_INVALID 62
82 09589288 2019-03-10 stsp #define GOT_ERR_UUID 63
83 01b7ba6b 2019-03-11 stsp #define GOT_ERR_LOCKFILE_TIMEOUT 64
84 f77a24b0 2019-03-11 stsp #define GOT_ERR_BAD_REF_NAME 65
85 0c48fee2 2019-03-11 stsp #define GOT_ERR_WORKTREE_REPO 66
86 2ec1f75b 2019-03-26 stsp #define GOT_ERR_FILE_MODIFIED 67
87 2ec1f75b 2019-03-26 stsp #define GOT_ERR_FILE_STATUS 68
88 c4296144 2019-05-09 stsp #define GOT_ERR_COMMIT_CONFLICT 69
89 b249b824 2019-05-09 stsp #define GOT_ERR_BAD_REF_TYPE 70
90 35bd8fed 2019-05-09 stsp #define GOT_ERR_COMMIT_NO_AUTHOR 71
91 09f5bd90 2019-05-09 stsp #define GOT_ERR_COMMIT_HEAD_CHANGED 72
92 819f385b 2019-05-10 stsp #define GOT_ERR_COMMIT_OUT_OF_DATE 73
93 33ad4cbe 2019-05-12 jcs #define GOT_ERR_COMMIT_MSG_EMPTY 74
94 33ad4cbe 2019-05-12 jcs #define GOT_ERR_DIR_NOT_EMPTY 75
95 33ad4cbe 2019-05-12 jcs #define GOT_ERR_COMMIT_NO_CHANGES 76
96 a367ff0f 2019-05-14 stsp #define GOT_ERR_BRANCH_MOVED 77
97 79c99a64 2019-05-23 stsp #define GOT_ERR_OBJ_TOO_LARGE 78
98 234035bc 2019-06-01 stsp #define GOT_ERR_SAME_BRANCH 79
99 5ef14e63 2019-06-02 stsp #define GOT_ERR_ROOT_COMMIT 80
100 234035bc 2019-06-01 stsp #define GOT_ERR_MIXED_COMMITS 81
101 234035bc 2019-06-01 stsp #define GOT_ERR_CONFLICTS 82
102 4e759de4 2019-06-26 stsp #define GOT_ERR_BRANCH_EXISTS 83
103 818c7501 2019-07-11 stsp #define GOT_ERR_MODIFIED 84
104 818c7501 2019-07-11 stsp #define GOT_ERR_NOT_REBASING 85
105 818c7501 2019-07-11 stsp #define GOT_ERR_EMPTY_REBASE 86
106 818c7501 2019-07-11 stsp #define GOT_ERR_REBASE_COMMITID 87
107 7d5807f4 2019-07-11 stsp #define GOT_ERR_REBASING 88
108 64c6d990 2019-07-11 stsp #define GOT_ERR_REBASE_PATH 89
109 0ebf8283 2019-07-24 stsp #define GOT_ERR_NOT_HISTEDIT 90
110 0ebf8283 2019-07-24 stsp #define GOT_ERR_EMPTY_HISTEDIT 91
111 0ebf8283 2019-07-24 stsp #define GOT_ERR_NO_HISTEDIT_CMD 92
112 0ebf8283 2019-07-24 stsp #define GOT_ERR_HISTEDIT_SYNTAX 93
113 0ebf8283 2019-07-24 stsp #define GOT_ERR_HISTEDIT_CANCEL 94
114 de05890f 2020-03-05 stsp /* 95 is currently unused */
115 0ebf8283 2019-07-24 stsp #define GOT_ERR_HISTEDIT_BUSY 96
116 0ebf8283 2019-07-24 stsp #define GOT_ERR_HISTEDIT_CMD 97
117 8ca9bd68 2019-07-25 stsp #define GOT_ERR_HISTEDIT_PATH 98
118 678ade17 2020-03-22 stsp /* 99 is currently unused */
119 916f288c 2019-07-30 stsp #define GOT_ERR_COMMIT_BRANCH 100
120 9acbc4fa 2019-08-03 stsp #define GOT_ERR_FILE_STAGED 101
121 d3e7c587 2019-08-03 stsp #define GOT_ERR_STAGE_NO_CHANGE 102
122 ebf48fd5 2019-08-03 stsp #define GOT_ERR_STAGE_CONFLICT 103
123 735ef5ac 2019-08-03 stsp #define GOT_ERR_STAGE_OUT_OF_DATE 104
124 f0b75401 2019-08-03 stsp #define GOT_ERR_FILE_NOT_STAGED 105
125 f032f1f7 2019-08-04 stsp #define GOT_ERR_STAGED_PATHS 106
126 dc424a06 2019-08-07 stsp #define GOT_ERR_PATCH_CHOICE 107
127 84792843 2019-08-09 stsp #define GOT_ERR_COMMIT_NO_EMAIL 108
128 8e7bd50a 2019-08-22 stsp #define GOT_ERR_TAG_EXISTS 109
129 aba9c984 2019-09-08 stsp #define GOT_ERR_GIT_REPO_FORMAT 110
130 2822a352 2019-10-15 stsp #define GOT_ERR_REBASE_REQUIRED 111
131 6d17833f 2019-11-08 stsp #define GOT_ERR_REGEX 112
132 bd5895f3 2019-11-28 stsp #define GOT_ERR_REF_NAME_MINUS 113
133 cd95becd 2019-11-29 stsp #define GOT_ERR_GITCONFIG_SYNTAX 114
134 abd4a1be 2020-03-18 stsp #define GOT_ERR_REBASE_OUT_OF_DATE 115
135 abd4a1be 2020-03-18 stsp #define GOT_ERR_CACHE_DUP_ENTRY 116
136 abd4a1be 2020-03-18 stsp #define GOT_ERR_QUERYSTRING 117
137 abd4a1be 2020-03-18 stsp #define GOT_ERR_FETCH_FAILED 118
138 abd4a1be 2020-03-18 stsp #define GOT_ERR_PARSE_URI 119
139 abd4a1be 2020-03-18 stsp #define GOT_ERR_BAD_PROTO 120
140 5cc27ede 2020-03-18 stsp #define GOT_ERR_ADDRINFO 121
141 fe53745c 2020-03-18 stsp #define GOT_ERR_BAD_PACKET 122
142 7848a0e1 2020-03-19 stsp #define GOT_ERR_NO_REMOTE 123
143 659e7fbd 2020-03-20 stsp #define GOT_ERR_FETCH_NO_BRANCH 124
144 0e4002ca 2020-03-21 stsp #define GOT_ERR_FETCH_BAD_REF 125
145 0d6c6ee3 2020-05-20 stsp #define GOT_ERR_TREE_ENTRY_TYPE 126
146 257add31 2020-09-09 stsp #define GOT_ERR_PARSE_CONFIG 127
147 fb863fa4 2020-06-22 tracey #define GOT_ERR_NO_CONFIG_FILE 128
148 35213c7c 2020-07-23 stsp #define GOT_ERR_BAD_SYMLINK 129
149 20b7abb3 2020-10-22 stsp #define GOT_ERR_GIT_REPO_EXT 130
150 05118f5a 2021-06-22 stsp #define GOT_ERR_CANNOT_PACK 131
151 1124fe40 2021-07-07 stsp #define GOT_ERR_LONELY_PACKIDX 132
152 d5c81d44 2021-07-08 stsp #define GOT_ERR_OBJ_CSUM 133
153 f8a36e22 2021-08-26 stsp #define GOT_ERR_SEND_BAD_REF 134
154 f8a36e22 2021-08-26 stsp #define GOT_ERR_SEND_FAILED 135
155 f8a36e22 2021-08-26 stsp #define GOT_ERR_SEND_EMPTY 136
156 f8a36e22 2021-08-26 stsp #define GOT_ERR_SEND_ANCESTRY 137
157 f8a36e22 2021-08-26 stsp #define GOT_ERR_CAPA_DELETE_REFS 138
158 f8a36e22 2021-08-26 stsp #define GOT_ERR_SEND_DELETE_REF 139
159 f8a36e22 2021-08-26 stsp #define GOT_ERR_SEND_TAG_EXISTS 140
160 10604dce 2021-09-24 thomas #define GOT_ERR_NOT_MERGING 141
161 10604dce 2021-09-24 thomas #define GOT_ERR_MERGE_OUT_OF_DATE 142
162 10604dce 2021-09-24 thomas #define GOT_ERR_MERGE_STAGED_PATHS 143
163 10604dce 2021-09-24 thomas #define GOT_ERR_MERGE_COMMIT_OUT_OF_DATE 143
164 10604dce 2021-09-24 thomas #define GOT_ERR_MERGE_BUSY 144
165 10604dce 2021-09-24 thomas #define GOT_ERR_MERGE_PATH 145
166 24f136e0 2021-11-20 thomas #define GOT_ERR_FILE_BINARY 146
167 069bbb86 2022-03-07 thomas #define GOT_ERR_PATCH_MALFORMED 147
168 069bbb86 2022-03-07 thomas #define GOT_ERR_PATCH_TRUNCATED 148
169 069bbb86 2022-03-07 thomas #define GOT_ERR_PATCH_DONT_APPLY 149
170 bb2ad8ff 2022-03-13 thomas #define GOT_ERR_NO_PATCH 150
171 4027f31a 2017-11-04 stsp
172 4027f31a 2017-11-04 stsp static const struct got_error {
173 4027f31a 2017-11-04 stsp int code;
174 4027f31a 2017-11-04 stsp const char *msg;
175 4027f31a 2017-11-04 stsp } got_errors[] = {
176 0a585a0d 2018-03-17 stsp { GOT_ERR_OK, "no error occured?!?" },
177 f334529e 2018-01-12 stsp { GOT_ERR_ERRNO, "see errno" },
178 4027f31a 2017-11-04 stsp { GOT_ERR_NOT_GIT_REPO, "no git repository found" },
179 f7b97ccb 2020-04-14 stsp { GOT_ERR_BAD_FILETYPE, "bad file type" },
180 4027f31a 2017-11-04 stsp { GOT_ERR_BAD_PATH, "bad path" },
181 4027f31a 2017-11-04 stsp { GOT_ERR_NOT_REF, "no such reference found" },
182 ab9a70b2 2017-11-06 stsp { GOT_ERR_IO, "input/output error" },
183 ab9a70b2 2017-11-06 stsp { GOT_ERR_EOF, "unexpected end of file" },
184 ab9a70b2 2017-11-06 stsp { GOT_ERR_DECOMPRESSION,"decompression failed" },
185 ab9a70b2 2017-11-06 stsp { GOT_ERR_NO_SPACE, "buffer too small" },
186 ab9a70b2 2017-11-06 stsp { GOT_ERR_BAD_OBJ_HDR, "bad object header" },
187 d1cda826 2017-11-06 stsp { GOT_ERR_OBJ_TYPE, "wrong type of object" },
188 d1cda826 2017-11-06 stsp { GOT_ERR_BAD_OBJ_DATA, "bad object data" },
189 e09a504c 2019-06-28 stsp { GOT_ERR_AMBIGUOUS_ID, "ambiguous object ID" },
190 0a0a3048 2018-01-10 stsp { GOT_ERR_BAD_PACKIDX, "bad pack index file" },
191 0ebaf008 2018-01-10 stsp { GOT_ERR_PACKIDX_CSUM, "pack index file checksum error" },
192 a1fd68d8 2018-01-12 stsp { GOT_ERR_BAD_PACKFILE, "bad pack file" },
193 a1fd68d8 2018-01-12 stsp { GOT_ERR_NO_OBJ, "object not found" },
194 a487c1d0 2018-01-14 stsp { GOT_ERR_NOT_IMPL, "feature not implemented" },
195 3ee5fc21 2018-01-17 stsp { GOT_ERR_OBJ_NOT_PACKED,"object is not packed" },
196 96f5e8b3 2018-01-23 stsp { GOT_ERR_BAD_DELTA_CHAIN,"bad delta chain" },
197 59ece79d 2018-02-12 stsp { GOT_ERR_BAD_DELTA, "bad delta" },
198 59ece79d 2018-02-12 stsp { GOT_ERR_COMPRESSION, "compression failed" },
199 59ece79d 2018-02-12 stsp { GOT_ERR_BAD_OBJ_ID_STR,"bad object id string" },
200 86c3caaf 2018-03-09 stsp { GOT_ERR_WORKTREE_EXISTS,"worktree already exists" },
201 09fe317a 2018-03-11 stsp { GOT_ERR_WORKTREE_META,"bad worktree meta data" },
202 6d9d28c3 2018-03-11 stsp { GOT_ERR_WORKTREE_VERS,"unsupported worktree format version" },
203 6d9d28c3 2018-03-11 stsp { GOT_ERR_WORKTREE_BUSY,"worktree already locked" },
204 95edb37e 2019-03-28 stsp { GOT_ERR_FILE_OBSTRUCTED,"file is obstructed" },
205 5b7e13a7 2018-04-02 stsp { GOT_ERR_RECURSION, "recursion limit reached" },
206 2178c42e 2018-04-22 stsp { GOT_ERR_TIMEOUT, "operation timed out" },
207 2178c42e 2018-04-22 stsp { GOT_ERR_INTERRUPT, "operation interrupted" },
208 55afbf19 2018-09-08 stsp { GOT_ERR_PRIVSEP_READ, "no data received in imsg" },
209 55afbf19 2018-09-08 stsp { GOT_ERR_PRIVSEP_LEN, "unexpected amount of data received in imsg" },
210 55afbf19 2018-09-08 stsp { GOT_ERR_PRIVSEP_PIPE, "privsep peer process closed pipe" },
211 55afbf19 2018-09-08 stsp { GOT_ERR_PRIVSEP_NO_FD,"privsep file descriptor unavailable" },
212 4c838a52 2018-12-23 stsp { GOT_ERR_PRIVSEP_MSG, "received unexpected privsep message" },
213 54be8251 2018-06-04 stsp { GOT_ERR_PRIVSEP_DIED, "unprivileged process died unexpectedly" },
214 54be8251 2018-06-04 stsp { GOT_ERR_PRIVSEP_EXIT, "bad exit code from unprivileged process" },
215 54be8251 2018-06-04 stsp { GOT_ERR_PACK_OFFSET, "bad offset in pack file" },
216 54be8251 2018-06-04 stsp { GOT_ERR_OBJ_EXISTS, "object already exists" },
217 54be8251 2018-06-04 stsp { GOT_ERR_BAD_OBJ_ID, "bad object id" },
218 3d509237 2020-01-04 stsp { GOT_ERR_ITER_BUSY, "iteration already in progress" },
219 9ba79e04 2018-06-11 stsp { GOT_ERR_ITER_COMPLETED,"iteration completed" },
220 730c718b 2018-06-21 stsp { GOT_ERR_RANGE, "value out of range" },
221 89817b30 2018-11-11 stsp { GOT_ERR_EXPECTED, "expected an error but have no error" },
222 99437157 2018-11-11 stsp { GOT_ERR_CANCELLED, "operation in progress has been cancelled" },
223 d1451975 2018-11-11 stsp { GOT_ERR_NO_TREE_ENTRY,"no such entry found in tree" },
224 52a74475 2018-12-24 stsp { GOT_ERR_FILEIDX_SIG, "bad file index signature" },
225 52a74475 2018-12-24 stsp { GOT_ERR_FILEIDX_VER, "unknown file index format version" },
226 52a74475 2018-12-24 stsp { GOT_ERR_FILEIDX_CSUM, "bad file index checksum" },
227 49520a32 2018-12-29 stsp { GOT_ERR_PATH_PREFIX, "worktree already contains items from a "
228 49520a32 2018-12-29 stsp "different path prefix" },
229 a367ff0f 2019-05-14 stsp { GOT_ERR_ANCESTRY, "target commit is on a different branch" },
230 27793341 2019-01-12 stsp { GOT_ERR_FILEIDX_BAD, "file index is corrupt" },
231 a808cfa5 2019-02-03 stsp { GOT_ERR_BAD_REF_DATA, "could not parse reference data" },
232 f5d3d7af 2019-02-05 stsp { GOT_ERR_TREE_DUP_ENTRY,"duplicate entry in tree object" },
233 f5d3d7af 2019-02-05 stsp { GOT_ERR_DIR_DUP_ENTRY,"duplicate entry in directory" },
234 247140b2 2019-02-05 stsp { GOT_ERR_NOT_WORKTREE, "no got work tree found" },
235 09589288 2019-03-10 stsp { GOT_ERR_UUID_VERSION, "bad uuid version" },
236 09589288 2019-03-10 stsp { GOT_ERR_UUID_INVALID, "uuid invalid" },
237 09589288 2019-03-10 stsp { GOT_ERR_UUID, "uuid error" },
238 01b7ba6b 2019-03-11 stsp { GOT_ERR_LOCKFILE_TIMEOUT,"lockfile timeout" },
239 f77a24b0 2019-03-11 stsp { GOT_ERR_BAD_REF_NAME, "bad reference name" },
240 0c48fee2 2019-03-11 stsp { GOT_ERR_WORKTREE_REPO,"cannot create worktree inside a git repository" },
241 2ec1f75b 2019-03-26 stsp { GOT_ERR_FILE_MODIFIED,"file contains modifications" },
242 2ec1f75b 2019-03-26 stsp { GOT_ERR_FILE_STATUS, "file has unexpected status" },
243 c4296144 2019-05-09 stsp { GOT_ERR_COMMIT_CONFLICT,"cannot commit file in conflicted status" },
244 b249b824 2019-05-09 stsp { GOT_ERR_BAD_REF_TYPE, "bad reference type" },
245 35bd8fed 2019-05-09 stsp { GOT_ERR_COMMIT_NO_AUTHOR,"GOT_AUTHOR environment variable is not set" },
246 09f5bd90 2019-05-09 stsp { GOT_ERR_COMMIT_HEAD_CHANGED, "branch head in repository has changed "
247 09f5bd90 2019-05-09 stsp "while commit was in progress" },
248 819f385b 2019-05-10 stsp { GOT_ERR_COMMIT_OUT_OF_DATE, "work tree must be updated before these "
249 819f385b 2019-05-10 stsp "changes can be committed" },
250 33ad4cbe 2019-05-12 jcs { GOT_ERR_COMMIT_MSG_EMPTY, "commit message cannot be empty" },
251 196d54c7 2019-05-15 stsp { GOT_ERR_DIR_NOT_EMPTY, "directory exists and is not empty" },
252 33ad4cbe 2019-05-12 jcs { GOT_ERR_COMMIT_NO_CHANGES, "no changes to commit" },
253 a1fb16d8 2019-05-24 stsp { GOT_ERR_BRANCH_MOVED, "work tree's head reference now points to a "
254 a1fb16d8 2019-05-24 stsp "different branch; new head reference and/or update -b required" },
255 79c99a64 2019-05-23 stsp { GOT_ERR_OBJ_TOO_LARGE, "object too large" },
256 234035bc 2019-06-01 stsp { GOT_ERR_SAME_BRANCH, "commit is already contained in this branch" },
257 5ef14e63 2019-06-02 stsp { GOT_ERR_ROOT_COMMIT, "specified commit has no parent commit" },
258 234035bc 2019-06-01 stsp { GOT_ERR_MIXED_COMMITS,"work tree contains files from multiple "
259 234035bc 2019-06-01 stsp "base commits; the entire work tree must be updated first" },
260 234035bc 2019-06-01 stsp { GOT_ERR_CONFLICTS, "work tree contains conflicted files; these "
261 234035bc 2019-06-01 stsp "conflicts must be resolved first" },
262 4e759de4 2019-06-26 stsp { GOT_ERR_BRANCH_EXISTS,"specified branch already exists" },
263 818c7501 2019-07-11 stsp { GOT_ERR_MODIFIED, "work tree contains local changes; these "
264 818c7501 2019-07-11 stsp "changes must be committed or reverted first" },
265 818c7501 2019-07-11 stsp { GOT_ERR_NOT_REBASING, "rebase operation not in progress" },
266 818c7501 2019-07-11 stsp { GOT_ERR_EMPTY_REBASE, "no commits to rebase" },
267 818c7501 2019-07-11 stsp { GOT_ERR_REBASE_COMMITID,"rebase commit ID mismatch" },
268 7d5807f4 2019-07-11 stsp { GOT_ERR_REBASING, "a rebase operation is in progress in this "
269 7d5807f4 2019-07-11 stsp "work tree and must be continued or aborted first" },
270 64c6d990 2019-07-11 stsp { GOT_ERR_REBASE_PATH, "cannot rebase branch which contains "
271 64c6d990 2019-07-11 stsp "changes outside of this work tree's path prefix" },
272 0ebf8283 2019-07-24 stsp { GOT_ERR_NOT_HISTEDIT, "histedit operation not in progress" },
273 ff6aa206 2019-07-25 stsp { GOT_ERR_EMPTY_HISTEDIT,"no commits to edit; perhaps the work tree "
274 ff6aa206 2019-07-25 stsp "must be updated to an older commit first" },
275 0ebf8283 2019-07-24 stsp { GOT_ERR_NO_HISTEDIT_CMD,"no histedit commands provided" },
276 0ebf8283 2019-07-24 stsp { GOT_ERR_HISTEDIT_SYNTAX,"syntax error in histedit command list" },
277 0ebf8283 2019-07-24 stsp { GOT_ERR_HISTEDIT_CANCEL,"histedit operation cancelled" },
278 de05890f 2020-03-05 stsp { 95, "unused error code" },
279 0ebf8283 2019-07-24 stsp { GOT_ERR_HISTEDIT_BUSY,"histedit operation is in progress in this "
280 0ebf8283 2019-07-24 stsp "work tree and must be continued or aborted first" },
281 0ebf8283 2019-07-24 stsp { GOT_ERR_HISTEDIT_CMD, "bad histedit command" },
282 8ca9bd68 2019-07-25 stsp { GOT_ERR_HISTEDIT_PATH, "cannot edit branch history which contains "
283 8ca9bd68 2019-07-25 stsp "changes outside of this work tree's path prefix" },
284 678ade17 2020-03-22 stsp { 99, "unused error code" },
285 916f288c 2019-07-30 stsp { GOT_ERR_COMMIT_BRANCH, "will not commit to a branch outside the "
286 916f288c 2019-07-30 stsp "\"refs/heads/\" reference namespace" },
287 24278f30 2019-08-03 stsp { GOT_ERR_FILE_STAGED, "file is staged" },
288 d3e7c587 2019-08-03 stsp { GOT_ERR_STAGE_NO_CHANGE, "no changes to stage" },
289 ebf48fd5 2019-08-03 stsp { GOT_ERR_STAGE_CONFLICT, "cannot stage file in conflicted status" },
290 735ef5ac 2019-08-03 stsp { GOT_ERR_STAGE_OUT_OF_DATE, "work tree must be updated before "
291 735ef5ac 2019-08-03 stsp "changes can be staged" },
292 f0b75401 2019-08-03 stsp { GOT_ERR_FILE_NOT_STAGED, "file is not staged" },
293 f032f1f7 2019-08-04 stsp { GOT_ERR_STAGED_PATHS, "work tree contains files with staged "
294 f032f1f7 2019-08-04 stsp "changes; these changes must be committed or unstaged first" },
295 dc424a06 2019-08-07 stsp { GOT_ERR_PATCH_CHOICE, "invalid patch choice" },
296 17431c13 2022-02-12 thomas { GOT_ERR_COMMIT_NO_EMAIL, "commit author's email address is required "
297 17431c13 2022-02-12 thomas "for compatibility with Git" },
298 8e7bd50a 2019-08-22 stsp { GOT_ERR_TAG_EXISTS,"specified tag already exists" },
299 aba9c984 2019-09-08 stsp { GOT_ERR_GIT_REPO_FORMAT,"unknown git repository format version" },
300 2822a352 2019-10-15 stsp { GOT_ERR_REBASE_REQUIRED,"specified branch must be rebased first" },
301 6d17833f 2019-11-08 stsp { GOT_ERR_REGEX, "regular expression error" },
302 bd5895f3 2019-11-28 stsp { GOT_ERR_REF_NAME_MINUS, "reference name may not start with '-'" },
303 cd95becd 2019-11-29 stsp { GOT_ERR_GITCONFIG_SYNTAX, "gitconfig syntax error" },
304 e51d7b55 2020-01-04 stsp { GOT_ERR_REBASE_OUT_OF_DATE, "work tree must be updated before it "
305 e51d7b55 2020-01-04 stsp "can be used to rebase a branch" },
306 e1a68182 2020-01-07 stsp { GOT_ERR_CACHE_DUP_ENTRY, "duplicate cache entry" },
307 9f33591a 2020-02-14 tracey { GOT_ERR_QUERYSTRING, "bad querystring" },
308 93658fb9 2020-03-18 stsp { GOT_ERR_FETCH_FAILED, "fetch failed" },
309 93658fb9 2020-03-18 stsp { GOT_ERR_PARSE_URI, "failed to parse uri" },
310 93658fb9 2020-03-18 stsp { GOT_ERR_BAD_PROTO, "unknown protocol" },
311 5cc27ede 2020-03-18 stsp { GOT_ERR_ADDRINFO, "getaddrinfo failed" },
312 fe53745c 2020-03-18 stsp { GOT_ERR_BAD_PACKET, "bad packet received" },
313 7848a0e1 2020-03-19 stsp { GOT_ERR_NO_REMOTE, "remote repository not found" },
314 659e7fbd 2020-03-20 stsp { GOT_ERR_FETCH_NO_BRANCH, "could not find any branches to fetch" },
315 0e4002ca 2020-03-21 stsp { GOT_ERR_FETCH_BAD_REF, "reference cannot be fetched" },
316 0d6c6ee3 2020-05-20 stsp { GOT_ERR_TREE_ENTRY_TYPE, "unexpected tree entry type" },
317 257add31 2020-09-09 stsp { GOT_ERR_PARSE_CONFIG, "configuration file syntax error" },
318 fb863fa4 2020-06-22 tracey { GOT_ERR_NO_CONFIG_FILE, "configuration file doesn't exit" },
319 35213c7c 2020-07-23 stsp { GOT_ERR_BAD_SYMLINK, "symbolic link points outside of paths under "
320 35213c7c 2020-07-23 stsp "version control" },
321 20b7abb3 2020-10-22 stsp { GOT_ERR_GIT_REPO_EXT, "unsupported repository format extension" },
322 05118f5a 2021-06-22 stsp { GOT_ERR_CANNOT_PACK, "not enough objects to pack" },
323 6843859a 2021-07-09 stsp { GOT_ERR_LONELY_PACKIDX, "pack index has no corresponding pack file; "
324 6843859a 2021-07-09 stsp "pack file must be restored or 'gotadmin cleanup -p' must be run" },
325 d5c81d44 2021-07-08 stsp { GOT_ERR_OBJ_CSUM, "bad object checksum" },
326 f8a36e22 2021-08-26 stsp { GOT_ERR_SEND_BAD_REF, "reference cannot be sent" },
327 f8a36e22 2021-08-26 stsp { GOT_ERR_SEND_FAILED, "could not send pack file" },
328 f8a36e22 2021-08-26 stsp { GOT_ERR_SEND_EMPTY, "no references to send" },
329 f8a36e22 2021-08-26 stsp { GOT_ERR_SEND_ANCESTRY, "fetch and rebase required" },
330 f8a36e22 2021-08-26 stsp { GOT_ERR_CAPA_DELETE_REFS, "server cannot delete references" },
331 f8a36e22 2021-08-26 stsp { GOT_ERR_SEND_DELETE_REF, "reference cannot be deleted" },
332 f8a36e22 2021-08-26 stsp { GOT_ERR_SEND_TAG_EXISTS, "tag already exists on server" },
333 10604dce 2021-09-24 thomas { GOT_ERR_NOT_MERGING, "merge operation not in progress" },
334 10604dce 2021-09-24 thomas { GOT_ERR_MERGE_OUT_OF_DATE, "work tree must be updated before it "
335 10604dce 2021-09-24 thomas "can be used to merge a branch" },
336 10604dce 2021-09-24 thomas { GOT_ERR_MERGE_STAGED_PATHS, "work tree contains files with staged "
337 10604dce 2021-09-24 thomas "changes; these changes must be unstaged before merging can "
338 10604dce 2021-09-24 thomas "proceed" },
339 10604dce 2021-09-24 thomas { GOT_ERR_MERGE_COMMIT_OUT_OF_DATE, "merging cannot proceed because "
340 10604dce 2021-09-24 thomas "the work tree is no longer up-to-date; merge must be aborted "
341 10604dce 2021-09-24 thomas "and retried" },
342 10604dce 2021-09-24 thomas { GOT_ERR_MERGE_BUSY,"a merge operation is in progress in this "
343 10604dce 2021-09-24 thomas "work tree and must be continued or aborted first" },
344 10604dce 2021-09-24 thomas { GOT_ERR_MERGE_PATH, "cannot merge branch which contains "
345 10604dce 2021-09-24 thomas "changes outside of this work tree's path prefix" },
346 24f136e0 2021-11-20 thomas { GOT_ERR_FILE_BINARY, "found a binary file instead of text" },
347 069bbb86 2022-03-07 thomas { GOT_ERR_PATCH_MALFORMED, "malformed patch" },
348 069bbb86 2022-03-07 thomas { GOT_ERR_PATCH_TRUNCATED, "patch truncated" },
349 069bbb86 2022-03-07 thomas { GOT_ERR_PATCH_DONT_APPLY, "patch doesn't apply" },
350 069bbb86 2022-03-07 thomas { GOT_ERR_NO_PATCH, "no patch found" },
351 4027f31a 2017-11-04 stsp };
352 4027f31a 2017-11-04 stsp
353 0c60ce5a 2018-04-02 stsp /*
354 0c60ce5a 2018-04-02 stsp * Get an error object from the above list, for a given error code.
355 0c60ce5a 2018-04-02 stsp * The error message is fixed.
356 0c60ce5a 2018-04-02 stsp */
357 0c60ce5a 2018-04-02 stsp const struct got_error *got_error(int);
358 0c60ce5a 2018-04-02 stsp
359 0c60ce5a 2018-04-02 stsp /*
360 91a3d81f 2018-11-11 stsp * Get an error object from the above list, for a given error code.
361 91a3d81f 2018-11-11 stsp * Use the specified error message instead of the default one.
362 91a3d81f 2018-11-11 stsp * Caution: If the message buffer lives in dynamically allocated memory,
363 91a3d81f 2018-11-11 stsp * then this memory likely won't be freed.
364 91a3d81f 2018-11-11 stsp */
365 91a3d81f 2018-11-11 stsp const struct got_error *got_error_msg(int, const char *);
366 91a3d81f 2018-11-11 stsp
367 91a3d81f 2018-11-11 stsp /*
368 0c60ce5a 2018-04-02 stsp * Get a statically allocated error object with code GOT_ERR_ERRNO
369 230a42bd 2019-05-11 jcs * and an error message obtained from strerror(3), prefixed with a
370 230a42bd 2019-05-11 jcs * string.
371 0c60ce5a 2018-04-02 stsp */
372 638f9024 2019-05-13 stsp const struct got_error *got_error_from_errno(const char *);
373 0c60ce5a 2018-04-02 stsp
374 0c60ce5a 2018-04-02 stsp /*
375 48b8b0eb 2019-05-11 jcs * Get a statically allocated error object with code GOT_ERR_ERRNO
376 230a42bd 2019-05-11 jcs * and an error message obtained from strerror(3), prefixed with two
377 230a42bd 2019-05-11 jcs * strings.
378 48b8b0eb 2019-05-11 jcs */
379 638f9024 2019-05-13 stsp const struct got_error *got_error_from_errno2(const char *, const char *);
380 48b8b0eb 2019-05-11 jcs
381 48b8b0eb 2019-05-11 jcs /*
382 230a42bd 2019-05-11 jcs * Get a statically allocated error object with code GOT_ERR_ERRNO
383 230a42bd 2019-05-11 jcs * and an error message obtained from strerror(3), prefixed with three
384 230a42bd 2019-05-11 jcs * strings.
385 230a42bd 2019-05-11 jcs */
386 638f9024 2019-05-13 stsp const struct got_error *got_error_from_errno3(const char *, const char *,
387 230a42bd 2019-05-11 jcs const char *);
388 4cc6a5a5 2020-12-15 stsp
389 4cc6a5a5 2020-12-15 stsp /*
390 4cc6a5a5 2020-12-15 stsp * Get a statically allocated error object with code GOT_ERR_ERRNO
391 4cc6a5a5 2020-12-15 stsp * and an error message obtained from strerror(3), prefixed with a
392 4cc6a5a5 2020-12-15 stsp * string built with vsnprintf(3) from the provided format string
393 4cc6a5a5 2020-12-15 stsp * and the variable-length list of additional arguments.
394 4cc6a5a5 2020-12-15 stsp */
395 4cc6a5a5 2020-12-15 stsp const struct got_error *got_error_from_errno_fmt(const char *, ...);
396 230a42bd 2019-05-11 jcs
397 230a42bd 2019-05-11 jcs /*
398 1a76625f 2018-10-22 stsp * Set errno to the specified error code and return a statically
399 1a76625f 2018-10-22 stsp * allocated error object with code GOT_ERR_ERRNO and an error
400 2af4a041 2019-05-11 jcs * message obtained from strerror(3), optionally prefixed with a
401 2af4a041 2019-05-11 jcs * string.
402 1a76625f 2018-10-22 stsp */
403 2af4a041 2019-05-11 jcs const struct got_error *got_error_set_errno(int, const char *);
404 1a76625f 2018-10-22 stsp
405 1a76625f 2018-10-22 stsp /*
406 0c60ce5a 2018-04-02 stsp * If ferror(3) indicates an error status for the FILE, obtain an error
407 638f9024 2019-05-13 stsp * from got_error_from_errno(). Else, obtain the error via got_error()
408 0c60ce5a 2018-04-02 stsp * with the error code provided in the second argument.
409 0c60ce5a 2018-04-02 stsp */
410 8251fdbc 2018-01-12 stsp const struct got_error *got_ferror(FILE *, int);
411 91a3d81f 2018-11-11 stsp
412 91a3d81f 2018-11-11 stsp /*
413 91a3d81f 2018-11-11 stsp * Obtain an error with code GOT_ERR_NO_OBJ and an error message which
414 91a3d81f 2018-11-11 stsp * contains the specified object ID. The message buffer is statically
415 91a3d81f 2018-11-11 stsp * allocated; future invocations of this function will overwrite the
416 91a3d81f 2018-11-11 stsp * message set during earlier invocations.
417 91a3d81f 2018-11-11 stsp */
418 91a3d81f 2018-11-11 stsp struct got_object_id; /* forward declaration */
419 91a3d81f 2018-11-11 stsp const struct got_error *got_error_no_obj(struct got_object_id *);
420 2aa0475c 2019-02-03 stsp
421 2aa0475c 2019-02-03 stsp /*
422 2aa0475c 2019-02-03 stsp * Obtain an error with code GOT_ERR_NOT_REF and an error message which
423 2aa0475c 2019-02-03 stsp * contains the specified reference name. The message buffer is statically
424 2aa0475c 2019-02-03 stsp * allocated; future invocations of this function will overwrite the
425 2aa0475c 2019-02-03 stsp * message set during earlier invocations.
426 2aa0475c 2019-02-03 stsp */
427 2aa0475c 2019-02-03 stsp const struct got_error *got_error_not_ref(const char *);
428 09589288 2019-03-10 stsp
429 09589288 2019-03-10 stsp /* Return an error based on a uuid(3) status code. */
430 cc483380 2019-09-01 stsp const struct got_error *got_error_uuid(uint32_t, const char *);
431 df056ada 2019-05-15 stsp
432 df056ada 2019-05-15 stsp /* Return an error with a path prefixed to the error message. */
433 df056ada 2019-05-15 stsp const struct got_error *got_error_path(const char *, int);
434 73e7eb7d 2020-12-15 stsp
435 73e7eb7d 2020-12-15 stsp /*
436 73e7eb7d 2020-12-15 stsp * Return an error with an error message prefix built by vsnprintf(3)
437 73e7eb7d 2020-12-15 stsp * from the provided format string and the variable-length list of
438 73e7eb7d 2020-12-15 stsp * additional arguments.
439 73e7eb7d 2020-12-15 stsp */
440 73e7eb7d 2020-12-15 stsp const struct got_error *got_error_fmt(int, const char *, ...);
441 3dc1dc04 2021-09-27 thomas
442 3dc1dc04 2021-09-27 thomas /*
443 3dc1dc04 2021-09-27 thomas * Check whether open(2) with O_NOFOLLOW failed on a symlink.
444 3dc1dc04 2021-09-27 thomas * This must be called directly after open(2) because it uses errno!
445 3dc1dc04 2021-09-27 thomas */
446 3dc1dc04 2021-09-27 thomas int got_err_open_nofollow_on_symlink(void);