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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Feb 8, 2017 at 15:53 UTC 8b24b9e76534b6664d4ea1afa67db0fbb495c925
1 file changed +7 -3
builtin/receive-pack.c
+7 -3
@@ -251,8 +251,9 @@ static void show_ref(const char *path, const unsigned char *sha1)
251 }
252
253 static int show_ref_cb(const char *path_full, const struct object_id *oid,
254 - int flag, void *unused)
254 + int flag, void *data)
255 {
256 + struct oidset *seen = data;
257 const char *path = strip_namespace(path_full);
258
259 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,
264 * refs, so that the client can use them to minimize data
265 * transfer but will otherwise ignore them.
266 */
266 - if (!path)
267 + if (!path) {
268 + if (oidset_insert(seen, oid))
269 + return 0;
270 path = ".have";
271 + }
272 show_ref(path, oid->hash);
273 return 0;
274 }
@@ -287,7 +291,7 @@ static void write_head_info(void)
291
292 for_each_alternate_ref(show_one_alternate_ref, &seen);
293 oidset_clear(&seen);
290 - for_each_ref(show_ref_cb, NULL);
294 + for_each_ref(show_ref_cb, &seen);
295 if (!sent_capabilities)
296 show_ref("capabilities^{}", null_sha1);
297