Show remote side colors when color is enabled

When sending a patch for review, I get an uncolored message. The
`SUCCESS` message comes from the remote side and the git client should
wrap `SUCESS` with color (see `color.remote` and `color.remote.<slot>`
in `git-config`man page). The feature was added to C git in 2018 by
Han-Wen Nienhuys who is working for Google and is one of Gerrit
maintainers.

The C git client would not enable colors when stdout is not a tty, which
is the case since `run_command_status` captures the outputs in a pipe.
Inject `--color.remote=always` when we have detected color can be used.

The option is not shown in dry-run mode, I expect people to then
copy-paste the command and it will then run interactively.

Downstream bug: https://phabricator.wikimedia.org/T359981

Change-Id: I0aca9dc4b186500421a5f6d5e87cde825e091702
This commit is contained in:
Antoine Musso 2024-03-22 18:28:03 +01:00
parent b65c3c201c
commit 425a315f2f
1 changed files with 6 additions and 2 deletions

View File

@ -1868,10 +1868,14 @@ additional information:
if options.no_thin:
no_thin = '--no-thin'
color_remote = ''
if not options.dry and check_use_color_output():
color_remote = '-c color.remote=always'
ref = "for"
cmd = ("git push --no-follow-tags %s %s HEAD:refs/%s/%s" %
(no_thin, remote, ref, branch))
cmd = ("git %s push --no-follow-tags %s %s HEAD:refs/%s/%s" %
(color_remote, no_thin, remote, ref, branch))
push_options = []
if options.topic is not None:
topic = options.topic