git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Buggy (or undocumented) handling of terminal \r in .gitignore patterns
@ 2008-12-03 15:46 Aaron Harnly
  2008-12-03 17:42 ` Michael J Gruber
  0 siblings, 1 reply; 2+ messages in thread
From: Aaron Harnly @ 2008-12-03 15:46 UTC (permalink / raw)
  To: git

This is with git 1.5.6.3 on Ubuntu and Mac OS X.

Overview: .gitignore patterns ending in \r do not work as expected, apparently
because the terminal \r is assumed to be part of the newline.

Steps to Reproduce:
(NB ^M is the control-M sequence, not a literal caret-M)

1. Create an empty repository.
2. Create a file named Icon\r (aka Icon^M).
3. Add the following pattern to the .gitignore:

Icon^M

Expected behavior:

The file is ignored.

Actual behavior:

The file is not ignored.

Discussion:

It appears that the parsing of .gitignore files tries to be graceful in allowing
the file to have CRLF endings, or indeed mixed LF / CRLF endings.

This is well and good, but poses a bit of a problem for ignoring files whose
name ends in \r. In particular, Mac OS X's icon files are named Icon\r. Yes,
this is sick and annoying on the part of Apple.

I understand the rationale for this behavior, but it probably should be
documented somewhere. In the meantime, a workaround that does allow the ignoring
of these files is the pattern:

Icon^M^M

where again, the terminal \r seems to be ignored as part of the newline, but the
penultimate \r gets picked up as part of the pattern.

Any thoughts on whether:
1. this behavior should be left as it is
2. there is actually documentation somewhere that I didn't see
3. terminal \r in an otherwise all-LF file should be assumed to be part of the
pattern
4. some other alternative?

cheers,
~aaron

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-12-03 17:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-03 15:46 Buggy (or undocumented) handling of terminal \r in .gitignore patterns Aaron Harnly
2008-12-03 17:42 ` Michael J Gruber

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).