From: Aniket Gupta <aniketgupta3001@gmail.com>
To: Patrick Steinhardt <ps@pks.im>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>,
Matt Hunter <m@lfurio.us>, Mike Beaton <mjsbeaton@gmail.com>,
Phillip Wood <phillip.wood123@gmail.com>
Subject: Re: [PATCH v3] dir: ignore CRLF-empty and space-only lines in pattern files
Date: Wed, 2 Dec 2026 00:41:33 +0530 [thread overview]
Message-ID: <20261201191133.16201-1-aniketgupta3001@gmail.com> (raw)
In-Reply-To: <aw7frcoTfryxeIPX@pks.im>
> Huh, affected by what? At this point I have no idea what the issue
> even is, the only thing I know is that we have an empty pattern now.
The problem is a line in a pattern file that "looks empty" but isnt. It
is either a 2 byte "\r\n" line in a file with CRLF line endings, or a
line that holds only spaces. Git skips an empty line by default,
however, these 2 lines only become empty after git strips the "\r" and
the trailing spaces, and by then, it passes the empty string to
add_pattern() which records a zero length pattern. A zero length pattern
matches a path argument that ends in a slash because its basename is
empty, so "git check-ignore foo/" says an untracked foo/ is ignored
because of that line. In a cone-mode sparse-checkout file, the same line
makes git print 2 warnings and disable cone matching. In the patch I try
to skip a line which is empty after trimming. Allow me to start the
message this way in v4.
> Okay. With git-check-ignore(1) we can append that slash ourselves, and
> thus it may trigger the bug. And this is in contrast to git-status(1)
> and git-add(1) seemingly, which never have that trailing slash.
True. status and add match a directory before they add the slash.
check-ignore can be given a path argument that ends in one.
> Sorry for repeating all of that, but I'm trying to deciper this AI
> message and am having a hard time doing so.
Claude discovered the problem while I was trying to understand the code
around it. Since I am new to open source and English not being my first
language, I use it to review my code and to correct my messages. I
realize I am only making it more complicated for your understanding.
> Okay. Is this a cosmetic issue, or is it something that results in
> wrong behaviour?
It does not check out wrong files, but it is more than cosmetic. With
one such line in a cone-mode sparse-checkout file, git prints 2 warnings
and disables cone matching. Because of that, the sparse index is
expanded to a full one, and "git sparse-checkout list" shows raw
patterns like "/a/" instead of the directory name "a". I can explain
like this in v4.
> Would it make sense to maybe clarify the rule to say "A blank line or
> a line that consists of spaces, only, matches no files"?
Yeah I think that would help. I will change it in gitignore.adoc in v4.
prev parent reply other threads:[~2026-12-01 19:11 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-28 12:49 [BUG] check-ignore matches trailing-slash paths against CRLF blank lines Mike Beaton
2026-11-06 18:29 ` [PATCH] dir: do not turn blank ignore-file lines into patterns Aniket Gupta
2026-11-19 17:19 ` Aniket Gupta
[not found] ` <CAHzAAWQo89ox+S_jtPX9DOtzfr-+3uMbWHN+HXdi9Aw2q57+Ng@mail.gmail.com>
2026-11-21 9:45 ` Aniket Gupta
2026-11-27 16:21 ` Aniket Gupta
2026-11-28 5:24 ` Matt Hunter
2026-11-28 7:28 ` Aniket Gupta
2026-11-28 10:47 ` Aniket Gupta
2026-11-29 3:21 ` Junio C Hamano
2026-11-28 6:54 ` Junio C Hamano
2026-11-28 7:28 ` Aniket Gupta
2026-11-29 4:01 ` Junio C Hamano
2026-11-28 9:38 ` Matt Hunter
2026-11-28 10:12 ` Aniket Gupta
2026-11-29 6:00 ` [PATCH v2] dir: ignore CRLF-empty and space-only lines in pattern files Aniket Gupta
2026-11-29 11:14 ` Matt Hunter
2026-11-29 11:42 ` Aniket Gupta
2026-12-01 8:00 ` [PATCH v3] " Aniket Gupta
2026-12-01 14:54 ` Patrick Steinhardt
2026-12-01 19:11 ` Aniket Gupta [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261201191133.16201-1-aniketgupta3001@gmail.com \
--to=aniketgupta3001@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=m@lfurio.us \
--cc=mjsbeaton@gmail.com \
--cc=phillip.wood123@gmail.com \
--cc=ps@pks.im \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox