{"thread":{"id":"55499","subject":"[PATCH] transport: respect verbosity when setting upstream","startedAt":"2021-04-15T12:34:13Z","lastAt":"2021-04-16T18:48:53Z","messageCount":4,"participants":["Øystein Walle","Eric Sunshine","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"422028","messageId":"20210415123353.14686-1-oystwa@gmail.com","threadId":"55499","inReplyTo":null,"subject":"[PATCH] transport: respect verbosity when setting upstream","fromName":"Øystein Walle","fromEmail":"oystwa@gmail.com","sentAt":"2021-04-15T12:33:53Z","receivedAt":"2021-04-15T12:34:13Z","isPatch":true,"sender":{"key":"oystwa@gmail.com","avatar":"https://avatars.githubusercontent.com/u/794585?v=4"},"body":"A command such as `git push -qu origin feature` will print \"Branch\n'feature' set up to track remote branch 'feature' from 'origin'.\" even\nwhen --quiet is passed. In this case it's because install_branch_config() is\nalways called with BRANCH_CONFIG_VERBOSE.\n\nstruct transport keeps track of the desired verbosity. Fix the above\nissue by passing BRANCH_CONFIG_VERBOSE conditionally based on that.\n\nSigned-off-by: Øystein Walle <oystwa@gmail.com>\n---\n t/t5523-push-upstream.sh |  7 +++++++\n transport.c              | 10 +++++-----\n 2 files changed, 12 insertions(+), 5 deletions(-)\n\ndiff --git a/t/t5523-push-upstream.sh b/t/t5523-push-upstream.sh\nindex 9fbe7f784d..fdb4292056 100755\n--- a/t/t5523-push-upstream.sh\n+++ b/t/t5523-push-upstream.sh\n@@ -119,4 +119,11 @@ test_expect_success TTY 'quiet push' '\n \ttest_must_be_empty output\n '\n \n+test_expect_success TTY 'quiet push -u' '\n+\tensure_fresh_upstream &&\n+\n+\ttest_terminal git push --quiet -u --no-progress upstream main 2>&1 | tee output &&\n+\ttest_must_be_empty output\n+'\n+\n test_done\ndiff --git a/transport.c b/transport.c\nindex ef66e73090..62b6eeed21 100644\n--- a/transport.c\n+++ b/transport.c\n@@ -108,11 +108,11 @@ static void set_upstreams(struct transport *transport, struct ref *refs,\n \t\tif (!remotename || !starts_with(remotename, \"refs/heads/\"))\n \t\t\tcontinue;\n \n-\t\tif (!pretend)\n-\t\t\tinstall_branch_config(BRANCH_CONFIG_VERBOSE,\n-\t\t\t\tlocalname + 11, transport->remote->name,\n-\t\t\t\tremotename);\n-\t\telse\n+\t\tif (!pretend) {\n+\t\t\tint flag = transport->verbose < 0 ? 0 : BRANCH_CONFIG_VERBOSE;\n+\t\t\tinstall_branch_config(flag, localname + 11,\n+\t\t\t\ttransport->remote->name, remotename);\n+\t\t} else if (transport->verbose >= 0)\n \t\t\tprintf(_(\"Would set upstream of '%s' to '%s' of '%s'\\n\"),\n \t\t\t\tlocalname + 11, remotename + 11,\n \t\t\t\ttransport->remote->name);\n-- \n2.20.1\n\n"},{"id":"422034","messageId":"CAPig+cSGDULOmqqpxe4b+r0ML-dMqjzgOjqgk++9E2oW-pz+9A@mail.gmail.com","threadId":"55499","inReplyTo":"20210415123353.14686-1-oystwa@gmail.com","subject":"Re: [PATCH] transport: respect verbosity when setting upstream","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2021-04-15T15:29:25Z","receivedAt":"2021-04-15T15:29:39Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Thu, Apr 15, 2021 at 8:34 AM Øystein Walle <oystwa@gmail.com> wrote:\n> A command such as `git push -qu origin feature` will print \"Branch\n> 'feature' set up to track remote branch 'feature' from 'origin'.\" even\n> when --quiet is passed. In this case it's because install_branch_config() is\n> always called with BRANCH_CONFIG_VERBOSE.\n>\n> struct transport keeps track of the desired verbosity. Fix the above\n> issue by passing BRANCH_CONFIG_VERBOSE conditionally based on that.\n>\n> Signed-off-by: Øystein Walle <oystwa@gmail.com>\n> ---\n> diff --git a/t/t5523-push-upstream.sh b/t/t5523-push-upstream.sh\n> @@ -119,4 +119,11 @@ test_expect_success TTY 'quiet push' '\n> +test_expect_success TTY 'quiet push -u' '\n> +       ensure_fresh_upstream &&\n> +\n> +       test_terminal git push --quiet -u --no-progress upstream main 2>&1 | tee output &&\n> +       test_must_be_empty output\n> +'\n\nI wondered why you used `tee` here since it adds no value (as far as I\ncan tell), but I see that you copied it from the test preceding this\none. So... [intentionally left blank]\n"},{"id":"422096","messageId":"CAFaJEqvL4xaXZOxS_4vXf_0gqTXBMbEO_k7ozsioTmqEMs09kA@mail.gmail.com","threadId":"55499","inReplyTo":"CAPig+cSGDULOmqqpxe4b+r0ML-dMqjzgOjqgk++9E2oW-pz+9A@mail.gmail.com","subject":"Re: [PATCH] transport: respect verbosity when setting upstream","fromName":"Øystein Walle","fromEmail":"oystwa@gmail.com","sentAt":"2021-04-16T13:38:03Z","receivedAt":"2021-04-16T13:38:41Z","isPatch":true,"sender":{"key":"oystwa@gmail.com","avatar":"https://avatars.githubusercontent.com/u/794585?v=4"},"body":"On Thu, 15 Apr 2021 at 17:29, Eric Sunshine <sunshine@sunshineco.com> wrote:\n\n> I wondered why you used `tee` here since it adds no value (as far as I\n> can tell), but I see that you copied it from the test preceding this\n> one. So... [intentionally left blank]\n\nIndeed, I wondered about that too; it seems a plain redirection will do\nthe trick. But a mix of laziness and not second-guessing others' work made\nme leave it as it is.\n\nØsse\n"},{"id":"422111","messageId":"xmqqk0p2m5fb.fsf@gitster.g","threadId":"55499","inReplyTo":"CAFaJEqvL4xaXZOxS_4vXf_0gqTXBMbEO_k7ozsioTmqEMs09kA@mail.gmail.com","subject":"Re: [PATCH] transport: respect verbosity when setting upstream","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-04-16T18:48:40Z","receivedAt":"2021-04-16T18:48:53Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Øystein Walle <oystwa@gmail.com> writes:\n\n> On Thu, 15 Apr 2021 at 17:29, Eric Sunshine <sunshine@sunshineco.com> wrote:\n>\n>> I wondered why you used `tee` here since it adds no value (as far as I\n>> can tell), but I see that you copied it from the test preceding this\n>> one. So... [intentionally left blank]\n>\n> Indeed, I wondered about that too; it seems a plain redirection will do\n> the trick. But a mix of laziness and not second-guessing others' work made\n> me leave it as it is.\n\nLet's agree to mark it as #leftoverbits then?\n\nThanks for a fix, additional tests, and a good review.\n\n"}]}