Merge branch 'ss/user-manual'
[git] / t / t5542-push-http-shallow.sh
1 #!/bin/sh
2
3 test_description='push from/to a shallow clone over http'
4
5 . ./test-lib.sh
6 . "$TEST_DIRECTORY"/lib-httpd.sh
7 start_httpd
8
9 commit() {
10         echo "$1" >tracked &&
11         git add tracked &&
12         git commit -m "$1"
13 }
14
15 test_expect_success 'setup' '
16         git config --global transfer.fsckObjects true &&
17         commit 1 &&
18         commit 2 &&
19         commit 3 &&
20         commit 4 &&
21         git clone . full &&
22         (
23         git init full-abc &&
24         cd full-abc &&
25         commit a &&
26         commit b &&
27         commit c
28         ) &&
29         git clone --no-local --depth=2 .git shallow &&
30         git --git-dir=shallow/.git log --format=%s >actual &&
31         cat <<EOF >expect &&
32 4
33 3
34 EOF
35         test_cmp expect actual &&
36         git clone --no-local --depth=2 full-abc/.git shallow2 &&
37         git --git-dir=shallow2/.git log --format=%s >actual &&
38         cat <<EOF >expect &&
39 c
40 b
41 EOF
42         test_cmp expect actual
43 '
44
45 test_expect_success 'push to shallow repo via http' '
46         git clone --bare --no-local shallow "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
47         (
48         cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
49         git config http.receivepack true
50         ) &&
51         (
52         cd full &&
53         commit 9 &&
54         git push $HTTPD_URL/smart/repo.git +master:refs/remotes/top/master
55         ) &&
56         (
57         cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
58         git fsck &&
59         git log --format=%s top/master >actual &&
60         cat <<EOF >expect &&
61 9
62 4
63 3
64 EOF
65         test_cmp expect actual
66         )
67 '
68
69 test_expect_success 'push from shallow repo via http' '
70         mv "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" shallow-upstream.git &&
71         git clone --bare --no-local full "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
72         (
73         cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
74         git config http.receivepack true
75         ) &&
76         commit 10 &&
77         git push $HTTPD_URL/smart/repo.git +master:refs/remotes/top/master &&
78         (
79         cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
80         git fsck &&
81         git log --format=%s top/master >actual &&
82         cat <<EOF >expect &&
83 10
84 4
85 3
86 2
87 1
88 EOF
89         test_cmp expect actual
90         )
91 '
92
93 stop_httpd
94 test_done