From e4d0c11c04ec3c28922168844ae2694e0d015b4e Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Mon, 20 Dec 2021 14:48:10 +0000 Subject: repack: respect kept objects with '--write-midx -b' Historically, we needed a single packfile in order to have reachability bitmaps. This introduced logic that when 'git repack' had a '-b' option that we should stop sending the '--honor-pack-keep' option to the 'git pack-objects' child process, ensuring that we create a packfile containing all reachable objects. In the world of multi-pack-index bitmaps, we no longer need to repack all objects into a single pack to have valid bitmaps. Thus, we should continue sending the '--honor-pack-keep' flag to 'git pack-objects'. The fix is very simple: only disable the flag when writing bitmaps but also _not_ writing the multi-pack-index. This opens the door to new repacking strategies that might want to keep some historical set of objects in a stable pack-file while only repacking more recent objects. To test, create a new 'test_subcommand_inexact' helper that is more flexible than 'test_subcommand'. This allows us to look for the --honor-pack-keep flag without over-indexing on the exact set of arguments. Signed-off-by: Derrick Stolee Signed-off-by: Junio C Hamano --- t/t7700-repack.sh | 6 ++++++ t/test-lib-functions.sh | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) (limited to 't') diff --git a/t/t7700-repack.sh b/t/t7700-repack.sh index 0260ad6f0e..63c9a247f5 100755 --- a/t/t7700-repack.sh +++ b/t/t7700-repack.sh @@ -372,4 +372,10 @@ test_expect_success '--write-midx with preferred bitmap tips' ' ) ' +test_expect_success '--write-midx -b packs non-kept objects' ' + GIT_TRACE2_EVENT="$(pwd)/trace.txt" \ + git repack --write-midx -a -b && + test_subcommand_inexact git pack-objects --honor-pack-keep ... < +# +# For example, to look for an invocation of "git pack-objects" +# with the "--honor-pack-keep" argument, use +# +# GIT_TRACE2_EVENT=event.log git repack ... && +# test_subcommand git pack-objects --honor-pack-keep Date: Mon, 20 Dec 2021 14:48:11 +0000 Subject: repack: make '--quiet' disable progress While testing some ideas in 'git repack', I ran it with '--quiet' and discovered that some progress output was still shown. Specifically, the output for writing the multi-pack-index showed the progress. The 'show_progress' variable in cmd_repack() is initialized with isatty(2) and is not modified at all by the '--quiet' flag. The '--quiet' flag modifies the po_args.quiet option which is translated into a '--quiet' flag for the 'git pack-objects' child process. However, 'show_progress' is used to directly send progress information to the multi-pack-index writing logic which does not use a child process. The fix here is to modify 'show_progress' to be false if po_opts.quiet is true, and isatty(2) otherwise. This new expectation simplifies a later condition that checks both. Update the documentation to make it clear that '-q' will disable all progress in addition to ensuring the 'git pack-objects' child process will receive the flag. Use 'test_terminal' to check that this works to get around the isatty(2) check. Helped-by: Jeff King Signed-off-by: Derrick Stolee Signed-off-by: Junio C Hamano --- t/t7700-repack.sh | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 't') diff --git a/t/t7700-repack.sh b/t/t7700-repack.sh index 63c9a247f5..fe2b493d0e 100755 --- a/t/t7700-repack.sh +++ b/t/t7700-repack.sh @@ -5,6 +5,7 @@ test_description='git repack works correctly' . ./test-lib.sh . "${TEST_DIRECTORY}/lib-bitmap.sh" . "${TEST_DIRECTORY}/lib-midx.sh" +. "${TEST_DIRECTORY}/lib-terminal.sh" commit_and_pack () { test_commit "$@" 1>&2 && @@ -378,4 +379,10 @@ test_expect_success '--write-midx -b packs non-kept objects' ' test_subcommand_inexact git pack-objects --honor-pack-keep stderr && + test_must_be_empty stderr +' + test_done -- cgit v1.2.3