grep: use the right index instead of the_index
[gitweb.git] / pack-bitmap-write.c
index 72d9daec7e62bb924940c4e20763effaa347ea5c..d977e9bacb19ed766dd0a501b6fbcae800bb4ae0 100644 (file)
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "object-store.h"
 #include "commit.h"
 #include "tag.h"
 #include "diff.h"
@@ -360,11 +361,17 @@ static int date_compare(const void *_a, const void *_b)
 
 void bitmap_writer_reuse_bitmaps(struct packing_data *to_pack)
 {
-       if (prepare_bitmap_git() < 0)
+       struct bitmap_index *bitmap_git;
+       if (!(bitmap_git = prepare_bitmap_git()))
                return;
 
        writer.reused = kh_init_sha1();
-       rebuild_existing_bitmaps(to_pack, writer.reused, writer.show_progress);
+       rebuild_existing_bitmaps(bitmap_git, to_pack, writer.reused,
+                                writer.show_progress);
+       /*
+        * NEEDSWORK: rebuild_existing_bitmaps() makes writer.reused reference
+        * some bitmaps in bitmap_git, so we can't free the latter.
+        */
 }
 
 static struct ewah_bitmap *find_reused_bitmap(const unsigned char *sha1)
@@ -477,7 +484,7 @@ static void write_selected_commits_v1(struct hashfile *f,
                        sha1_pos(stored->commit->object.oid.hash, index, index_nr, sha1_access);
 
                if (commit_pos < 0)
-                       die("BUG: trying to write commit not in index");
+                       BUG("trying to write commit not in index");
 
                hashwrite_be32(f, commit_pos);
                hashwrite_u8(f, stored->xor_offset);