Repository navigation
Fix Ignore doing nothing once a .gitignore is already there - #604
Merged
Merged
Conversation
goneng
marked this pull request as ready for review
September 11, 2026 22:50
goneng
force-pushed
the
fix-ignoring-a-second-file
branch
from
September 12, 2026 08:42
3addef6 to
47ebe9d
Compare
…tx#597) Ignoring a file worked the first time and never again, because appending to the .gitignore left behind measured the length of the string being built rather than the one read off disk, and indexing past the end of it raised an exception the menu item quietly swallowed. * Ask the file read off disk whether it already ends in a newline * Leave an empty .gitignore without a newline in front of the first path written into it
Writing the .gitignore can raise rather than return, and an exception leaving this call reaches AppKit, which logs it and carries on, so the menu item looks to the user as though it simply did nothing. * Catch anything raised while the file is written and hand the caller an error, which it already knows to show in a sheet * Name the raised reason in that error, so a report of "nothing happened" arrives with something to go on
goneng
force-pushed
the
fix-ignoring-a-second-file
branch
from
September 12, 2026 09:36
47ebe9d to
04ab711
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #597.
Ignoring a file worked the first time and never again.
Appending to the
.gitignorethat the first one left behind measured the length of thestring being built rather than the one read off disk:
[nil length]is 0, and0 - 1on anNSUIntegerwraps around, so the call raisedNSRangeException.That branch runs only when a
.gitignorealready exists, which is whythe first file always worked and every one after it did nothing.
The exception reached AppKit, which logs it and carries on, so no error sheet was ever shown either.
The second commit catches anything raised there and hands the caller an error, which
it already knows how to show.
Test plan
PBGitRepositoryIgnoreTests: 6 tests, of which 4 fail on masterwith the exception above and one covers the empty .gitignore that
would have overflowed the same way
make unit-test: 55 tests, 0 failuresf1 and f2, ignore f1, then ignore f2, and the .gitignore holds both