Skip to content

Commit

Permalink
pack-objects: disable --full-name-hash when shallow
Browse files Browse the repository at this point in the history
As demonstrated in the previous change, the --full-name-hash option of
'git pack-objects' is less effective in a trunctated history. Thus, even
when the option is selected via a command-line option or config, disable
this option when the '--shallow' option is specified. This will help
performance in servers that choose to enable the --full-name-hash option
by default for a repository while not regressing their ability to serve
shallow clones.

This will not present a compatibility issue in the future when the full
name hash values are stored in the reachability bitmaps, since shallow
clones disable bitmaps.

Signed-off-by: Derrick Stolee <stolee@gmail.com>
  • Loading branch information
derrickstolee committed Nov 5, 2024
1 parent 086ecbb commit 5fd345a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions builtin/pack-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -4589,6 +4589,12 @@ int cmd_pack_objects(int argc,
if (use_full_name_hash < 0)
use_full_name_hash = git_env_bool("GIT_TEST_FULL_NAME_HASH", 0);

if (shallow && use_full_name_hash > 0 &&
!git_env_bool("GIT_TEST_USE_FULL_NAME_HASH_WITH_SHALLOW", 0)) {
use_full_name_hash = 0;
warning("the --full-name-hash option is disabled with the --shallow option");
}

if (write_bitmap_index && use_full_name_hash > 0) {
warning(_("currently, the --full-name-hash option is incompatible with --write-bitmap-index"));
use_full_name_hash = 0;
Expand Down
1 change: 1 addition & 0 deletions t/perf/p5313-pack-objects.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ test_size 'shallow pack size' '
'

test_perf 'shallow pack with --full-name-hash' '
GIT_TEST_USE_FULL_NAME_HASH_WITH_SHALLOW=1 \
git pack-objects --stdout --revs --sparse --shallow --full-name-hash <in-shallow >out
'

Expand Down

0 comments on commit 5fd345a

Please sign in to comment.