Show changes to 4 files +40 −34
builtin/multi-pack-index.c, builtin/repack.c, midx-write.c, midx.h
diff --git a/builtin/multi-pack-index.c b/builtin/multi-pack-index.c
index 2a938466f5..fb073a946a 100644
--- a/builtin/multi-pack-index.c
+++ b/builtin/multi-pack-index.c
@@ -10,6 +10,7 @@
#include "object-store-ll.h"
#include "replace-object.h"
#include "repository.h"
+#include "pack-bitmap.h"
#define BUILTIN_MIDX_WRITE_USAGE \
N_("git multi-pack-index [<options>] write [--preferred-pack=<pack>]" \
@@ -54,6 +55,7 @@ static struct opts_multi_pack_index {
char *refs_snapshot;
unsigned long batch_size;
unsigned flags;
+ uint16_t bitmap_options;
int stdin_packs;
} opts;
@@ -89,16 +91,16 @@ static int git_multi_pack_index_write_config(const char *var, const char *value,
{
if (!strcmp(var, "pack.writebitmaphashcache")) {
if (git_config_bool(var, value))
- opts.flags |= MIDX_WRITE_BITMAP_HASH_CACHE;
+ opts.bitmap_options |= BITMAP_OPT_HASH_CACHE;
else
- opts.flags &= ~MIDX_WRITE_BITMAP_HASH_CACHE;
+ opts.bitmap_options &= ~BITMAP_OPT_HASH_CACHE;
}
if (!strcmp(var, "pack.writebitmaplookuptable")) {
if (git_config_bool(var, value))
- opts.flags |= MIDX_WRITE_BITMAP_LOOKUP_TABLE;
+ opts.bitmap_options |= BITMAP_OPT_LOOKUP_TABLE;
else
- opts.flags &= ~MIDX_WRITE_BITMAP_LOOKUP_TABLE;
+ opts.bitmap_options &= ~BITMAP_OPT_LOOKUP_TABLE;
}
/*
@@ -141,7 +143,7 @@ static int cmd_multi_pack_index_write(int argc, const char **argv,
};
int ret;
- opts.flags |= MIDX_WRITE_BITMAP_HASH_CACHE;
+ opts.bitmap_options |= BITMAP_OPT_HASH_CACHE;
git_config(git_multi_pack_index_write_config, NULL);
@@ -167,7 +169,8 @@ static int cmd_multi_pack_index_write(int argc, const char **argv,
ret = write_midx_file_only(repo, opts.object_dir, &packs,
opts.preferred_pack,
- opts.refs_snapshot, opts.flags);
+ opts.refs_snapshot, opts.flags,
+ opts.bitmap_options);
string_list_clear(&packs, 0);
free(opts.refs_snapshot);
@@ -177,7 +180,8 @@ static int cmd_multi_pack_index_write(int argc, const char **argv,
}
ret = write_midx_file(repo, opts.object_dir, opts.preferred_pack,
- opts.refs_snapshot, opts.flags);
+ opts.refs_snapshot, opts.flags,
+ opts.bitmap_options);
free(opts.refs_snapshot);
return ret;
@@ -236,7 +240,8 @@ static int cmd_multi_pack_index_expire(int argc, const char **argv,
FREE_AND_NULL(options);
- return expire_midx_packs(the_repository, opts.object_dir, opts.flags);
+ return expire_midx_packs(the_repository, opts.object_dir, opts.flags,
+ opts.bitmap_options);
}
static int cmd_multi_pack_index_repack(int argc, const char **argv,
@@ -269,7 +274,8 @@ static int cmd_multi_pack_index_repack(int argc, const char **argv,
FREE_AND_NULL(options);
return midx_repack(the_repository, opts.object_dir,
- (size_t)opts.batch_size, opts.flags);
+ (size_t)opts.batch_size, opts.flags,
+ opts.bitmap_options);
}
int cmd_multi_pack_index(int argc,
diff --git a/builtin/repack.c b/builtin/repack.c
index f3330ade7b..69c9a8bc4c 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -1562,7 +1562,7 @@ int cmd_repack(int argc,
if (git_env_bool(GIT_TEST_MULTI_PACK_INDEX_WRITE_INCREMENTAL, 0))
flags |= MIDX_WRITE_INCREMENTAL;
write_midx_file(the_repository, repo_get_object_directory(the_repository),
- NULL, NULL, flags);
+ NULL, NULL, flags, 0);
}
cleanup:
diff --git a/midx-write.c b/midx-write.c
index 48a4dc5e94..5729b989cb 100644
--- a/midx-write.c
+++ b/midx-write.c
@@ -841,10 +841,10 @@ static int write_midx_bitmap(struct write_midx_context *ctx,
struct packing_data *pdata,
struct commit **commits,
uint32_t commits_nr,
- unsigned flags)
+ unsigned flags,
+ uint16_t options)
{
int ret, i;
- uint16_t options = 0;
struct bitmap_writer writer;
struct pack_idx_entry **index;
struct strbuf bitmap_name = STRBUF_INIT;
@@ -859,12 +859,6 @@ static int write_midx_bitmap(struct write_midx_context *ctx,
get_midx_filename_ext(ctx->repo->hash_algo, &bitmap_name,
object_dir, midx_hash, MIDX_EXT_BITMAP);
- if (flags & MIDX_WRITE_BITMAP_HASH_CACHE)
- options |= BITMAP_OPT_HASH_CACHE;
-
- if (flags & MIDX_WRITE_BITMAP_LOOKUP_TABLE)
- options |= BITMAP_OPT_LOOKUP_TABLE;
-
/*
* Build the MIDX-order index based on pdata.objects (which is already
* in MIDX order; c.f., 'midx_pack_order_cmp()' for the definition of
@@ -1070,7 +1064,8 @@ static int write_midx_internal(struct repository *r, const char *object_dir,
struct string_list *packs_to_drop,
const char *preferred_pack_name,
const char *refs_snapshot,
- unsigned flags)
+ unsigned flags,
+ uint16_t bitmap_options)
{
struct strbuf midx_name = STRBUF_INIT;
unsigned char midx_hash[GIT_MAX_RAWSZ];
@@ -1433,7 +1428,7 @@ static int write_midx_internal(struct repository *r, const char *object_dir,
if (write_midx_bitmap(&ctx, object_dir,
midx_hash, &pdata, commits, commits_nr,
- flags) < 0) {
+ flags, bitmap_options) < 0) {
error(_("could not write multi-pack bitmap"));
result = 1;
clear_packing_data(&pdata);
@@ -1529,23 +1524,27 @@ static int write_midx_internal(struct repository *r, const char *object_dir,
int write_midx_file(struct repository *r, const char *object_dir,
const char *preferred_pack_name,
- const char *refs_snapshot, unsigned flags)
+ const char *refs_snapshot, unsigned flags,
+ uint16_t bitmap_options)
{
return write_midx_internal(r, object_dir, NULL, NULL,
preferred_pack_name, refs_snapshot,
- flags);
+ flags, bitmap_options);
}
int write_midx_file_only(struct repository *r, const char *object_dir,
struct string_list *packs_to_include,
const char *preferred_pack_name,
- const char *refs_snapshot, unsigned flags)
+ const char *refs_snapshot, unsigned flags,
+ uint16_t bitmap_options)
{
return write_midx_internal(r, object_dir, packs_to_include, NULL,
- preferred_pack_name, refs_snapshot, flags);
+ preferred_pack_name, refs_snapshot, flags,
+ bitmap_options);
}
-int expire_midx_packs(struct repository *r, const char *object_dir, unsigned flags)
+int expire_midx_packs(struct repository *r, const char *object_dir,
+ unsigned flags, uint16_t bitmap_options)
{
uint32_t i, *count, result = 0;
struct string_list packs_to_drop = STRING_LIST_INIT_DUP;
@@ -1603,7 +1602,8 @@ int expire_midx_packs(struct repository *r, const char *object_dir, unsigned fla
if (packs_to_drop.nr)
result = write_midx_internal(r, object_dir, NULL,
- &packs_to_drop, NULL, NULL, flags);
+ &packs_to_drop, NULL, NULL, flags,
+ bitmap_options);
string_list_clear(&packs_to_drop, 0);
@@ -1718,7 +1718,8 @@ static void fill_included_packs_batch(struct repository *r,
free(pack_info);
}
-int midx_repack(struct repository *r, const char *object_dir, size_t batch_size, unsigned flags)
+int midx_repack(struct repository *r, const char *object_dir, size_t batch_size,
+ unsigned flags, uint16_t bitmap_options)
{
int result = 0;
uint32_t i, packs_to_repack = 0;
@@ -1801,7 +1802,7 @@ int midx_repack(struct repository *r, const char *object_dir, size_t batch_size,
}
result = write_midx_internal(r, object_dir, NULL, NULL, NULL, NULL,
- flags);
+ flags, bitmap_options);
cleanup:
free(include_pack);
diff --git a/midx.h b/midx.h
index 9d1374cbd5..5a79302a7a 100644
--- a/midx.h
+++ b/midx.h
@@ -81,8 +81,6 @@ struct multi_pack_index {
#define MIDX_PROGRESS (1 << 0)
#define MIDX_WRITE_REV_INDEX (1 << 1)
#define MIDX_WRITE_BITMAP (1 << 2)
-#define MIDX_WRITE_BITMAP_HASH_CACHE (1 << 3)
-#define MIDX_WRITE_BITMAP_LOOKUP_TABLE (1 << 4)
#define MIDX_WRITE_INCREMENTAL (1 << 5)
#define MIDX_EXT_REV "rev"
@@ -131,15 +129,16 @@ int prepare_multi_pack_index_one(struct repository *r, const char *object_dir, i
*/
int write_midx_file(struct repository *r, const char *object_dir,
const char *preferred_pack_name, const char *refs_snapshot,
- unsigned flags);
+ unsigned flags, uint16_t bitmap_options);
int write_midx_file_only(struct repository *r, const char *object_dir,
struct string_list *packs_to_include,
const char *preferred_pack_name,
- const char *refs_snapshot, unsigned flags);
+ const char *refs_snapshot, unsigned flags,
+ uint16_t bitmap_options);
void clear_midx_file(struct repository *r);
int verify_midx_file(struct repository *r, const char *object_dir, unsigned flags);
-int expire_midx_packs(struct repository *r, const char *object_dir, unsigned flags);
-int midx_repack(struct repository *r, const char *object_dir, size_t batch_size, unsigned flags);
+int expire_midx_packs(struct repository *r, const char *object_dir, unsigned flags, uint16_t bitmap_options);
+int midx_repack(struct repository *r, const char *object_dir, size_t batch_size, unsigned flags, uint16_t bitmap_options);
void close_midx(struct multi_pack_index *m);