Am 07.06.2014 09:57, schrieb Stepan Kasal:
From: Karsten Blees <>
Date: Sat, 14 Jan 2012 22:24:19 +0100

Winansi.c has many static variables that are accessed and modified from
the [v][f]printf / fputs functions overridden in the file. This may cause
multi threaded git commands that print to the console to produce corrupted
output or even crash.

Additionally, winansi.c doesn't override all functions that can be used to
print to the console (e.g. fwrite, write, fputc are missing), so that ANSI
escapes don't work properly for some git commands (e.g. git-grep).

Instead of doing ANSI emulation in just a few wrapped functions on top of
the IO API, let's plug into the IO system and take advantage of the thread
safety inherent to the IO system.

Redirect stdout and stderr to a pipe if they point to the console. A
background thread reads from the pipe, handles ANSI escape sequences and
UTF-8 to UTF-16 conversion, then writes to the console.

There's something fishy with this patch. Please checkout and build eac14f8909d9. Then run like so from a CMD prompt:

  sh -v -i

Notice that in test 36 (invoke tar filter by extension) the tar file is written to the console instead of the file. Hit Ctrl-C to interrupt the test; do not remove the trash directory. You can verify the incorrect behavior like this:

  cd "t\trash directory.t5000-tar-tree"
  ..\..\git archive -o HEAD

It writes the tar file to the console. When you build the parent commit, and repeat these two commands, there is no unexpected console output.

The patch fcd428f4a952 (Win32: fix broken pipe detection) does not fix the incorrect behavior.

I haven't dug (and won't dig) deeper than that.

-- Hannes

To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to
More majordomo info at

Reply via email to