]> git.ipfire.org Git - thirdparty/git.git/blob - t/t5558-clone-bundle-uri.sh
packfile: delete .idx files before .pack files
[thirdparty/git.git] / t / t5558-clone-bundle-uri.sh
1 #!/bin/sh
2
3 test_description='test fetching bundles with --bundle-uri'
4
5 . ./test-lib.sh
6
7 test_expect_success 'fail to clone from non-existent file' '
8 test_when_finished rm -rf test &&
9 git clone --bundle-uri="$(pwd)/does-not-exist" . test 2>err &&
10 grep "failed to download bundle from URI" err
11 '
12
13 test_expect_success 'fail to clone from non-bundle file' '
14 test_when_finished rm -rf test &&
15 echo bogus >bogus &&
16 git clone --bundle-uri="$(pwd)/bogus" . test 2>err &&
17 grep "is not a bundle" err
18 '
19
20 test_expect_success 'create bundle' '
21 git init clone-from &&
22 git -C clone-from checkout -b topic &&
23 test_commit -C clone-from A &&
24 test_commit -C clone-from B &&
25 git -C clone-from bundle create B.bundle topic
26 '
27
28 test_expect_success 'clone with path bundle' '
29 git clone --bundle-uri="clone-from/B.bundle" \
30 clone-from clone-path &&
31 git -C clone-path rev-parse refs/bundles/topic >actual &&
32 git -C clone-from rev-parse topic >expect &&
33 test_cmp expect actual
34 '
35
36 test_expect_success 'clone with file:// bundle' '
37 git clone --bundle-uri="file://$(pwd)/clone-from/B.bundle" \
38 clone-from clone-file &&
39 git -C clone-file rev-parse refs/bundles/topic >actual &&
40 git -C clone-from rev-parse topic >expect &&
41 test_cmp expect actual
42 '
43
44 #########################################################################
45 # HTTP tests begin here
46
47 . "$TEST_DIRECTORY"/lib-httpd.sh
48 start_httpd
49
50 test_expect_success 'fail to fetch from non-existent HTTP URL' '
51 test_when_finished rm -rf test &&
52 git clone --bundle-uri="$HTTPD_URL/does-not-exist" . test 2>err &&
53 grep "failed to download bundle from URI" err
54 '
55
56 test_expect_success 'fail to fetch from non-bundle HTTP URL' '
57 test_when_finished rm -rf test &&
58 echo bogus >"$HTTPD_DOCUMENT_ROOT_PATH/bogus" &&
59 git clone --bundle-uri="$HTTPD_URL/bogus" . test 2>err &&
60 grep "is not a bundle" err
61 '
62
63 test_expect_success 'clone HTTP bundle' '
64 cp clone-from/B.bundle "$HTTPD_DOCUMENT_ROOT_PATH/B.bundle" &&
65
66 git clone --no-local --mirror clone-from \
67 "$HTTPD_DOCUMENT_ROOT_PATH/fetch.git" &&
68
69 git clone --bundle-uri="$HTTPD_URL/B.bundle" \
70 "$HTTPD_URL/smart/fetch.git" clone-http &&
71 git -C clone-http rev-parse refs/bundles/topic >actual &&
72 git -C clone-from rev-parse topic >expect &&
73 test_cmp expect actual &&
74
75 test_config -C clone-http log.excludedecoration refs/bundle/
76 '
77
78 # Do not add tests here unless they use the HTTP server, as they will
79 # not run unless the HTTP dependencies exist.
80
81 test_done