diff options
author | Alex Riesen <raa.lkml@gmail.com> | 2005-11-02 14:05:45 +0100 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2005-11-02 16:50:58 -0800 |
commit | d317e4384acd5646f2ba44197a531c129b26b57e (patch) | |
tree | 29e2eac910f75f58e824d17972a93a52c1a0db47 | |
parent | 13d1cc3604a1a64cb5a6025bba8af8b74a373963 (diff) | |
download | git-d317e4384acd5646f2ba44197a531c129b26b57e.tar.gz |
remove CR/LF from .gitignore
For everyone cursed by dos/windows line endings (aka CRLF):
The code reading the .gitignore files (excludes and excludes per
directory) leaves \r in the patterns, which causes fnmatch to fail for
no obvious reason. Just remove a "\r" preceding a "\n"
unconditionally.
Signed-off-by: Junio C Hamano <junkio@cox.net>
-rw-r--r-- | ls-files.c | 2 | ||||
-rwxr-xr-x | t/t3001-ls-files-others-exclude.sh | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/ls-files.c b/ls-files.c index 3085b2fc8c..d9c8b215f1 100644 --- a/ls-files.c +++ b/ls-files.c @@ -97,7 +97,7 @@ static int add_excludes_from_file_1(const char *fname, for (i = 0; i < size; i++) { if (buf[i] == '\n') { if (entry != buf + i && entry[0] != '#') { - buf[i] = 0; + buf[i - (i && buf[i-1] == '\r')] = 0; add_exclude(entry, base, baselen, which); } entry = buf + i + 1; diff --git a/t/t3001-ls-files-others-exclude.sh b/t/t3001-ls-files-others-exclude.sh index 5beaaa3375..fde2bb25fa 100755 --- a/t/t3001-ls-files-others-exclude.sh +++ b/t/t3001-ls-files-others-exclude.sh @@ -67,4 +67,16 @@ test_expect_success \ >output && diff -u expect output' +# Test \r\n (MSDOS-like systems) +echo -ne '*.1\r\n/*.3\r\n!*.6\r\n' >.gitignore + +test_expect_success \ + 'git-ls-files --others with \r\n line endings.' \ + 'git-ls-files --others \ + --exclude=\*.6 \ + --exclude-per-directory=.gitignore \ + --exclude-from=.git/ignore \ + >output && + diff -u expect output' + test_done |