Sync with 'master'
[alt-git.git] / t / t0411-clone-from-partial.sh
blob932bf2067daaeb88de744762f2cdbc0b59c8b565
1 #!/bin/sh
3 test_description='check that local clone does not fetch from promisor remotes'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 test_expect_success 'create evil repo' '
9 git init tmp &&
10 test_commit -C tmp a &&
11 git -C tmp config uploadpack.allowfilter 1 &&
12 git clone --filter=blob:none --no-local --no-checkout tmp evil &&
13 rm -rf tmp &&
15 git -C evil config remote.origin.uploadpack \"\$TRASH_DIRECTORY/fake-upload-pack\" &&
16 write_script fake-upload-pack <<-\EOF &&
17 echo >&2 "fake-upload-pack running"
18 >"$TRASH_DIRECTORY/script-executed"
19 exit 1
20 EOF
21 export TRASH_DIRECTORY &&
23 # empty shallow file disables local clone optimization
24 >evil/.git/shallow
27 test_expect_success 'local clone must not fetch from promisor remote and execute script' '
28 rm -f script-executed &&
29 test_must_fail git clone \
30 --upload-pack="GIT_TEST_ASSUME_DIFFERENT_OWNER=true git-upload-pack" \
31 evil clone1 2>err &&
32 test_grep "detected dubious ownership" err &&
33 test_grep ! "fake-upload-pack running" err &&
34 test_path_is_missing script-executed
37 test_expect_success 'clone from file://... must not fetch from promisor remote and execute script' '
38 rm -f script-executed &&
39 test_must_fail git clone \
40 --upload-pack="GIT_TEST_ASSUME_DIFFERENT_OWNER=true git-upload-pack" \
41 "file://$(pwd)/evil" clone2 2>err &&
42 test_grep "detected dubious ownership" err &&
43 test_grep ! "fake-upload-pack running" err &&
44 test_path_is_missing script-executed
47 test_expect_success 'fetch from file://... must not fetch from promisor remote and execute script' '
48 rm -f script-executed &&
49 test_must_fail git fetch \
50 --upload-pack="GIT_TEST_ASSUME_DIFFERENT_OWNER=true git-upload-pack" \
51 "file://$(pwd)/evil" 2>err &&
52 test_grep "detected dubious ownership" err &&
53 test_grep ! "fake-upload-pack running" err &&
54 test_path_is_missing script-executed
57 test_expect_success 'pack-objects should fetch from promisor remote and execute script' '
58 rm -f script-executed &&
59 echo "HEAD" | test_must_fail git -C evil pack-objects --revs --stdout >/dev/null 2>err &&
60 test_grep "fake-upload-pack running" err &&
61 test_path_is_file script-executed
64 test_expect_success 'clone from promisor remote does not lazy-fetch by default' '
65 rm -f script-executed &&
66 test_must_fail git clone evil no-lazy 2>err &&
67 test_grep "lazy fetching disabled" err &&
68 test_path_is_missing script-executed
71 test_expect_success 'promisor lazy-fetching can be re-enabled' '
72 rm -f script-executed &&
73 test_must_fail env GIT_NO_LAZY_FETCH=0 \
74 git clone evil lazy-ok 2>err &&
75 test_grep "fake-upload-pack running" err &&
76 test_path_is_file script-executed
79 test_done