|
21 | 21 | #include "sigchain.h"
|
22 | 22 | #include "fsck.h"
|
23 | 23 | #include "tmp-objdir.h"
|
| 24 | +#include "oidset.h" |
24 | 25 |
|
25 | 26 | static const char * const receive_pack_usage[] = {
|
26 | 27 | N_("git receive-pack <git-dir>"),
|
@@ -271,27 +272,24 @@ static int show_ref_cb(const char *path_full, const struct object_id *oid,
|
271 | 272 | return 0;
|
272 | 273 | }
|
273 | 274 |
|
274 |
| -static int show_one_alternate_sha1(const unsigned char sha1[20], void *unused) |
| 275 | +static void show_one_alternate_ref(const char *refname, |
| 276 | + const struct object_id *oid, |
| 277 | + void *data) |
275 | 278 | {
|
276 |
| - show_ref(".have", sha1); |
277 |
| - return 0; |
278 |
| -} |
| 279 | + struct oidset *seen = data; |
279 | 280 |
|
280 |
| -static void collect_one_alternate_ref(const char *refname, |
281 |
| - const struct object_id *oid, |
282 |
| - void *data) |
283 |
| -{ |
284 |
| - struct sha1_array *sa = data; |
285 |
| - sha1_array_append(sa, oid->hash); |
| 281 | + if (oidset_insert(seen, oid)) |
| 282 | + return; |
| 283 | + |
| 284 | + show_ref(".have", oid->hash); |
286 | 285 | }
|
287 | 286 |
|
288 | 287 | static void write_head_info(void)
|
289 | 288 | {
|
290 |
| - struct sha1_array sa = SHA1_ARRAY_INIT; |
| 289 | + static struct oidset seen = OIDSET_INIT; |
291 | 290 |
|
292 |
| - for_each_alternate_ref(collect_one_alternate_ref, &sa); |
293 |
| - sha1_array_for_each_unique(&sa, show_one_alternate_sha1, NULL); |
294 |
| - sha1_array_clear(&sa); |
| 291 | + for_each_alternate_ref(show_one_alternate_ref, &seen); |
| 292 | + oidset_clear(&seen); |
295 | 293 | for_each_ref(show_ref_cb, NULL);
|
296 | 294 | if (!sent_capabilities)
|
297 | 295 | show_ref("capabilities^{}", null_sha1);
|
|
0 commit comments