Skip to content

Commit 8b24b9e

Browse files
peffgitster
authored andcommitted
receive-pack: treat namespace .have lines like alternates
Namely, de-duplicate them. We use the same set as the alternates, since we call them both ".have" (i.e., there is no value in showing one versus the other). Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fea6c47 commit 8b24b9e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

builtin/receive-pack.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,9 @@ static void show_ref(const char *path, const unsigned char *sha1)
251251
}
252252

253253
static int show_ref_cb(const char *path_full, const struct object_id *oid,
254-
int flag, void *unused)
254+
int flag, void *data)
255255
{
256+
struct oidset *seen = data;
256257
const char *path = strip_namespace(path_full);
257258

258259
if (ref_is_hidden(path, path_full))
@@ -263,8 +264,11 @@ static int show_ref_cb(const char *path_full, const struct object_id *oid,
263264
* refs, so that the client can use them to minimize data
264265
* transfer but will otherwise ignore them.
265266
*/
266-
if (!path)
267+
if (!path) {
268+
if (oidset_insert(seen, oid))
269+
return 0;
267270
path = ".have";
271+
}
268272
show_ref(path, oid->hash);
269273
return 0;
270274
}
@@ -287,7 +291,7 @@ static void write_head_info(void)
287291

288292
for_each_alternate_ref(show_one_alternate_ref, &seen);
289293
oidset_clear(&seen);
290-
for_each_ref(show_ref_cb, NULL);
294+
for_each_ref(show_ref_cb, &seen);
291295
if (!sent_capabilities)
292296
show_ref("capabilities^{}", null_sha1);
293297

0 commit comments

Comments
 (0)