Subject: Re: git on Cygwin: Not a valid object name HEAD

From: [email-masked] (Brian Downing)
Date: Tue, 7 Aug 2007 09:58:25 -0500

On Tue, Aug 07, 2007 at 10:36:16AM -0400, Shawn O. Pearce wrote:
> Now on a normal UNIX system open(2) *always* by definition does
> binary IO.  But Cygwin's text mount option tries to make UNIX
> programs DOS-friendly by making all files treated as text, even if
> it supposedly doing binary IO via open(2).
> 
> I think its a mis-feature of Cygwin.  Git has no way (that I know
> of) to defend itself from this, other than to tell the user to make
> sure they only store a Git repository in a location that is mounted
> with the binary flag.

Cygwin, like Windows' own open(2) simulation, defines an O_BINARY to pass
as a flag to open(2).  I once got Git half-working on Cygwin text-mode
mounts by doing a horrible hack approximating:

#define open(name, flag, ...) \
	open(name, (flag) | O_BINARY, ## __VA_ARGS__)

But it only half worked.  Eventually it managed to corrupt itself again,
and worse, the test suite was completely hopeless, as all shell activity
still results in text-mode files.

-bcd