git/list[1] front-page[2] threads[3] people[4] search[5] about
 

.git/info/exclude w/ CFLF fails in cygwin

From
JXJing Xue <jingxue@digizenstudio.com>
Date
Sep 8, 2007, 01:01 UTC
Message-ID
<20070908010139.GA5501@falcon.digizenstudio.com>

(1.5.3.1 in cygwin, Win XP) I have cygwin configured to operate in the DOS/text mode, which means cygwin translates LF to CRLF when writing a file, and CRLF to LF when reading. Unfortunately cygwin's fstat() implementation doesn't take the mode into account when reporting stat.st_size, presumably for the sake of performance, while read() does actually do the conversion.

That causes the function add_excludes_from_file_1() in dir.c to reject a .git/info/exclude file with CRLF ending, because the size actually read is not the same as the size reported by fstat().

The simplest fix I have found is to explicitly open the exclude file in binary mode, because the rest of the exclude file parsing code actually deals with CRLF quite fine.

I would submit a patch but I am not sure if this is the appropriate fix.

By the way, parsing .git/config with CRLF in the same environment works fine because the code reads the file by byte and doesn't do any size validation.

Any thoughts?
-- 
Jing Xue
Next: Robin Rosenberg
Message 1 of 2 in “.git/info/exclude w/ CFLF fails in cygwin”
  1. Jing XueSep 8, 2007
  2. Robin RosenbergSep 8, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.