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

From: "Shawn O. Pearce" <[email-masked]>
Date: Tue, 7 Aug 2007 10:36:16 -0400

Sebastian Schuberth <[email-masked]> wrote:
> I wonder if this happens because git never passes "b" to any fopen() 
> calls (as there is no such thing like opening a file in binary mode 
> under Linux, because files are always opened "binary"). If fopen() 
> safely ignores the "b" option under Linux, I think it should always be 
> specified so Cygwin's git will work with text mode mounts when compiled 
> from the original git sources.

Actually we never use fopen() when we care about the data (and we
always care about object data and working tree data).  We always
use open(2) and use system call IO directly to perform all reads
and writes.  fopen() is only used on trivial things, like say the
.git/config file.

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.

-- 
Shawn.