1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-10-31 22:37:54 +01:00
git/t/t5538-push-shallow.sh
Jeff King 3bb486e439 tests: auto-set LIB_HTTPD_PORT from test name
We set the default apache port for each of the httpd tests
to the 4-digit test number of the test script. We want these
to remain unique so that the tests do not conflict with each
other when run in parallel.

Instead of doing it manually in each test script, let's just
set it from the test name at run time. This is simpler, and
is one less thing to be updated when test scripts are
renamed (e.g., when being re-rolled or when conflicting
after being merged with another topic).

Incidentally, this fixes a case where t5537 and t5538 used
the same port number (5537), and could conflict with each
other when run in parallel.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-02-10 10:20:45 -08:00

182 lines
3.6 KiB
Bash
Executable file

#!/bin/sh
test_description='push from/to a shallow clone'
. ./test-lib.sh
commit() {
echo "$1" >tracked &&
git add tracked &&
git commit -m "$1"
}
test_expect_success 'setup' '
git config --global transfer.fsckObjects true &&
commit 1 &&
commit 2 &&
commit 3 &&
commit 4 &&
git clone . full &&
(
git init full-abc &&
cd full-abc &&
commit a &&
commit b &&
commit c
) &&
git clone --no-local --depth=2 .git shallow &&
git --git-dir=shallow/.git log --format=%s >actual &&
cat <<EOF >expect &&
4
3
EOF
test_cmp expect actual &&
git clone --no-local --depth=2 full-abc/.git shallow2 &&
git --git-dir=shallow2/.git log --format=%s >actual &&
cat <<EOF >expect &&
c
b
EOF
test_cmp expect actual
'
test_expect_success 'push from shallow clone' '
(
cd shallow &&
commit 5 &&
git push ../.git +master:refs/remotes/shallow/master
) &&
git log --format=%s shallow/master >actual &&
git fsck &&
cat <<EOF >expect &&
5
4
3
2
1
EOF
test_cmp expect actual
'
test_expect_success 'push from shallow clone, with grafted roots' '
(
cd shallow2 &&
test_must_fail git push ../.git +master:refs/remotes/shallow2/master 2>err &&
grep "shallow2/master.*shallow update not allowed" err
) &&
test_must_fail git rev-parse shallow2/master &&
git fsck
'
test_expect_success 'add new shallow root with receive.updateshallow on' '
test_config receive.shallowupdate true &&
(
cd shallow2 &&
git push ../.git +master:refs/remotes/shallow2/master
) &&
git log --format=%s shallow2/master >actual &&
git fsck &&
cat <<EOF >expect &&
c
b
EOF
test_cmp expect actual
'
test_expect_success 'push from shallow to shallow' '
(
cd shallow &&
git --git-dir=../shallow2/.git config receive.shallowupdate true &&
git push ../shallow2/.git +master:refs/remotes/shallow/master &&
git --git-dir=../shallow2/.git config receive.shallowupdate false
) &&
(
cd shallow2 &&
git log --format=%s shallow/master >actual &&
git fsck &&
cat <<EOF >expect &&
5
4
3
EOF
test_cmp expect actual
)
'
test_expect_success 'push from full to shallow' '
! git --git-dir=shallow2/.git cat-file blob `echo 1|git hash-object --stdin` &&
commit 1 &&
git push shallow2/.git +master:refs/remotes/top/master &&
(
cd shallow2 &&
git log --format=%s top/master >actual &&
git fsck &&
cat <<EOF >expect &&
1
4
3
EOF
test_cmp expect actual &&
git cat-file blob `echo 1|git hash-object --stdin` >/dev/null
)
'
if test -n "$NO_CURL" -o -z "$GIT_TEST_HTTPD"; then
say 'skipping remaining tests, git built without http support'
test_done
fi
. "$TEST_DIRECTORY"/lib-httpd.sh
start_httpd
test_expect_success 'push to shallow repo via http' '
git clone --bare --no-local shallow "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
(
cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
git config http.receivepack true
) &&
(
cd full &&
commit 9 &&
git push $HTTPD_URL/smart/repo.git +master:refs/remotes/top/master
) &&
(
cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
git fsck &&
git log --format=%s top/master >actual &&
cat <<EOF >expect &&
9
4
3
EOF
test_cmp expect actual
)
'
test_expect_success 'push from shallow repo via http' '
mv "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" shallow-upstream.git &&
git clone --bare --no-local full "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
(
cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
git config http.receivepack true
) &&
commit 10 &&
git push $HTTPD_URL/smart/repo.git +master:refs/remotes/top/master &&
(
cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
git fsck &&
git log --format=%s top/master >actual &&
cat <<EOF >expect &&
10
1
4
3
2
1
EOF
test_cmp expect actual
)
'
stop_httpd
test_done