Thread (1 message) 1 message, 1 author, 2026-02-04

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

From: Junio C Hamano <hidden>
Date: 2026-02-04 20:47:50

"Remy D. Farley" [off-list ref] writes:
This case is actually already handled by the pathspec itself.


From pathspec.c:
quoted
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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help