transport: respect verbosity when setting upstream
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Øystein Walle committed
Apr 15, 2021 at 14:33 UTC
f3cce896a8e14e4732f45a6ee46f77e7ed17a990
2 files changed
+12
-5
t/t5523-push-upstream.sh
+7
@@ -119,4 +119,11 @@ test_expect_success TTY 'quiet push' '
119
test_must_be_empty output
120
'
121
122
+test_expect_success TTY 'quiet push -u' '
123
+ ensure_fresh_upstream &&
124
+
125
+ test_terminal git push --quiet -u --no-progress upstream main 2>&1 | tee output &&
126
+ test_must_be_empty output
127
+'
128
+
129
test_done
transport.c
+5
-5
@@ -108,11 +108,11 @@ static void set_upstreams(struct transport *transport, struct ref *refs,
108
if (!remotename || !starts_with(remotename, "refs/heads/"))
109
continue;
110
111
- if (!pretend)
112
- install_branch_config(BRANCH_CONFIG_VERBOSE,
113
- localname + 11, transport->remote->name,
114
- remotename);
115
- else
111
+ if (!pretend) {
112
+ int flag = transport->verbose < 0 ? 0 : BRANCH_CONFIG_VERBOSE;
113
+ install_branch_config(flag, localname + 11,
114
+ transport->remote->name, remotename);
115
+ } else if (transport->verbose >= 0)
116
printf(_("Would set upstream of '%s' to '%s' of '%s'\n"),
117
localname + 11, remotename + 11,
118
transport->remote->name);