public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Mirko Faina <mroik@delayed.space>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] t0008: fix "large exclude file ignored in tree"
Date: Sun, 15 Mar 2026 09:04:33 -0700	[thread overview]
Message-ID: <xmqq7brdt6y6.fsf@gitster.g> (raw)
In-Reply-To: <abZwbCF1R0_bnFBv@exploit> (Mirko Faina's message of "Sun, 15 Mar 2026 09:50:06 +0100")

Mirko Faina <mroik@delayed.space> writes:

> When running "GIT_TEST_OPTS='-l -v' git make t0008-ignores.sh", "large

This must be "make", not "git make", right?

> exclude file ignored in tree" fails with the comparison failing due to
> an extra warning "warning: unable to access 'subdir/.gitignore': Too
> many levels of symbolic links".

test_expect_success SYMLINKS 'symlinks not respected in-tree' '
	test_when_finished "rm .gitignore" &&
	ln -s ignore .gitignore &&
	mkdir subdir &&
	ln -s ignore subdir/.gitignore &&
	test_must_fail git check-ignore subdir/file >actual 2>err &&
	test_must_be_empty actual &&
	test_grep "unable to access.*gitignore" err
'

The above step creates symbolic links subdir/.gitignore and
.gitignore, each of which pointing at a "ignore" file next to it.
This test has extremely bad hygiene and depends on "ignore" having
preexisting contents "*" in it (so a bad version of Git that follows
symbolic links would ignore almost everything).

Files err and actual are created, and when the test finishes, only
".gitignore" is removed, everything else left behind.

test_expect_success EXPENSIVE 'large exclude file ignored in tree' '
	test_when_finished "rm .gitignore" &&
	dd if=/dev/zero of=.gitignore bs=101M count=1 &&
	git ls-files -o --exclude-standard 2>err &&
	echo "warning: ignoring excessively large pattern file: .gitignore" >expect &&
	test_cmp expect err
'

Ah, OK, you're right.

The problem is not the subdir/ directory itself, but the leftover
symbolic link subdir/.gitignore that would cause "ls-files -o" to
notice and complain about that symbolic link.

If that is what is happening, then this should probably be fixed in
a belt-and-suspenders fashion.  The primary bug is that the
expensive test that does not protect against pre-existing files in
the working tree when it starts.

In the failing test, remove preexisting .gitignore everywhere in
tree.  With as bad hygiene as this entire script has, we do not know
what is left behind in the working tree by which other test piece
that comes before this last test, something like

test_expect_success EXPENSIVE 'large exclude file ignored in tree' '
	test_when_finished "rm .gitignore" &&
	find . -name .gitignore -exec rm "{}" ";" &&
	dd if=/dev/zero of=.gitignore bs=101M count=1 &&
	...

perhaps?

And in the previous test, as you said, you would need to remove at
least subdir/.gitignore in addition to .gitignore to make the next
test pass, but (1) the next test should not depend on it to work
correctly, and (2) it would be a good discipline to remove any and
all dropping you make.

So the change to the not-expensive piece would be

test_expect_success SYMLINKS 'symlinks not respected in-tree' '
	test_when_finished "rm -fr subdir .gitignore err actual" &&
	...

and the primary reason why we make such a change (to be described in
the proposed log message) is not about the next test, but is about
cleaning cruft created in each test before it finishes.  It would be
OK to make both changes in a single commit, as they are fairly small.

Thanks.

  reply	other threads:[~2026-03-15 16:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-15  3:48 [PATCH] t0008: fix "large exclude file ignored in tree" Mirko Faina
2026-03-15  5:50 ` Junio C Hamano
2026-03-15  8:50   ` Mirko Faina
2026-03-15 16:04     ` Junio C Hamano [this message]
2026-03-16  1:15 ` [PATCH v2] t0008: improve test cleanup to fix failing test Mirko Faina
2026-03-16  1:21   ` Mirko Faina
2026-03-16 19:48   ` Junio C Hamano

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=xmqq7brdt6y6.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=mroik@delayed.space \
    /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