Skip to content

Commit c29a7b8

Browse files
pcloudsgitster
authored andcommitted
receive-pack: support pushing to a shallow clone via http
Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1609488 commit c29a7b8

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

builtin/receive-pack.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,9 +1179,6 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
11791179
if (!enter_repo(dir, 0))
11801180
die("'%s' does not appear to be a git repository", dir);
11811181

1182-
if (is_repository_shallow() && stateless_rpc)
1183-
die("attempt to push into a shallow repository");
1184-
11851182
git_config(receive_pack_config, NULL);
11861183

11871184
if (0 <= transfer_unpack_limit)

t/t5538-push-shallow.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ test_expect_success 'setup' '
1616
commit 2 &&
1717
commit 3 &&
1818
commit 4 &&
19+
git clone . full &&
1920
(
2021
git init full-abc &&
2122
cd full-abc &&
@@ -120,4 +121,38 @@ EOF
120121
)
121122
'
122123

124+
if test -n "$NO_CURL" -o -z "$GIT_TEST_HTTPD"; then
125+
say 'skipping remaining tests, git built without http support'
126+
test_done
127+
fi
128+
129+
LIB_HTTPD_PORT=${LIB_HTTPD_PORT-'5537'}
130+
. "$TEST_DIRECTORY"/lib-httpd.sh
131+
start_httpd
132+
133+
test_expect_success 'push to shallow repo via http' '
134+
git clone --bare --no-local shallow "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
135+
(
136+
cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
137+
git config http.receivepack true
138+
) &&
139+
(
140+
cd full &&
141+
commit 9 &&
142+
git push $HTTPD_URL/smart/repo.git +master:refs/remotes/top/master
143+
) &&
144+
(
145+
cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
146+
git fsck &&
147+
git log --format=%s top/master >actual &&
148+
cat <<EOF >expect &&
149+
9
150+
4
151+
3
152+
EOF
153+
test_cmp expect actual
154+
)
155+
'
156+
157+
stop_httpd
123158
test_done

0 commit comments

Comments
 (0)