clone_submodule: avoid using `access()` on directories
[git.git] / t / t0411-clone-from-partial.sh
blobb3d6ddc4bc2d99993dc1ba37edd55c5beff3fd2b
1 #!/bin/sh
3 test_description='check that local clone does not fetch from promisor remotes'
5 . ./test-lib.sh
7 test_expect_success 'create evil repo' '
8 git init tmp &&
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 &&
12 rm -rf tmp &&
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"
18 exit 1
19 EOF
20 export TRASH_DIRECTORY &&
22 # empty shallow file disables local clone optimization
23 >evil/.git/shallow
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" \
30 evil clone1 2>err &&
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
78 test_done