Merge branch 'jk/ident-empty'
[gitweb.git] / builtin / receive-pack.c
index a4926fcfb4bd8b56fc993e9f9da9dc990bbabf42..9ed8fbbfad71daf45381dbccf0aebe4a5b9af03d 100644 (file)
@@ -251,8 +251,9 @@ static void show_ref(const char *path, const unsigned char *sha1)
 }
 
 static int show_ref_cb(const char *path_full, const struct object_id *oid,
-                      int flag, void *unused)
+                      int flag, void *data)
 {
+       struct oidset *seen = data;
        const char *path = strip_namespace(path_full);
 
        if (ref_is_hidden(path, path_full))
@@ -261,13 +262,15 @@ static int show_ref_cb(const char *path_full, const struct object_id *oid,
        /*
         * Advertise refs outside our current namespace as ".have"
         * refs, so that the client can use them to minimize data
-        * transfer but will otherwise ignore them. This happens to
-        * cover ".have" that are thrown in by add_one_alternate_ref()
-        * to mark histories that are complete in our alternates as
-        * well.
+        * transfer but will otherwise ignore them.
         */
-       if (!path)
+       if (!path) {
+               if (oidset_insert(seen, oid))
+                       return 0;
                path = ".have";
+       } else {
+               oidset_insert(seen, oid);
+       }
        show_ref(path, oid->hash);
        return 0;
 }
@@ -288,9 +291,9 @@ static void write_head_info(void)
 {
        static struct oidset seen = OIDSET_INIT;
 
+       for_each_ref(show_ref_cb, &seen);
        for_each_alternate_ref(show_one_alternate_ref, &seen);
        oidset_clear(&seen);
-       for_each_ref(show_ref_cb, NULL);
        if (!sent_capabilities)
                show_ref("capabilities^{}", null_sha1);