]> git.ipfire.org Git - thirdparty/git.git/commit - midx.c
multi-pack-index: implement 'expire' subcommand
authorDerrick Stolee <dstolee@microsoft.com>
Mon, 10 Jun 2019 23:35:25 +0000 (16:35 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 11 Jun 2019 17:34:40 +0000 (10:34 -0700)
commit19575c7c8e60c95c6714e51039ee9a21721cc31d
tree62cd567e947a4cfdff6fe0d61daf5505a47c3cf8
parentd01bf2e609bf792820023fc0f4ef5048bc689327
multi-pack-index: implement 'expire' subcommand

The 'git multi-pack-index expire' subcommand looks at the existing
mult-pack-index, counts the number of objects referenced in each
pack-file, deletes the pack-fils with no referenced objects, and
rewrites the multi-pack-index to no longer reference those packs.

Refactor the write_midx_file() method to call write_midx_internal()
which now takes an existing 'struct multi_pack_index' and a list
of pack-files to drop (as specified by the names of their pack-
indexes). As we write the new multi-pack-index, we drop those
file names from the list of known pack-files.

The expire_midx_packs() method removes the unreferenced pack-files
after carefully closing the packs to avoid open handles.

Test that a new pack-file that covers the contents of two other
pack-files leads to those pack-files being deleted during the
expire subcommand. Be sure to read the multi-pack-index to ensure
it no longer references those packs.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
midx.c
t/t5319-multi-pack-index.sh