Skip to content

Commit ce4b382

Browse files
derrickstoleedscho
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 c07ed6f commit ce4b382

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
@@ -269,7 +269,7 @@ struct configured_exclusion {
269269
static struct oidmap configured_exclusions;
270270

271271
static struct oidset excluded_by_config;
272-
static int use_full_name_hash;
272+
static int use_full_name_hash = -1;
273273

274274
static inline uint32_t pack_name_hash_fn(const char *name)
275275
{
@@ -4600,8 +4600,10 @@ int cmd_pack_objects(int argc,
46004600
if (pack_to_stdout || !rev_list_all)
46014601
write_bitmap_index = 0;
46024602

4603-
if (write_bitmap_index && use_full_name_hash)
4603+
if (write_bitmap_index && use_full_name_hash > 0)
46044604
die(_("currently, the --full-name-hash option is incompatible with --write-bitmap-index"));
4605+
if (use_full_name_hash < 0)
4606+
use_full_name_hash = git_env_bool("GIT_TEST_FULL_NAME_HASH", 0);
46054607

46064608
if (use_delta_islands)
46074609
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_NO_WRITE_REV_INDEX=1
3232
export GIT_TEST_CHECKOUT_WORKERS=2
3333
export GIT_TEST_PACK_USE_BITMAP_BOUNDARY_TRAVERSAL=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
@@ -471,6 +471,10 @@ a test and then fails then the whole test run will abort. This can help to make
471471
sure the expected tests are executed and not silently skipped when their
472472
dependency breaks or is simply not present in a new environment.
473473

474+
GIT_TEST_FULL_NAME_HASH=<boolean>, when true, sets the default name-hash
475+
function in 'git pack-objects' to be the one used by the --full-name-hash
476+
option.
477+
474478
Naming Tests
475479
------------
476480

t/t5510-fetch.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1253,7 +1253,12 @@ test_expect_success 'all boundary commits are excluded' '
12531253
test_tick &&
12541254
git merge otherside &&
12551255
ad=$(git log --no-walk --format=%ad HEAD) &&
1256-
git bundle create twoside-boundary.bdl main --since="$ad" &&
1256+
1257+
# If the --full-name-hash function is used here, then no delta
1258+
# pair is found and the bundle does not expand to three objects
1259+
# when fixing the thin object.
1260+
GIT_TEST_FULL_NAME_HASH=0 \
1261+
git bundle create twoside-boundary.bdl main --since="$ad" &&
12571262
test_bundle_object_count --thin twoside-boundary.bdl 3
12581263
'
12591264

t/t5616-partial-clone.sh

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,18 @@ test_expect_success 'fetch lazy-fetches only to resolve deltas' '
515515
# Exercise to make sure it works. Git will not fetch anything from the
516516
# promisor remote other than for the big tree (because it needs to
517517
# resolve the delta).
518-
GIT_TRACE_PACKET="$(pwd)/trace" git -C client \
518+
#
519+
# TODO: the --full-name-hash option is disabled here, since this test
520+
# is fundamentally broken! When GIT_TEST_FULL_NAME_HASH=1, the server
521+
# recognizes delta bases in a different way and then sends a _blob_ to
522+
# the client with a delta base that the client does not have! This is
523+
# because the client is cloned from "promisor-server" with tree:0 but
524+
# is now fetching from "server" withot any filter. This is violating the
525+
# promise to the server that all reachable objects exist and could be
526+
# used as delta bases!
527+
GIT_TRACE_PACKET="$(pwd)/trace" \
528+
GIT_TEST_FULL_NAME_HASH=0 \
529+
git -C client \
519530
fetch "file://$(pwd)/server" main &&
520531
521532
# Verify the assumption that the client needed to fetch the delta base
@@ -534,7 +545,18 @@ test_expect_success 'fetch lazy-fetches only to resolve deltas, protocol v2' '
534545
# Exercise to make sure it works. Git will not fetch anything from the
535546
# promisor remote other than for the big blob (because it needs to
536547
# resolve the delta).
537-
GIT_TRACE_PACKET="$(pwd)/trace" git -C client \
548+
#
549+
# TODO: the --full-name-hash option is disabled here, since this test
550+
# is fundamentally broken! When GIT_TEST_FULL_NAME_HASH=1, the server
551+
# recognizes delta bases in a different way and then sends a _blob_ to
552+
# the client with a delta base that the client does not have! This is
553+
# because the client is cloned from "promisor-server" with tree:0 but
554+
# is now fetching from "server" withot any filter. This is violating the
555+
# promise to the server that all reachable objects exist and could be
556+
# used as delta bases!
557+
GIT_TRACE_PACKET="$(pwd)/trace" \
558+
GIT_TEST_FULL_NAME_HASH=0 \
559+
git -C client \
538560
fetch "file://$(pwd)/server" main &&
539561
540562
# 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
@@ -246,7 +246,11 @@ test_expect_success 'create bundle with --since option' '
246246
EOF
247247
test_cmp expect actual &&
248248
249-
git bundle create since.bdl \
249+
# If the --full-name-hash option is used, then one fewer
250+
# delta base is found and this counts a different number
251+
# of objects after performing --fix-thin.
252+
GIT_TEST_FULL_NAME_HASH=0 \
253+
git bundle create since.bdl \
250254
--since "Thu Apr 7 15:27:00 2005 -0700" \
251255
--all &&
252256

0 commit comments

Comments
 (0)