# [PATCH] transport: respect verbosity when setting upstream

4 messages from 2021-04-15 to 2021-04-16. Participants: Øystein Walle, Eric Sunshine, Junio C Hamano.
Thread: https://gitlist.dev/t/55499

## Øystein Walle, 2021-04-15 12:33

Subject: [PATCH] transport: respect verbosity when setting upstream
Message-ID: <20210415123353.14686-1-oystwa@gmail.com>
URL: https://gitlist.dev/e/20210415123353.14686-1-oystwa%40gmail.com

```
A command such as `git push -qu origin feature` will print "Branch
'feature' set up to track remote branch 'feature' from 'origin'." even
when --quiet is passed. In this case it's because install_branch_config() is
always called with BRANCH_CONFIG_VERBOSE.

struct transport keeps track of the desired verbosity. Fix the above
issue by passing BRANCH_CONFIG_VERBOSE conditionally based on that.

Signed-off-by: Øystein Walle <oystwa@gmail.com>
---
 t/t5523-push-upstream.sh |  7 +++++++
 transport.c              | 10 +++++-----
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/t/t5523-push-upstream.sh b/t/t5523-push-upstream.sh
index 9fbe7f784d..fdb4292056 100755
--- a/t/t5523-push-upstream.sh
+++ b/t/t5523-push-upstream.sh
@@ -119,4 +119,11 @@ test_expect_success TTY 'quiet push' '
 	test_must_be_empty output
 '
 
+test_expect_success TTY 'quiet push -u' '
+	ensure_fresh_upstream &&
+
+	test_terminal git push --quiet -u --no-progress upstream main 2>&1 | tee output &&
+	test_must_be_empty output
+'
+
 test_done
diff --git a/transport.c b/transport.c
index ef66e73090..62b6eeed21 100644
--- a/transport.c
+++ b/transport.c
@@ -108,11 +108,11 @@ static void set_upstreams(struct transport *transport, struct ref *refs,
 		if (!remotename || !starts_with(remotename, "refs/heads/"))
 			continue;
 
-		if (!pretend)
-			install_branch_config(BRANCH_CONFIG_VERBOSE,
-				localname + 11, transport->remote->name,
-				remotename);
-		else
+		if (!pretend) {
+			int flag = transport->verbose < 0 ? 0 : BRANCH_CONFIG_VERBOSE;
+			install_branch_config(flag, localname + 11,
+				transport->remote->name, remotename);
+		} else if (transport->verbose >= 0)
 			printf(_("Would set upstream of '%s' to '%s' of '%s'\n"),
 				localname + 11, remotename + 11,
 				transport->remote->name);
-- 
2.20.1


```

## Eric Sunshine, 2021-04-15 15:29

Subject: Re: [PATCH] transport: respect verbosity when setting upstream
Message-ID: <CAPig+cSGDULOmqqpxe4b+r0ML-dMqjzgOjqgk++9E2oW-pz+9A@mail.gmail.com>
URL: https://gitlist.dev/e/CAPig%2BcSGDULOmqqpxe4b%2Br0ML-dMqjzgOjqgk%2B%2B9E2oW-pz%2B9A%40mail.gmail.com
In-Reply-To: <20210415123353.14686-1-oystwa@gmail.com>

```
On Thu, Apr 15, 2021 at 8:34 AM Øystein Walle <oystwa@gmail.com> wrote:
> A command such as `git push -qu origin feature` will print "Branch
> 'feature' set up to track remote branch 'feature' from 'origin'." even
> when --quiet is passed. In this case it's because install_branch_config() is
> always called with BRANCH_CONFIG_VERBOSE.
>
> struct transport keeps track of the desired verbosity. Fix the above
> issue by passing BRANCH_CONFIG_VERBOSE conditionally based on that.
>
> Signed-off-by: Øystein Walle <oystwa@gmail.com>
> ---
> diff --git a/t/t5523-push-upstream.sh b/t/t5523-push-upstream.sh
> @@ -119,4 +119,11 @@ test_expect_success TTY 'quiet push' '
> +test_expect_success TTY 'quiet push -u' '
> +       ensure_fresh_upstream &&
> +
> +       test_terminal git push --quiet -u --no-progress upstream main 2>&1 | tee output &&
> +       test_must_be_empty output
> +'

I wondered why you used `tee` here since it adds no value (as far as I
can tell), but I see that you copied it from the test preceding this
one. So... [intentionally left blank]

```

## Øystein Walle, 2021-04-16 13:38

Subject: Re: [PATCH] transport: respect verbosity when setting upstream
Message-ID: <CAFaJEqvL4xaXZOxS_4vXf_0gqTXBMbEO_k7ozsioTmqEMs09kA@mail.gmail.com>
URL: https://gitlist.dev/e/CAFaJEqvL4xaXZOxS_4vXf_0gqTXBMbEO_k7ozsioTmqEMs09kA%40mail.gmail.com
In-Reply-To: <CAPig+cSGDULOmqqpxe4b+r0ML-dMqjzgOjqgk++9E2oW-pz+9A@mail.gmail.com>

```
On Thu, 15 Apr 2021 at 17:29, Eric Sunshine <sunshine@sunshineco.com> wrote:

> I wondered why you used `tee` here since it adds no value (as far as I
> can tell), but I see that you copied it from the test preceding this
> one. So... [intentionally left blank]

Indeed, I wondered about that too; it seems a plain redirection will do
the trick. But a mix of laziness and not second-guessing others' work made
me leave it as it is.

Øsse

```

## Junio C Hamano, 2021-04-16 18:48

Subject: Re: [PATCH] transport: respect verbosity when setting upstream
Message-ID: <xmqqk0p2m5fb.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqqk0p2m5fb.fsf%40gitster.g
In-Reply-To: <CAFaJEqvL4xaXZOxS_4vXf_0gqTXBMbEO_k7ozsioTmqEMs09kA@mail.gmail.com>

```
Øystein Walle <oystwa@gmail.com> writes:

> On Thu, 15 Apr 2021 at 17:29, Eric Sunshine <sunshine@sunshineco.com> wrote:
>
>> I wondered why you used `tee` here since it adds no value (as far as I
>> can tell), but I see that you copied it from the test preceding this
>> one. So... [intentionally left blank]
>
> Indeed, I wondered about that too; it seems a plain redirection will do
> the trick. But a mix of laziness and not second-guessing others' work made
> me leave it as it is.

Let's agree to mark it as #leftoverbits then?

Thanks for a fix, additional tests, and a good review.


```
