From: Junio C Hamano Date: Thu, 10 May 2012 17:08:54 +0000 (-0700) Subject: Merge branch 'jk/maint-push-progress' into maint X-Git-Tag: v1.7.10.2~18 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/25047b88965c8954e0599fe20c88b6a03c3ee506?ds=inline;hp=-c Merge branch 'jk/maint-push-progress' into maint "git push" over smart-http lost progress output a few releases ago. By Jeff King * jk/maint-push-progress: t5541: test more combinations of --progress teach send-pack about --[no-]progress send-pack: show progress when isatty(2) --- 25047b88965c8954e0599fe20c88b6a03c3ee506 diff --combined remote-curl.c index 08962214db,e5e9490be7..04a9d6277d --- a/remote-curl.c +++ b/remote-curl.c @@@ -290,7 -290,6 +290,7 @@@ static void output_refs(struct ref *ref struct rpc_state { const char *service_name; const char **argv; + struct strbuf *stdin_preamble; char *service_url; char *hdr_content_type; char *hdr_accept; @@@ -536,7 -535,6 +536,7 @@@ static int rpc_service(struct rpc_stat { const char *svc = rpc->service_name; struct strbuf buf = STRBUF_INIT; + struct strbuf *preamble = rpc->stdin_preamble; struct child_process client; int err = 0; @@@ -547,8 -545,6 +547,8 @@@ client.argv = rpc->argv; if (start_command(&client)) exit(1); + if (preamble) + write_or_die(client.in, preamble->buf, preamble->len); if (heads) write_or_die(client.in, heads->buf, heads->len); @@@ -630,14 -626,13 +630,14 @@@ static int fetch_git(struct discovery * int nr_heads, struct ref **to_fetch) { struct rpc_state rpc; + struct strbuf preamble = STRBUF_INIT; char *depth_arg = NULL; - const char **argv; int argc = 0, i, err; + const char *argv[15]; - argv = xmalloc((15 + nr_heads) * sizeof(char*)); argv[argc++] = "fetch-pack"; argv[argc++] = "--stateless-rpc"; + argv[argc++] = "--stdin"; argv[argc++] = "--lock-pack"; if (options.followtags) argv[argc++] = "--include-tag"; @@@ -656,27 -651,24 +656,27 @@@ argv[argc++] = depth_arg; } argv[argc++] = url; + argv[argc++] = NULL; + for (i = 0; i < nr_heads; i++) { struct ref *ref = to_fetch[i]; if (!ref->name || !*ref->name) die("cannot fetch by sha1 over smart http"); - argv[argc++] = ref->name; + packet_buf_write(&preamble, "%s\n", ref->name); } - argv[argc++] = NULL; + packet_buf_flush(&preamble); memset(&rpc, 0, sizeof(rpc)); rpc.service_name = "git-upload-pack", rpc.argv = argv; + rpc.stdin_preamble = &preamble; rpc.gzip_request = 1; err = rpc_service(&rpc, heads); if (rpc.result.len) safe_write(1, rpc.result.buf, rpc.result.len); strbuf_release(&rpc.result); - free(argv); + strbuf_release(&preamble); free(depth_arg); return err; } @@@ -782,6 -774,7 +782,7 @@@ static int push_git(struct discovery *h argv[argc++] = "--quiet"; else if (options.verbosity > 1) argv[argc++] = "--verbose"; + argv[argc++] = options.progress ? "--progress" : "--no-progress"; argv[argc++] = url; for (i = 0; i < nr_spec; i++) argv[argc++] = specs[i]; diff --combined t/t5541-http-push.sh index cc6f081711,363beaf5dd..c07973ed8d --- a/t/t5541-http-push.sh +++ b/t/t5541-http-push.sh @@@ -106,7 -106,7 +106,7 @@@ cat >exp < dev2 (hook declined) -error: failed to push some refs to 'http://127.0.0.1:5541/smart/test_repo.git' +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' ' @@@ -215,12 -215,35 +215,35 @@@ test_expect_success 'push --mirror to r git push --mirror "$HTTPD_URL"/smart/alternates-mirror.git ' - test_expect_success TTY 'quiet push' ' + test_expect_success TTY 'push shows progress when stderr is a tty' ' + cd "$ROOT_PATH"/test_repo_clone && + test_commit noisy && + test_terminal git push >output 2>&1 && + grep "^Writing objects" output + ' + + test_expect_success TTY 'push --quiet silences status and progress' ' cd "$ROOT_PATH"/test_repo_clone && test_commit quiet && - test_terminal git push --quiet --no-progress 2>&1 | tee output && + test_terminal git push --quiet >output 2>&1 && test_cmp /dev/null output ' + test_expect_success TTY 'push --no-progress silences progress but not status' ' + cd "$ROOT_PATH"/test_repo_clone && + test_commit no-progress && + test_terminal git push --no-progress >output 2>&1 && + grep "^To http" output && + ! grep "^Writing objects" + ' + + test_expect_success 'push --progress shows progress to non-tty' ' + cd "$ROOT_PATH"/test_repo_clone && + test_commit progress && + git push --progress >output 2>&1 && + grep "^To http" output && + grep "^Writing objects" output + ' + stop_httpd test_done