diff options
author | Derrick Stolee <stolee@gmail.com> | 2018-07-12 15:39:40 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-07-20 11:27:29 -0700 |
commit | 525e18c04bb38450e6677bb2aa5c65b78254b5c2 (patch) | |
tree | 4ecc21ed7cc9200580b1e20344681c5ef9420433 /builtin/repack.c | |
parent | packfile: skip loading index if in multi-pack-index (diff) | |
download | tgif-525e18c04bb38450e6677bb2aa5c65b78254b5c2.tar.xz |
midx: clear midx on repack
If a 'git repack' command replaces existing packfiles, then we must
clear the existing multi-pack-index before moving the packfiles it
references.
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/repack.c')
-rw-r--r-- | builtin/repack.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/builtin/repack.c b/builtin/repack.c index 6c636e159e..7f7cdc8b17 100644 --- a/builtin/repack.c +++ b/builtin/repack.c @@ -8,6 +8,7 @@ #include "strbuf.h" #include "string-list.h" #include "argv-array.h" +#include "midx.h" static int delta_base_offset = 1; static int pack_kept_objects = -1; @@ -174,6 +175,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix) int no_update_server_info = 0; int quiet = 0; int local = 0; + int midx_cleared = 0; struct option builtin_repack_options[] = { OPT_BIT('a', NULL, &pack_everything, @@ -333,6 +335,13 @@ int cmd_repack(int argc, const char **argv, const char *prefix) for_each_string_list_item(item, &names) { for (ext = 0; ext < ARRAY_SIZE(exts); ext++) { char *fname, *fname_old; + + if (!midx_cleared) { + /* if we move a packfile, it will invalidated the midx */ + clear_midx_file(get_object_directory()); + midx_cleared = 1; + } + fname = mkpathdup("%s/pack-%s%s", packdir, item->string, exts[ext].name); if (!file_exists(fname)) { |