Skip to content

Commit 0eeb18a

Browse files
committed
pack-objects: disable --full-name-hash when shallow
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>
1 parent da17ccc commit 0eeb18a

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

builtin/pack-objects.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4589,6 +4589,12 @@ int cmd_pack_objects(int argc,
45894589
if (use_full_name_hash < 0)
45904590
use_full_name_hash = git_env_bool("GIT_TEST_FULL_NAME_HASH", 0);
45914591

4592+
if (shallow && use_full_name_hash > 0 &&
4593+
!git_env_bool("GIT_TEST_USE_FULL_NAME_HASH_WITH_SHALLOW", 0)) {
4594+
use_full_name_hash = 0;
4595+
warning("the --full-name-hash option is disabled with the --shallow option");
4596+
}
4597+
45924598
if (write_bitmap_index && use_full_name_hash > 0) {
45934599
warning(_("currently, the --full-name-hash option is incompatible with --write-bitmap-index"));
45944600
use_full_name_hash = 0;

t/perf/p5313-pack-objects.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ test_size 'shallow pack size' '
6666
'
6767

6868
test_perf 'shallow pack with --full-name-hash' '
69+
GIT_TEST_USE_FULL_NAME_HASH_WITH_SHALLOW=1 \
6970
git pack-objects --stdout --revs --sparse --shallow --full-name-hash <in-shallow >out
7071
'
7172

0 commit comments

Comments
 (0)