Page MenuHomePhabricator

Tell git on gerrit.wikimedia.org not to generate spurious terminal sequences
Closed, DeclinedPublic

Description

I am recording most of my git/gerrit commandline sessions with UNIX script(1) utility to use that later for documentation and/or troubleshooting.

script has an interesting property that it records all control and terminal characters as it receives them, so I have turned off colors and automatic use of "less" as the page using

$ git config --global color.ui false
$ git config --global core.pager ''

However, when doing "git push" I am still getting some terminal control characters (like ESC [ K meaning "erase to end of line" on *most* terminals) from remote git instance running on gerrit.wikimedia.org.

This is a hexdump of the data received:

0000000: 7265 6d6f 7465 3a20 5265 736f 6c76 696e  remote: Resolvin
0000010: 6720 6465 6c74 6173 3a20 2020 3025 2028  g deltas:   0% (
0000020: 302f 3429 2020 201b 5b4b 0d72 656d 6f74  0/4)   .[K.remot
0000030: 653a 2052 6573 6f6c 7669 6e67 2064 656c  e: Resolving del
0000040: 7461 733a 2020 2030 2520 2830 2f34 291b  tas:   0% (0/4).
0000050: 5b4b 0d0a 7265 6d6f 7465 3a20 4552 524f  [K..remote: ERRO
0000060: 523a 206d 6973 7369 6e67 2043 6861 6e67  R: missing Chang
0000070: 652d 4964 2069 6e20 636f 6d6d 6974 206d  e-Id in commit m
0000080: 6573 7361 6765 1b5b 4b0d 0a72 656d 6f74  essage.[K..remot
0000090: 653a 2053 7567 6765 7374 696f 6e20 666f  e: Suggestion fo
00000a0: 7220 636f 6d6d 6974 206d 6573 7361 6765  r commit message
00000b0: 3a1b 5b4b 0d0a 7265 6d6f 7465 3a20 436f  :.[K..remote: Co
00000c0: 736d 6574 6963 2069 6d70 726f 7665 6d65  smetic improveme
00000d0: 6e74 7320 746f 2050 6f73 7472 6553 514c  nts to PostreSQL
00000e0: 2075 7064 6174 6572 206f 7574 7075 741b   updater output.
00000f0: 5b4b 0d0a 7265 6d6f 7465 3a20 0d0a 7265  [K..remote: ..re
0000100: 6d6f 7465 3a20 2a20 446f 6e27 7420 5741  mote: * Don't WA
0000110: 524e 206f 6e20 7365 7175 656e 6365 7320  RN on sequences 
0000120: 616c 7265 6164 7920 6578 6973 7469 6e67  already existing
0000130: 1b5b 4b0d 0a72 656d 6f74 653a 202a 2041  .[K..remote: * A
0000140: 6c69 676e 2064 6f74 7320 6e69 6365 6c79  lign dots nicely
0000150: 2074 6f20 7468 6520 7265 7374 1b5b 4b0d   to the rest.[K.
0000160: 0a72 656d 6f74 653a 2028 6368 6572 7279  .remote: (cherry
0000170: 2070 6963 6b65 6420 6672 6f6d 2063 6f6d   picked from com
0000180: 6d69 7420 6264 3761 3236 3865 3462 6532  mit bd7a268e4be2
0000190: 6461 3233 6261 3062 3939 3433 6333 6230  da23ba0b9943c3b0
00001a0: 6261 3161 6338 3832 3934 6463 291b 5b4b  ba1ac88294dc).[K
00001b0: 0d0a 7265 6d6f 7465 3a20 0d0a 7265 6d6f  ..remote: ..remo
00001c0: 7465 3a20 4368 616e 6765 2d49 643a 2049  te: Change-Id: I
00001d0: 6133 3534 6163 6438 3739 6333 6464 3834  a354acd879c3dd84
00001e0: 3065 3762 6531 6533 6336 6436 6663 3738  0e7be1e3c6d6fc78
00001f0: 6436 3936 3633 3164 1b5b 4b0d 0a54 6f20  d696631d.[K..To 
0000200: 7373 683a 2f2f 7361 7065 7240 7265 7669  ssh://saper@revi
0000210: 6577 3a32 3934 3138 2f6d 6564 6961 7769  ew:29418/mediawi
0000220: 6b69 2f63 6f72 652e 6769 740d 0a20 2120  ki/core.git.. ! 
0000230: 5b72 656d 6f74 6520 7265 6a65 6374 6564  [remote rejected
0000240: 5d20 4845 4144 202d 3e20 7265 6673 2f66  ] HEAD -> refs/f
0000250: 6f72 2f52 454c 315f 3139 2f50 6f73 7467  or/REL1_19/Postg
0000260: 7265 5351 4c20 286d 6973 7369 6e67 2043  reSQL (missing C
0000270: 6861 6e67 652d 4964 2069 6e20 636f 6d6d  hange-Id in comm
0000280: 6974 206d 6573 7361 6765 290d 0a         it message)..

Looks like setting color.ui to false and core.pager to nothing on
a remote server (in out case it would be gerrit.wm.org) does not help.
Any hints how to get rid of these?
as using "git push --porcelain"


Version: unspecified
Severity: minor
URL: http://tools.wikimedia.pl/~saper/fail/git-remote-color-fail

Details

Reference
bz35462

Event Timeline

bzimport raised the priority of this task from to Lowest.Nov 22 2014, 12:14 AM
bzimport added projects: Gerrit, Upstream.
bzimport set Reference to bz35462.

removing block of 22596 (svn to git migration). Not related.

Could ESC + ^K be sent by the git command line or is it only done by Gerrit ?

In both cases they are upstream issues that you might want to report there instead of WMF Bugzilla :-D

I am still hoping this can be configured somehow.

Just found this:

17 #define ANSI_SUFFIX "\033[K"
18 #define DUMB_SUFFIX " "
19
20 #define FIX_SIZE 10 /* large enough for any of the above */
21
22 int recv_sideband(const char *me, int in_stream, int out)
23 {
24 unsigned pf = strlen(PREFIX);
25 unsigned sf;
26 char buf[LARGE_PACKET_MAX + 2*FIX_SIZE];
27 char *suffix, *term;
28 int skip_pf = 0;
29
30 memcpy(buf, PREFIX, pf);
31 term = getenv("TERM");
32 if (term && strcmp(term, "dumb"))
33 suffix = ANSI_SUFFIX;
34 else
35 suffix = DUMB_SUFFIX;
36 sf = strlen(suffix);

http://git.kernel.org/?p=git/git.git;a=blob;f=sideband.c;h=d5ffa1c8919a6db750606c78a1b44d8618fa35a5;hb=HEAD#l33

*facepalm*

Need to find out how to set TERM=dumb for git-receive-pack, I hope it's a local client
issue.

TERM=dumb could be set in the /etc/profile or somewhere similar

removing blocking of 22596 (migrate svn to git). That is really a corner case we probably do not want to focus on.

I think upstream git should be fixed and I guess we can just close our local bug. Is that fine for you sapper ?

Note to self:

http://git.kernel.org/?p=git/git.git;a=commitdiff;h=ebe8fa738dcf6911fe520adce0cfa0cb26dee5e2;hp=140dd77a5cb2e61dcb942e245a2474fae95e42a5

Looks like a client-side issue, but not sure. Will investigate. If there is nothing that could be done on the git/gerrit side, will file upstream.

(In reply to comment #6)

Note to self:

http://git.kernel.org/?p=git/git.git;a=commitdiff;h=ebe8fa738dcf6911fe520adce0cfa0cb26dee5e2;hp=140dd77a5cb2e61dcb942e245a2474fae95e42a5

Looks like a client-side issue, but not sure. Will investigate. If there is
nothing that could be done on the git/gerrit side, will file upstream.

Looks like that may be it. If this is indeed not something we can configure, then I see two real options here:

  1. File a bug with msysgit to handle these sequences in a nicer manner
  2. File a bug with git to not use this/adjust behavior/etc.

I feel like #1 will be easier, but I don't know the msysgit community.

Also worth checking: jgit. I've not delved into their code, so I'm not sure how much wheel reinvention is going on there.

Yes. Locally-set TERM=dump helps to resolve the issue. One cannot live with TERM set this way permanently.

Let's see what the upstream says:

http://thread.gmane.org/gmane.comp.version-control.git/63343/focus=194365

[Removing RESOLVED LATER as discussed in http://lists.wikimedia.org/pipermail/wikitech-l/2012-November/064240.html . Reopening and setting priority to "Lowest". For future reference, please use either RESOLVED WONTFIX (for issues that will not be fixed), or simply set lowest priority. Thanks a lot!]

(In reply to comment #9)

Yes. Locally-set TERM=dump helps to resolve the issue. One cannot live with
TERM set this way permanently.

Let's see what the upstream says:

http://thread.gmane.org/gmane.comp.version-control.git/63343/focus=194365

Marcin, apparently upstream hasn't followed up there. I notice you replied to a thread that was 5 years old, maybe you want to send a new message instead?

saper raised the priority of this task from Lowest to Low.
saper updated the task description. (Show Details)
saper set Security to None.