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