Skip to content

Commit

Permalink
receive-pack: support pushing to a shallow clone via http
Browse files Browse the repository at this point in the history
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Nguyễn Thái Ngọc Duy authored and Junio C Hamano committed Dec 11, 2013
1 parent 1609488 commit c29a7b8
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
3 changes: 0 additions & 3 deletions builtin/receive-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -1179,9 +1179,6 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
if (!enter_repo(dir, 0))
die("'%s' does not appear to be a git repository", dir);

if (is_repository_shallow() && stateless_rpc)
die("attempt to push into a shallow repository");

git_config(receive_pack_config, NULL);

if (0 <= transfer_unpack_limit)
Expand Down
35 changes: 35 additions & 0 deletions t/t5538-push-shallow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ test_expect_success 'setup' '
commit 2 &&
commit 3 &&
commit 4 &&
git clone . full &&
(
git init full-abc &&
cd full-abc &&
Expand Down Expand Up @@ -120,4 +121,38 @@ EOF
)
'

if test -n "$NO_CURL" -o -z "$GIT_TEST_HTTPD"; then
say 'skipping remaining tests, git built without http support'
test_done
fi

LIB_HTTPD_PORT=${LIB_HTTPD_PORT-'5537'}
. "$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
)
'

stop_httpd
test_done

0 comments on commit c29a7b8

Please sign in to comment.