3 test_description
='check that local clone does not fetch from promisor remotes'
7 test_expect_success
'create evil repo' '
9 test_commit -C tmp a &&
10 git -C tmp config uploadpack.allowfilter 1 &&
11 git clone --filter=blob:none --no-local --no-checkout tmp evil &&
14 git -C evil config remote.origin.uploadpack \"\$TRASH_DIRECTORY/fake-upload-pack\" &&
15 write_script fake-upload-pack <<-\EOF &&
16 echo >&2 "fake-upload-pack running"
17 >"$TRASH_DIRECTORY/script-executed"
20 export TRASH_DIRECTORY &&
22 # empty shallow file disables local clone optimization
26 test_expect_success
'local clone must not fetch from promisor remote and execute script' '
27 rm -f script-executed &&
28 test_must_fail git clone \
29 --upload-pack="GIT_TEST_ASSUME_DIFFERENT_OWNER=true git-upload-pack" \
31 test_grep ! "fake-upload-pack running" err &&
32 test_path_is_missing script-executed
35 test_expect_success
'clone from file://... must not fetch from promisor remote and execute script' '
36 rm -f script-executed &&
37 test_must_fail git clone \
38 --upload-pack="GIT_TEST_ASSUME_DIFFERENT_OWNER=true git-upload-pack" \
39 "file://$(pwd)/evil" clone2 2>err &&
40 test_grep ! "fake-upload-pack running" err &&
41 test_path_is_missing script-executed
44 test_expect_success
'fetch from file://... must not fetch from promisor remote and execute script' '
45 rm -f script-executed &&
46 test_must_fail git fetch \
47 --upload-pack="GIT_TEST_ASSUME_DIFFERENT_OWNER=true git-upload-pack" \
48 "file://$(pwd)/evil" 2>err &&
49 test_grep ! "fake-upload-pack running" err &&
50 test_path_is_missing script-executed
53 test_expect_success
'pack-objects should fetch from promisor remote and execute script' '
54 rm -f script-executed &&
55 echo "HEAD" | test_must_fail git -C evil pack-objects --revs --stdout >/dev/null 2>err &&
56 test_grep "fake-upload-pack running" err &&
57 test_path_is_file script-executed
60 test_expect_success
'clone from promisor remote does not lazy-fetch by default' '
61 rm -f script-executed &&
62 test_must_fail git clone evil no-lazy 2>err &&
63 test_grep "lazy fetching disabled" err &&
64 test_path_is_missing script-executed
67 test_expect_success
'promisor lazy-fetching can be re-enabled' '
68 rm -f script-executed &&
69 test_must_fail env GIT_NO_LAZY_FETCH=0 \
70 git clone evil lazy-ok 2>err &&
71 test_grep "fake-upload-pack running" err &&
72 test_path_is_file script-executed