]> git.ipfire.org Git - thirdparty/git.git/commitdiff
transport: respect verbosity when setting upstream
authorØystein Walle <oystwa@gmail.com>
Thu, 15 Apr 2021 12:33:53 +0000 (14:33 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 15 Apr 2021 19:52:49 +0000 (12:52 -0700)
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>
t/t5523-push-upstream.sh
transport.c

index 9fbe7f784d234af76f5616f0816f29c64bd0d379..fdb429205643b8ccb03529795f5b6f6aef63d93a 100755 (executable)
@@ -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
index 1c4ab676d1b148835431106d99766545c31da721..b5452b6ff545c1256f35168e512402e945f0eb8d 100644 (file)
@@ -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);