Skip to content

Commit b5c1279

Browse files
committed
Merge branch 'jk/http-push-to-empty' into maint
* jk/http-push-to-empty: remote-curl: don't pass back fake refs Conflicts: remote-curl.c
2 parents 81eaa06 + 02f7914 commit b5c1279

File tree

2 files changed

+36
-3
lines changed

2 files changed

+36
-3
lines changed

remote-curl.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ static int write_discovery(int in, int out, void *data)
188188
return err;
189189
}
190190

191-
static struct ref *parse_git_refs(struct discovery *heads)
191+
static struct ref *parse_git_refs(struct discovery *heads, int for_push)
192192
{
193193
struct ref *list = NULL;
194194
struct async async;
@@ -200,7 +200,8 @@ static struct ref *parse_git_refs(struct discovery *heads)
200200

201201
if (start_async(&async))
202202
die("cannot start thread to parse advertised refs");
203-
get_remote_heads(async.out, &list, 0, NULL);
203+
get_remote_heads(async.out, &list,
204+
for_push ? REF_NORMAL : 0, NULL);
204205
close(async.out);
205206
if (finish_async(&async))
206207
die("ref parsing thread failed");
@@ -268,7 +269,7 @@ static struct ref *get_refs(int for_push)
268269
heads = discover_refs("git-upload-pack");
269270

270271
if (heads->proto_git)
271-
return parse_git_refs(heads);
272+
return parse_git_refs(heads, for_push);
272273
return parse_info_refs(heads);
273274
}
274275

t/t5541-http-push.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,5 +154,37 @@ test_expect_success 'push (chunked)' '
154154
test $HEAD = $(git rev-parse --verify HEAD))
155155
'
156156

157+
test_expect_success 'push --all can push to empty repo' '
158+
d=$HTTPD_DOCUMENT_ROOT_PATH/empty-all.git &&
159+
git init --bare "$d" &&
160+
git --git-dir="$d" config http.receivepack true &&
161+
git push --all "$HTTPD_URL"/smart/empty-all.git
162+
'
163+
164+
test_expect_success 'push --mirror can push to empty repo' '
165+
d=$HTTPD_DOCUMENT_ROOT_PATH/empty-mirror.git &&
166+
git init --bare "$d" &&
167+
git --git-dir="$d" config http.receivepack true &&
168+
git push --mirror "$HTTPD_URL"/smart/empty-mirror.git
169+
'
170+
171+
test_expect_success 'push --all to repo with alternates' '
172+
s=$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git &&
173+
d=$HTTPD_DOCUMENT_ROOT_PATH/alternates-all.git &&
174+
git clone --bare --shared "$s" "$d" &&
175+
git --git-dir="$d" config http.receivepack true &&
176+
git --git-dir="$d" repack -adl &&
177+
git push --all "$HTTPD_URL"/smart/alternates-all.git
178+
'
179+
180+
test_expect_success 'push --mirror to repo with alternates' '
181+
s=$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git &&
182+
d=$HTTPD_DOCUMENT_ROOT_PATH/alternates-mirror.git &&
183+
git clone --bare --shared "$s" "$d" &&
184+
git --git-dir="$d" config http.receivepack true &&
185+
git --git-dir="$d" repack -adl &&
186+
git push --mirror "$HTTPD_URL"/smart/alternates-mirror.git
187+
'
188+
157189
stop_httpd
158190
test_done

0 commit comments

Comments
 (0)