Merge branch 'sp/smart-http-failure-to-push' into maint

* sp/smart-http-failure-to-push:
  remote-curl: Fix push status report when all branches fail
This commit is contained in:
Junio C Hamano 2012-02-05 23:58:43 -08:00
Родитель e27d620e91 5238cbf656
Коммит f2120eb4db
2 изменённых файлов: 33 добавлений и 4 удалений

Просмотреть файл

@ -807,7 +807,7 @@ static int push(int nr_spec, char **specs)
static void parse_push(struct strbuf *buf) static void parse_push(struct strbuf *buf)
{ {
char **specs = NULL; char **specs = NULL;
int alloc_spec = 0, nr_spec = 0, i; int alloc_spec = 0, nr_spec = 0, i, ret;
do { do {
if (!prefixcmp(buf->buf, "push ")) { if (!prefixcmp(buf->buf, "push ")) {
@ -824,12 +824,13 @@ static void parse_push(struct strbuf *buf)
break; break;
} while (1); } while (1);
if (push(nr_spec, specs)) ret = push(nr_spec, specs);
exit(128); /* error already reported */
printf("\n"); printf("\n");
fflush(stdout); fflush(stdout);
if (ret)
exit(128); /* error already reported */
free_specs: free_specs:
for (i = 0; i < nr_spec; i++) for (i = 0; i < nr_spec; i++)
free(specs[i]); free(specs[i]);

Просмотреть файл

@ -96,6 +96,32 @@ test_expect_success 'create and delete remote branch' '
test_must_fail git show-ref --verify refs/remotes/origin/dev test_must_fail git show-ref --verify refs/remotes/origin/dev
' '
cat >"$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git/hooks/update" <<EOF
#!/bin/sh
exit 1
EOF
chmod a+x "$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git/hooks/update"
cat >exp <<EOF
remote: error: hook declined to update refs/heads/dev2
To http://127.0.0.1:$LIB_HTTPD_PORT/smart/test_repo.git
! [remote rejected] dev2 -> dev2 (hook declined)
error: failed to push some refs to 'http://127.0.0.1:5541/smart/test_repo.git'
EOF
test_expect_success 'rejected update prints status' '
cd "$ROOT_PATH"/test_repo_clone &&
git checkout -b dev2 &&
: >path4 &&
git add path4 &&
test_tick &&
git commit -m dev2 &&
test_must_fail git push origin dev2 2>act &&
sed -e "/^remote: /s/ *$//" <act >cmp &&
test_cmp exp cmp
'
rm -f "$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git/hooks/update"
cat >exp <<EOF cat >exp <<EOF
GET /smart/test_repo.git/info/refs?service=git-upload-pack HTTP/1.1 200 GET /smart/test_repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
@ -107,6 +133,8 @@ GET /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200 POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200
GET /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200 GET /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200 POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200
GET /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200
EOF EOF
test_expect_success 'used receive-pack service' ' test_expect_success 'used receive-pack service' '
sed -e " sed -e "