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 grep "detected dubious ownership" err &&
32 ! grep "fake-upload-pack running" err &&
33 test_path_is_missing script-executed
36 test_expect_success
'clone from file://... must not fetch from promisor remote and execute script' '
37 rm -f script-executed &&
38 test_must_fail git clone \
39 --upload-pack="GIT_TEST_ASSUME_DIFFERENT_OWNER=true git-upload-pack" \
40 "file://$(pwd)/evil" clone2 2>err &&
41 grep "detected dubious ownership" err &&
42 ! grep "fake-upload-pack running" err &&
43 test_path_is_missing script-executed
46 test_expect_success
'fetch from file://... must not fetch from promisor remote and execute script' '
47 rm -f script-executed &&
48 test_must_fail git fetch \
49 --upload-pack="GIT_TEST_ASSUME_DIFFERENT_OWNER=true git-upload-pack" \
50 "file://$(pwd)/evil" 2>err &&
51 grep "detected dubious ownership" err &&
52 ! grep "fake-upload-pack running" err &&
53 test_path_is_missing script-executed
56 test_expect_success
'pack-objects should fetch from promisor remote and execute script' '
57 rm -f script-executed &&
58 echo "HEAD" | test_must_fail git -C evil pack-objects --revs --stdout >/dev/null 2>err &&
59 grep "fake-upload-pack running" err &&
60 test_path_is_file script-executed
63 test_expect_success
'clone from promisor remote does not lazy-fetch by default' '
64 rm -f script-executed &&
65 test_must_fail git clone evil no-lazy 2>err &&
66 grep "lazy fetching disabled" err &&
67 test_path_is_missing script-executed
70 test_expect_success
'promisor lazy-fetching can be re-enabled' '
71 rm -f script-executed &&
72 test_must_fail env GIT_NO_LAZY_FETCH=0 \
73 git clone evil lazy-ok 2>err &&
74 grep "fake-upload-pack running" err &&
75 test_path_is_file script-executed