Start preparing for Git 2.0
[gitweb.git] / builtin / pack-objects.c
index fd6ae01ba486f7a7355510d887fb98a8eb02120f..c73337931b0c2d456801de75a4a17e83b2091753 100644 (file)
@@ -64,6 +64,7 @@ static off_t reuse_packfile_offset;
 
 static int use_bitmap_index = 1;
 static int write_bitmap_index;
+static uint16_t write_bitmap_options;
 
 static unsigned long delta_cache_size = 0;
 static unsigned long max_delta_cache_size = 256 * 1024 * 1024;
@@ -768,8 +769,6 @@ static void write_pack_file(void)
                        f = create_tmp_packfile(&pack_tmp_name);
 
                offset = write_pack_header(f, nr_remaining);
-               if (!offset)
-                       die_errno("unable to write pack header");
 
                if (reuse_packfile) {
                        off_t packfile_size;
@@ -851,7 +850,8 @@ static void write_pack_file(void)
                                bitmap_writer_reuse_bitmaps(&to_pack);
                                bitmap_writer_select_commits(indexed_commits, indexed_commits_nr, -1);
                                bitmap_writer_build(&to_pack);
-                               bitmap_writer_finish(written_list, nr_written, tmpname);
+                               bitmap_writer_finish(written_list, nr_written,
+                                                    tmpname, write_bitmap_options);
                                write_bitmap_index = 0;
                        }
 
@@ -2087,7 +2087,7 @@ static int add_ref_tag(const char *path, const unsigned char *sha1, int flag, vo
 {
        unsigned char peeled[20];
 
-       if (!prefixcmp(path, "refs/tags/") && /* is a tag? */
+       if (starts_with(path, "refs/tags/") && /* is a tag? */
            !peel_ref(path, peeled)        && /* peelable? */
            packlist_find(&to_pack, peeled, NULL))      /* object packed? */
                add_object_entry(sha1, OBJ_TAG, NULL, 0);
@@ -2201,6 +2201,12 @@ static int git_pack_config(const char *k, const char *v, void *cb)
                write_bitmap_index = git_config_bool(k, v);
                return 0;
        }
+       if (!strcmp(k, "pack.writebitmaphashcache")) {
+               if (git_config_bool(k, v))
+                       write_bitmap_options |= BITMAP_OPT_HASH_CACHE;
+               else
+                       write_bitmap_options &= ~BITMAP_OPT_HASH_CACHE;
+       }
        if (!strcmp(k, "pack.usebitmaps")) {
                use_bitmap_index = git_config_bool(k, v);
                return 0;