Mike Beaton reported that with a .gitignore containing one CRLF blank line, 'git check-ignore -v' reports paths ending in '/' as ignored by an empty pattern. He stressed that status and add are not affected, so no files are lost.

Aniket Gupta traced the cause. add_patterns_from_buffer() skips an empty line only if it starts right at the newline, before stripping '\r' or trailing spaces. A two-byte "\r\n" line or a spaces-only line is reduced to an empty string afterwards and passed to add_pattern(), which creates a zero-length pattern. For a path ending in a slash, the basename is empty and so matches that pattern.

Junio Hamano suggested rewording the commit message to explain how "\r\n" and space-only lines turn into "". He also noted that add_patterns_from_buffer() is shared with sparse-checkout. In cone mode, an empty pattern triggers an "unrecognized pattern" warning and disables cone matching, so changing only match_basename() would leave that case broken and would still allocate unused pattern entries.

Gupta replied that returning 0 from match_basename() for an empty pattern also fixes the lines "!", "/" and "!/", which the original patch left alone. Status, add, clean and ls-files give the same output as before. Gupta offered to do this in v2 if Hamano agrees, and said the earlier test would be dropped.

Matt Hunter observed that the test does not need to create the 'blank-dir' directory, because check-ignore only treats its input as candidate names. Gupta agreed and said the commit message will say that only check-ignore with a trailing-slash path is affected.