receive-pack: support pushing to a shallow clone via http

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nguyễn Thái Ngọc Duy committed Dec 5, 2013 at 20:02 UTC c29a7b8b3f71c1bede1f57626bafe120280aaea3
2 files changed +35 -3
builtin/receive-pack.c
-3
@@ -1179,9 +1179,6 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
1179 if (!enter_repo(dir, 0))
1180 die("'%s' does not appear to be a git repository", dir);
1181
1182 - if (is_repository_shallow() && stateless_rpc)
1183 - die("attempt to push into a shallow repository");
1184 -
1182 git_config(receive_pack_config, NULL);
1183
1184 if (0 <= transfer_unpack_limit)
t/t5538-push-shallow.sh
+35
@@ -16,6 +16,7 @@ test_expect_success 'setup' '
16 commit 2 &&
17 commit 3 &&
18 commit 4 &&
19 + git clone . full &&
20 (
21 git init full-abc &&
22 cd full-abc &&
@@ -120,4 +121,38 @@ EOF
121 )
122 '
123
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
158 test_done