Merge branch 'jk/pack-bitmap'
authorJunio C Hamano <gitster@pobox.com>
Thu, 27 Feb 2014 22:01:48 +0000 (14:01 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 27 Feb 2014 22:01:48 +0000 (14:01 -0800)
Borrow the bitmap index into packfiles from JGit to speed up
enumeration of objects involved in a commit range without having to
fully traverse the history.

* jk/pack-bitmap: (26 commits)
ewah: unconditionally ntohll ewah data
ewah: support platforms that require aligned reads
read-cache: use get_be32 instead of hand-rolled ntoh_l
block-sha1: factor out get_be and put_be wrappers
do not discard revindex when re-preparing packfiles
pack-bitmap: implement optional name_hash cache
t/perf: add tests for pack bitmaps
t: add basic bitmap functionality tests
count-objects: recognize .bitmap in garbage-checking
repack: consider bitmaps when performing repacks
repack: handle optional files created by pack-objects
repack: turn exts array into array-of-struct
repack: stop using magic number for ARRAY_SIZE(exts)
pack-objects: implement bitmap writing
rev-list: add bitmap mode to speed up object lists
pack-objects: use bitmaps when packing objects
pack-objects: split add_object_entry
pack-bitmap: add support for bitmap indexes
documentation: add documentation for the bitmap format
ewah: compressed bitmap implementation
...

14 files changed:
1  2 
Documentation/config.txt
Documentation/git-repack.txt
Documentation/rev-list-options.txt
Makefile
block-sha1/sha1.c
builtin/pack-objects.c
builtin/repack.c
builtin/rev-list.c
cache.h
pack-write.c
read-cache.c
revision.c
revision.h
sha1_file.c
Simple merge
Simple merge
Simple merge
diff --cc Makefile
Simple merge
Simple merge
index 541667f1026d7ba62be8e029c31138d5661f65c7,fd741970e61c674c628f2e9c8ae48e08d4996961..c73337931b0c2d456801de75a4a17e83b2091753
@@@ -737,8 -769,19 +769,17 @@@ 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;
+                       assert(pack_to_stdout);
+                       packfile_size = write_reused_pack(f);
+                       offset += packfile_size;
+               }
                nr_written = 0;
-               for (; i < nr_objects; i++) {
+               for (; i < to_pack.nr_objects; i++) {
                        struct object_entry *e = write_order[i];
                        if (write_one(f, e, &offset) == WRITE_ONE_BREAK)
                                break;
@@@ -2030,9 -2089,9 +2087,9 @@@ static int add_ref_tag(const char *path
  {
        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? */
-           locate_object_entry(peeled))      /* object packed? */
+           packlist_find(&to_pack, peeled, NULL))      /* object packed? */
                add_object_entry(sha1, OBJ_TAG, NULL, 0);
        return 0;
  }
index bb2314c9cb0ce3e01372c6c3a27396931c0143ab,239f278fac9c2be6655458992022b23117ea5020..49f5857627fd616b1019063f3f2d1937b20004fd
@@@ -155,15 -163,17 +163,17 @@@ int cmd_repack(int argc, const char **a
                OPT__QUIET(&quiet, N_("be quiet")),
                OPT_BOOL('l', "local", &local,
                                N_("pass --local to git-pack-objects")),
+               OPT_BOOL('b', "write-bitmap-index", &write_bitmap,
+                               N_("write bitmap index")),
                OPT_STRING(0, "unpack-unreachable", &unpack_unreachable, N_("approxidate"),
                                N_("with -A, do not loosen objects older than this")),
 -              OPT_INTEGER(0, "window", &window,
 +              OPT_STRING(0, "window", &window, N_("n"),
                                N_("size of the window used for delta compression")),
 -              OPT_INTEGER(0, "window-memory", &window_memory,
 +              OPT_STRING(0, "window-memory", &window_memory, N_("bytes"),
                                N_("same as the above, but limit memory size instead of entries count")),
 -              OPT_INTEGER(0, "depth", &depth,
 +              OPT_STRING(0, "depth", &depth, N_("n"),
                                N_("limits the maximum delta depth")),
 -              OPT_INTEGER(0, "max-pack-size", &max_pack_size,
 +              OPT_STRING(0, "max-pack-size", &max_pack_size, N_("bytes"),
                                N_("maximum size of each packfile")),
                OPT_END()
        };
         */
        failed = 0;
        for_each_string_list_item(item, &names) {
-               for (ext = 0; ext < 2; ext++) {
+               for (ext = 0; ext < ARRAY_SIZE(exts); ext++) {
                        char *fname, *fname_old;
 -                      fname = mkpathdup("%s/%s%s", packdir,
 +                      fname = mkpathdup("%s/pack-%s%s", packdir,
-                                               item->string, exts[ext]);
+                                               item->string, exts[ext].name);
                        if (!file_exists(fname)) {
                                free(fname);
                                continue;
  
        /* Remove the "old-" files */
        for_each_string_list_item(item, &names) {
-               for (ext = 0; ext < 2; ext++) {
+               for (ext = 0; ext < ARRAY_SIZE(exts); ext++) {
                        char *fname;
 -                      fname = mkpath("%s/old-pack-%s%s",
 +                      fname = mkpath("%s/old-%s%s",
                                        packdir,
                                        item->string,
-                                       exts[ext]);
+                                       exts[ext].name);
                        if (remove_path(fname))
                                warning(_("removing '%s' failed"), fname);
                }
Simple merge
diff --cc cache.h
Simple merge
diff --cc pack-write.c
Simple merge
diff --cc read-cache.c
Simple merge
diff --cc revision.c
Simple merge
diff --cc revision.h
Simple merge
diff --cc sha1_file.c
Simple merge