From: Junio C Hamano Date: Thu, 27 Feb 2014 22:01:48 +0000 (-0800) Subject: Merge branch 'jk/pack-bitmap' X-Git-Tag: v2.0.0-rc0~148 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0f9e62e0847c075678a7a5a748567d1e881d16f8;p=git Merge branch 'jk/pack-bitmap' 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 ... --- 0f9e62e0847c075678a7a5a748567d1e881d16f8 diff --cc builtin/pack-objects.c index 541667f102,fd741970e6..c73337931b --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@@ -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; } diff --cc builtin/repack.c index bb2314c9cb,239f278fac..49f5857627 --- a/builtin/repack.c +++ b/builtin/repack.c @@@ -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() }; @@@ -256,10 -271,10 +269,10 @@@ */ 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; @@@ -333,12 -352,12 +350,12 @@@ /* 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); }