There are many tests that validate whether 'git pack-objects' works as expected. Instead of duplicating these tests, add a new test environment variable, GIT_TEST_PACK_PATH_WALK, that implies --path-walk by default when specified. This was useful in testing the implementation of the --path-walk implementation, helping to find tests that are overly specific to the default object walk. These include: - t0411-clone-from-partial.sh : One test fetches from a repo that does not have the boundary objects. This causes the path-based walk to fail. Disable the variable for this test. - t5306-pack-nobase.sh : Similar to t0411, one test fetches from a repo without a boundary object. - t5310-pack-bitmaps.sh : One test compares the case when packing with bitmaps to the case when packing without them. Since we disable the test variable when writing bitmaps, this causes a difference in the object list (the --path-walk option adds an extra object). Specify --no-path-walk in both processes for the comparison. Another test checks for a specific delta base, but when computing dynamically without using bitmaps, the base object it too small to be considered in the delta calculations so no base is used. - t5316-pack-delta-depth.sh : This script cares about certain delta choices and their chain lengths. The --path-walk option changes how these chains are selected, and thus changes the results of this test. - t5322-pack-objects-sparse.sh : This demonstrates the effectiveness of the --sparse option and how it combines with --path-walk. - t5332-multi-pack-reuse.sh : This test verifies that the preferred pack is used for delta reuse when possible. The --path-walk option is not currently aware of the preferred pack at all, so finds a different delta base. - t7406-submodule-update.sh : When using the variable, the --depth option collides with the --path-walk feature, resulting in a warning message. Disable the variable so this warning does not appear. I want to call out one specific test change that is only temporary: - t5530-upload-pack-error.sh : One test cares specifically about an "unable to read" error message. Since the current implementation performs delta calculations within the path-walk API callback, a different "unable to get size" error message appears. When this is changed in a future refactoring, this test change can be reverted. Similar to GIT_TEST_NAME_HASH_VERSION, we do not add this option to the linux-TEST-vars CI build as that's already an overloaded build. Signed-off-by: Derrick Stolee <stolee@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
82 lines
2.6 KiB
Bash
Executable File
82 lines
2.6 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
test_description='check that local clone does not fetch from promisor remotes'
|
|
|
|
. ./test-lib.sh
|
|
|
|
test_expect_success 'create evil repo' '
|
|
git init tmp &&
|
|
test_commit -C tmp a &&
|
|
git -C tmp config uploadpack.allowfilter 1 &&
|
|
git clone --filter=blob:none --no-local --no-checkout tmp evil &&
|
|
rm -rf tmp &&
|
|
|
|
git -C evil config remote.origin.uploadpack \"\$TRASH_DIRECTORY/fake-upload-pack\" &&
|
|
write_script fake-upload-pack <<-\EOF &&
|
|
echo >&2 "fake-upload-pack running"
|
|
>"$TRASH_DIRECTORY/script-executed"
|
|
exit 1
|
|
EOF
|
|
export TRASH_DIRECTORY &&
|
|
|
|
# empty shallow file disables local clone optimization
|
|
>evil/.git/shallow
|
|
'
|
|
|
|
test_expect_success 'local clone must not fetch from promisor remote and execute script' '
|
|
rm -f script-executed &&
|
|
test_must_fail git clone \
|
|
--upload-pack="GIT_TEST_ASSUME_DIFFERENT_OWNER=true git-upload-pack" \
|
|
evil clone1 2>err &&
|
|
test_grep ! "fake-upload-pack running" err &&
|
|
test_path_is_missing script-executed
|
|
'
|
|
|
|
test_expect_success 'clone from file://... must not fetch from promisor remote and execute script' '
|
|
rm -f script-executed &&
|
|
test_must_fail git clone \
|
|
--upload-pack="GIT_TEST_ASSUME_DIFFERENT_OWNER=true git-upload-pack" \
|
|
"file://$(pwd)/evil" clone2 2>err &&
|
|
test_grep ! "fake-upload-pack running" err &&
|
|
test_path_is_missing script-executed
|
|
'
|
|
|
|
test_expect_success 'fetch from file://... must not fetch from promisor remote and execute script' '
|
|
rm -f script-executed &&
|
|
test_must_fail git fetch \
|
|
--upload-pack="GIT_TEST_ASSUME_DIFFERENT_OWNER=true git-upload-pack" \
|
|
"file://$(pwd)/evil" 2>err &&
|
|
test_grep ! "fake-upload-pack running" err &&
|
|
test_path_is_missing script-executed
|
|
'
|
|
|
|
test_expect_success 'pack-objects should fetch from promisor remote and execute script' '
|
|
rm -f script-executed &&
|
|
echo "HEAD" | test_must_fail git -C evil pack-objects --revs --stdout >/dev/null 2>err &&
|
|
test_grep "fake-upload-pack running" err &&
|
|
test_path_is_file script-executed
|
|
'
|
|
|
|
test_expect_success 'clone from promisor remote does not lazy-fetch by default' '
|
|
rm -f script-executed &&
|
|
|
|
# The --path-walk feature of "git pack-objects" is not
|
|
# compatible with this kind of fetch from an incomplete repo.
|
|
GIT_TEST_PACK_PATH_WALK=0 &&
|
|
export GIT_TEST_PACK_PATH_WALK &&
|
|
|
|
test_must_fail git clone evil no-lazy 2>err &&
|
|
test_grep "lazy fetching disabled" err &&
|
|
test_path_is_missing script-executed
|
|
'
|
|
|
|
test_expect_success 'promisor lazy-fetching can be re-enabled' '
|
|
rm -f script-executed &&
|
|
test_must_fail env GIT_NO_LAZY_FETCH=0 \
|
|
git clone evil lazy-ok 2>err &&
|
|
test_grep "fake-upload-pack running" err &&
|
|
test_path_is_file script-executed
|
|
'
|
|
|
|
test_done
|