From: Junio C Hamano Date: Mon, 9 Apr 2012 20:38:41 +0000 (-0700) Subject: Merge branch 'cb/maint-t5541-make-server-port-portable' into maint-1.7.8 X-Git-Tag: v1.7.8.6~5 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/00fb2d25632191b89ac4144e1a6498470a4a1c9e?ds=inline;hp=-c Merge branch 'cb/maint-t5541-make-server-port-portable' into maint-1.7.8 * cb/maint-t5541-make-server-port-portable: t5541: check error message against the real port number used remote-curl: Fix push status report when all branches fail --- 00fb2d25632191b89ac4144e1a6498470a4a1c9e diff --combined remote-curl.c index 48c20b86f3,f48485931f..25c1af7ab7 --- a/remote-curl.c +++ b/remote-curl.c @@@ -115,7 -115,7 +115,7 @@@ static struct discovery* discover_refs( http_ret = http_get_strbuf(refs_url, &buffer, HTTP_NO_CACHE); /* try again with "plain" url (no ? or & appended) */ - if (http_ret != HTTP_OK) { + if (http_ret != HTTP_OK && http_ret != HTTP_NOAUTH) { free(refs_url); strbuf_reset(&buffer); @@@ -188,7 -188,7 +188,7 @@@ static int write_discovery(int in, int return err; } -static struct ref *parse_git_refs(struct discovery *heads) +static struct ref *parse_git_refs(struct discovery *heads, int for_push) { struct ref *list = NULL; struct async async; @@@ -200,8 -200,7 +200,8 @@@ if (start_async(&async)) die("cannot start thread to parse advertised refs"); - get_remote_heads(async.out, &list, 0, NULL, 0, NULL); + get_remote_heads(async.out, &list, + for_push ? REF_NORMAL : 0, NULL); close(async.out); if (finish_async(&async)) die("ref parsing thread failed"); @@@ -269,7 -268,7 +269,7 @@@ static struct ref *get_refs(int for_pus heads = discover_refs("git-upload-pack"); if (heads->proto_git) - return parse_git_refs(heads); + return parse_git_refs(heads, for_push); return parse_info_refs(heads); } @@@ -574,14 -573,7 +574,14 @@@ static int rpc_service(struct rpc_stat close(client.in); client.in = -1; - strbuf_read(&rpc->result, client.out, 0); + if (!err) { + strbuf_read(&rpc->result, client.out, 0); + } else { + char buf[4096]; + for (;;) + if (xread(client.out, buf, sizeof(buf)) <= 0) + break; + } close(client.out); client.out = -1; @@@ -805,7 -797,7 +805,7 @@@ static int push(int nr_spec, char **spe static void parse_push(struct strbuf *buf) { char **specs = NULL; - int alloc_spec = 0, nr_spec = 0, i; + int alloc_spec = 0, nr_spec = 0, i, ret; do { if (!prefixcmp(buf->buf, "push ")) { @@@ -822,12 -814,13 +822,13 @@@ break; } while (1); - if (push(nr_spec, specs)) - exit(128); /* error already reported */ - + ret = push(nr_spec, specs); printf("\n"); fflush(stdout); + if (ret) + exit(128); /* error already reported */ + free_specs: for (i = 0; i < nr_spec; i++) free(specs[i]); @@@ -860,17 -853,10 +861,17 @@@ int main(int argc, const char **argv url = strbuf_detach(&buf, NULL); - http_init(remote); + http_init(remote, url, 0); do { - if (strbuf_getline(&buf, stdin, '\n') == EOF) + if (strbuf_getline(&buf, stdin, '\n') == EOF) { + if (ferror(stdin)) + fprintf(stderr, "Error reading command stream\n"); + else + fprintf(stderr, "Unexpected end of command stream\n"); + return 1; + } + if (buf.len == 0) break; if (!prefixcmp(buf.buf, "fetch ")) { if (nongit) @@@ -910,7 -896,6 +911,7 @@@ printf("\n"); fflush(stdout); } else { + fprintf(stderr, "Unknown command '%s'\n", buf.buf); return 1; } strbuf_reset(&buf); diff --combined t/t5541-http-push.sh index 9b85d420c3,da0b702639..d37bc1dc58 --- a/t/t5541-http-push.sh +++ b/t/t5541-http-push.sh @@@ -95,6 -95,32 +95,32 @@@ test_expect_success 'create and delete test_must_fail git show-ref --verify refs/remotes/origin/dev ' + cat >"$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git/hooks/update" <exp < dev2 (hook declined) + error: failed to push some refs to 'http://127.0.0.1:$LIB_HTTPD_PORT/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/ *$//" cmp && + test_cmp exp cmp + ' + rm -f "$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git/hooks/update" + cat >exp <