|
10 | 10 | #include "fsck.h" |
11 | 11 | #include "refs.h" |
12 | 12 | #include "utf8.h" |
13 | | -#include "sha1-array.h" |
14 | 13 | #include "decorate.h" |
15 | 14 | #include "oidset.h" |
16 | 15 | #include "packfile.h" |
@@ -182,39 +181,23 @@ static int fsck_msg_type(enum fsck_msg_id msg_id, |
182 | 181 |
|
183 | 182 | static void init_skiplist(struct fsck_options *options, const char *path) |
184 | 183 | { |
185 | | - static struct oid_array skiplist = OID_ARRAY_INIT; |
186 | | - int sorted; |
187 | 184 | FILE *fp; |
188 | 185 | struct strbuf sb = STRBUF_INIT; |
189 | 186 | struct object_id oid; |
190 | 187 |
|
191 | | - if (options->skiplist) |
192 | | - sorted = options->skiplist->sorted; |
193 | | - else { |
194 | | - sorted = 1; |
195 | | - options->skiplist = &skiplist; |
196 | | - } |
197 | | - |
198 | 188 | fp = fopen(path, "r"); |
199 | 189 | if (!fp) |
200 | 190 | die("Could not open skip list: %s", path); |
201 | 191 | while (!strbuf_getline(&sb, fp)) { |
202 | 192 | const char *p; |
203 | 193 | if (parse_oid_hex(sb.buf, &oid, &p) || *p != '\0') |
204 | 194 | die("Invalid SHA-1: %s", sb.buf); |
205 | | - oid_array_append(&skiplist, &oid); |
206 | | - if (sorted && skiplist.nr > 1 && |
207 | | - oidcmp(&skiplist.oid[skiplist.nr - 2], |
208 | | - &oid) > 0) |
209 | | - sorted = 0; |
| 195 | + oidset_insert(&options->skiplist, &oid); |
210 | 196 | } |
211 | 197 | if (ferror(fp)) |
212 | 198 | die_errno("Could not read '%s'", path); |
213 | 199 | fclose(fp); |
214 | 200 | strbuf_release(&sb); |
215 | | - |
216 | | - if (sorted) |
217 | | - skiplist.sorted = 1; |
218 | 201 | } |
219 | 202 |
|
220 | 203 | static int parse_msg_type(const char *str) |
@@ -319,9 +302,7 @@ static void append_msg_id(struct strbuf *sb, const char *msg_id) |
319 | 302 |
|
320 | 303 | static int object_on_skiplist(struct fsck_options *opts, struct object *obj) |
321 | 304 | { |
322 | | - if (opts && opts->skiplist && obj) |
323 | | - return oid_array_lookup(opts->skiplist, &obj->oid) >= 0; |
324 | | - return 0; |
| 305 | + return opts && obj && oidset_contains(&opts->skiplist, &obj->oid); |
325 | 306 | } |
326 | 307 |
|
327 | 308 | __attribute__((format (printf, 4, 5))) |
|
0 commit comments