git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] fix git add :!x exiting with error when x is in .gitignore

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 4, 2026, 20:47 UTC
Message-ID
<xmqqikccnsln.fsf@gitster.g>
In-Reply-To
<24VdqZCRHE7M9q7Rp-IH60MmQrEOW5lzhtd1-SUNqEhV_OTzGiCUkVDL5ngVJbyWRMDZ2GlWCJ9wkMSJLsJh8QYO4gRhDMGyzhfuGAODOs8=@protonmail.com>
"Remy D. Farley" <one-d-wide@protonmail.com> writes:
Show 18 quoted lines
> This case is actually already handled by the pathspec itself.
>
>
> From pathspec.c:
>> void parse_pathspec(struct pathspec *pathspec,
>> 		    unsigned magic_mask, unsigned flags,
>> 		    const char *prefix, const char **argv)
>> {
>> 	[...]
>> 	/*
>> 	 * If everything is an exclude pattern, add one positive pattern
>> 	 * that matches everything. We allocated an extra one for this.
>> 	 */
>> 	if (nr_exclude == n) {
>> 		int plen = (!(flags & PATHSPEC_PREFER_CWD)) ? 0 : prefixlen;
>> 		init_pathspec_item(item + n, 0, prefix, plen, ".");
>> 		pathspec->nr++;
>> 	}

Yes, that is from Linus 9 years ago plus a bit of my work, in 859b7f1d (pathspec: don't error out on all-exclusionary pathspec patterns, 2017-02-07) and b02fdbc8 (pathspec: correct an empty string used as a pathspec element, 2022-05-29). No wonder it sounded familiar ;-).

Thanks.
Previous: Remy D. Farley
Message 6 of 6 in “fix git add :!x exiting with error when x is in .gitignore”
  1. fix git add :!x exiting with error when x is in .gitignoreRemy D. Farley, Feb 4, 2026
  2. Junio C HamanoFeb 4, 2026
  3. Tian YuchenFeb 4, 2026
  4. Junio C HamanoFeb 4, 2026
  5. fix git add :!x exiting with error when x is in .gitignoreRemy D. Farley, Feb 4, 2026
  6. Junio C HamanoFeb 4, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.