Skip to content

Commit 85f2510

Browse files
mhaggergitster
authored andcommitted
write_head_info(): handle "extra refs" locally
The old code basically did: generate array of SHA1s for alternate refs for each unique SHA1 in array: add_extra_ref(".have", sha1) for each ref (including real refs and extra refs): show_ref(refname, sha1) But there is no need to stuff the alternate refs in extra_refs; we can call show_ref() directly when iterating over the array, then handle real refs separately. So change the code to: generate array of SHA1s for alternate refs for each unique SHA1 in array: show_ref(".have", sha1) for each ref (this now only includes real refs): show_ref(refname, sha1) Signed-off-by: Michael Haggerty <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bc98201 commit 85f2510

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

builtin/receive-pack.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ static int show_ref_cb(const char *path, const unsigned char *sha1, int flag, vo
143143
return 0;
144144
}
145145

146-
static void add_one_alternate_sha1(const unsigned char sha1[20], void *unused)
146+
static void show_one_alternate_sha1(const unsigned char sha1[20], void *unused)
147147
{
148-
add_extra_ref(".have", sha1, 0);
148+
show_ref(".have", sha1);
149149
}
150150

151151
static void collect_one_alternate_ref(const struct ref *ref, void *data)
@@ -158,12 +158,11 @@ static void write_head_info(void)
158158
{
159159
struct sha1_array sa = SHA1_ARRAY_INIT;
160160
for_each_alternate_ref(collect_one_alternate_ref, &sa);
161-
sha1_array_for_each_unique(&sa, add_one_alternate_sha1, NULL);
161+
sha1_array_for_each_unique(&sa, show_one_alternate_sha1, NULL);
162162
sha1_array_clear(&sa);
163163
for_each_ref(show_ref_cb, NULL);
164164
if (!sent_capabilities)
165165
show_ref("capabilities^{}", null_sha1);
166-
clear_extra_refs();
167166

168167
/* EOF */
169168
packet_flush(1);

0 commit comments

Comments
 (0)