Skip to content

Commit ddb0596

Browse files
derrickstoleeGit for Windows Build Agent
authored andcommitted
pack-objects: add GIT_TEST_FULL_NAME_HASH
Add a new environment variable to opt-in to the --full-name-hash option in 'git pack-objects'. This allows for extra testing of the feature without repeating all of the test scenarios. But this option isn't free. There are a few tests that change behavior with the variable enabled. First, there are a few tests that are very sensitive to certain delta bases being picked. These are both involving the generation of thin bundles and then counting their objects via 'git index-pack --fix-thin' which pulls the delta base into the new packfile. For these tests, disable the option as a decent long-term option. Second, there are two tests in t5616-partial-clone.sh that I believe are actually broken scenarios. While the client is set up to clone the 'promisor-server' repo via a treeless partial clone filter (tree:0), that filter does not translate to the 'server' repo. Thus, fetching from these repos causes the server to think that the client has all reachable trees and blobs from the commits advertised as 'haves'. This leads the server to providing a thin pack assuming those objects as delta bases. Changing the name-hash algorithm presents new delta bases and thus breaks the expectations of these tests. An alternative could be to set up 'server' as a promisor server with the correct filter enabled. This may also point out more issues with partial clone being set up as a remote-based filtering mechanism and not a repository-wide setting. For now, do the minimal change to make the test work by disabling the test variable. Signed-off-by: Derrick Stolee <[email protected]>
1 parent da958eb commit ddb0596

File tree

6 files changed

+44
-6
lines changed

6 files changed

+44
-6
lines changed

builtin/pack-objects.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ struct configured_exclusion {
276276
static struct oidmap configured_exclusions;
277277

278278
static struct oidset excluded_by_config;
279-
static int use_full_name_hash;
279+
static int use_full_name_hash = -1;
280280

281281
static inline uint32_t pack_name_hash_fn(const char *name)
282282
{
@@ -4927,8 +4927,10 @@ int cmd_pack_objects(int argc,
49274927
if (pack_to_stdout || !rev_list_all)
49284928
write_bitmap_index = 0;
49294929

4930-
if (write_bitmap_index && use_full_name_hash)
4930+
if (write_bitmap_index && use_full_name_hash > 0)
49314931
die(_("currently, the --full-name-hash option is incompatible with --write-bitmap-index"));
4932+
if (use_full_name_hash < 0)
4933+
use_full_name_hash = git_env_bool("GIT_TEST_FULL_NAME_HASH", 0);
49324934

49334935
if (use_delta_islands)
49344936
strvec_push(&rp, "--topo-order");

ci/run-build-and-tests.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ linux-TEST-vars)
3131
export GIT_TEST_CHECKOUT_WORKERS=2
3232
export GIT_TEST_PACK_USE_BITMAP_BOUNDARY_TRAVERSAL=1
3333
export GIT_TEST_PACK_PATH_WALK=1
34+
export GIT_TEST_FULL_NAME_HASH=1
3435
;;
3536
linux-clang)
3637
export GIT_TEST_DEFAULT_HASH=sha1

t/README

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,10 @@ a test and then fails then the whole test run will abort. This can help to make
495495
sure the expected tests are executed and not silently skipped when their
496496
dependency breaks or is simply not present in a new environment.
497497

498+
GIT_TEST_FULL_NAME_HASH=<boolean>, when true, sets the default name-hash
499+
function in 'git pack-objects' to be the one used by the --full-name-hash
500+
option.
501+
498502
Naming Tests
499503
------------
500504

t/t5510-fetch.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,12 @@ test_expect_success 'all boundary commits are excluded' '
10801080
test_tick &&
10811081
git merge otherside &&
10821082
ad=$(git log --no-walk --format=%ad HEAD) &&
1083-
git bundle create twoside-boundary.bdl main --since="$ad" &&
1083+
1084+
# If the --full-name-hash function is used here, then no delta
1085+
# pair is found and the bundle does not expand to three objects
1086+
# when fixing the thin object.
1087+
GIT_TEST_FULL_NAME_HASH=0 \
1088+
git bundle create twoside-boundary.bdl main --since="$ad" &&
10841089
test_bundle_object_count --thin twoside-boundary.bdl 3
10851090
'
10861091

t/t5616-partial-clone.sh

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,18 @@ test_expect_success 'fetch lazy-fetches only to resolve deltas' '
516516
# Exercise to make sure it works. Git will not fetch anything from the
517517
# promisor remote other than for the big tree (because it needs to
518518
# resolve the delta).
519-
GIT_TRACE_PACKET="$(pwd)/trace" git -C client \
519+
#
520+
# TODO: the --full-name-hash option is disabled here, since this test
521+
# is fundamentally broken! When GIT_TEST_FULL_NAME_HASH=1, the server
522+
# recognizes delta bases in a different way and then sends a _blob_ to
523+
# the client with a delta base that the client does not have! This is
524+
# because the client is cloned from "promisor-server" with tree:0 but
525+
# is now fetching from "server" withot any filter. This is violating the
526+
# promise to the server that all reachable objects exist and could be
527+
# used as delta bases!
528+
GIT_TRACE_PACKET="$(pwd)/trace" \
529+
GIT_TEST_FULL_NAME_HASH=0 \
530+
git -C client \
520531
fetch "file://$(pwd)/server" main &&
521532
522533
# Verify the assumption that the client needed to fetch the delta base
@@ -535,7 +546,18 @@ test_expect_success 'fetch lazy-fetches only to resolve deltas, protocol v2' '
535546
# Exercise to make sure it works. Git will not fetch anything from the
536547
# promisor remote other than for the big blob (because it needs to
537548
# resolve the delta).
538-
GIT_TRACE_PACKET="$(pwd)/trace" git -C client \
549+
#
550+
# TODO: the --full-name-hash option is disabled here, since this test
551+
# is fundamentally broken! When GIT_TEST_FULL_NAME_HASH=1, the server
552+
# recognizes delta bases in a different way and then sends a _blob_ to
553+
# the client with a delta base that the client does not have! This is
554+
# because the client is cloned from "promisor-server" with tree:0 but
555+
# is now fetching from "server" withot any filter. This is violating the
556+
# promise to the server that all reachable objects exist and could be
557+
# used as delta bases!
558+
GIT_TRACE_PACKET="$(pwd)/trace" \
559+
GIT_TEST_FULL_NAME_HASH=0 \
560+
git -C client \
539561
fetch "file://$(pwd)/server" main &&
540562
541563
# Verify that protocol version 2 was used.

t/t6020-bundle-misc.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,11 @@ test_expect_success 'create bundle with --since option' '
247247
EOF
248248
test_cmp expect actual &&
249249
250-
git bundle create since.bdl \
250+
# If the --full-name-hash option is used, then one fewer
251+
# delta base is found and this counts a different number
252+
# of objects after performing --fix-thin.
253+
GIT_TEST_FULL_NAME_HASH=0 \
254+
git bundle create since.bdl \
251255
--since "Thu Apr 7 15:27:00 2005 -0700" \
252256
--all &&
253257

0 commit comments

Comments
 (0)