From: Junio C Hamano <gitster@pobox.com>
To: Aniket Gupta <aniketgupta3001@gmail.com>
Cc: Matt Hunter <m@lfurio.us>,
git@vger.kernel.org, Mike Beaton <mjsbeaton@gmail.com>,
Phillip Wood <phillip.wood123@gmail.com>
Subject: Re: [PATCH] dir: do not turn blank ignore-file lines into patterns
Date: Sat, 28 Nov 2026 19:21:01 -0800 [thread overview]
Message-ID: <xmqqcxroqq5e.fsf@gitster.g> (raw)
In-Reply-To: <20261128104728.77555-1-aniketgupta3001@gmail.com> (Aniket Gupta's message of "Sat, 28 Nov 2026 16:17:28 +0530")
Aniket Gupta <aniketgupta3001@gmail.com> writes:
>> This avoids adding a pattern which becomes empty after stripping a
>> carriage return and any spaces. I wonder if it is also worth fixing up
>> the parsing responsible for interpreting such "whitespace only" patterns
>> to match ".*/"? Either way, I think this patch is an improvement as-is.
>
> I tried that. The empty pattern matches "foo/" because the basename of a
> path with a trailing slash is empty and match_basename() compares it
> with the empty pattern. Making match_basename() return 0 for an empty
> pattern fixes blank line and also the lines "!", "/" and "!/", which my
> patch leaves alone. With only "/" in the ignore file, "git check-ignore
> -v foo/" still names that line. status, add, clean and ls-files give the
> same output as before.
add_patterns_from_buffer() is shared with sparse-checkout through
add_patterns_from_file_to_list() and add_patterns_from_blob_to_list().
Before any matching runs, add_pattern() calls add_pattern_to_hashsets().
When cone mode is active, add_pattern_to_hashsets() checks whether
patternlen is less than 2, and if so it emits "warning: unrecognized
pattern: ''" and disables cone pattern matching.
Changing only match_basename() would leave cone-mode sparse-checkout
broken on "\r\n" and space-only lines, and would still allocate unused
path_pattern entries for every such line in ignore files.
Making match_basename() reject zero-length patterns may still be a
worthwhile complementary change (for "!", "/", and "!/", or an empty
"--exclude=" pattern), though that can be a separate decision from
skipping empty trimmed lines here.
next prev parent reply other threads:[~2026-11-29 3:21 UTC|newest]
Thread overview: 17+ 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 [this message]
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
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=xmqqcxroqq5e.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=aniketgupta3001@gmail.com \
--cc=git@vger.kernel.org \
--cc=m@lfurio.us \
--cc=mjsbeaton@gmail.com \
--cc=phillip.wood123@gmail.com \
/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