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