Skip to content

Fix GitX quitting when its history cannot be loaded - #654

Merged
hannesa2 merged 1 commit into
gitx:masterfrom
goneng:fix-commit-walk-error-reporting
Sep 15, 2026
Merged

hannesa2 merged 1 commit into
gitx:masterfrom
goneng:fix-commit-walk-error-reporting

Conversation

@goneng

@goneng goneng commented Sep 15, 2026 •

Copy link
Copy Markdown
Collaborator

Deleting, moving, renaming or unmounting a repository under an open window
makes GitX quit while it refreshes the history: no sheet, no message, the
window is simply gone. The error that ends the load is already in hand, but
the load ended on an assertion instead of reporting it.

Fixes #645, where the diagnosis is written up in full.

Changes

  • Replace the NSAssert ending -addCommitsFromEnumerator: with the log this
    class already uses for a failed push. NS_BLOCK_ASSERTIONS is unset in
    Release, so this was not Debug-only: the failure raised
    NSInternalInconsistencyException and took the application down.
  • Let the partial walk flush. The commits read before the failure now reach
    the history list instead of being lost with the exception, so the window
    keeps the history it had rather than emptying.
  • Add PBGitRevListEnumerationErrorTests, which drives the load with an
    enumerator that reports failure immediately. -addCommitsFromEnumerator:
    only ever asks for the next OID, so the test needs no repository behind it,
    following PBGitRevListRaceConditionTests.

Test plan

  • make unit-test fails on the new test before the source change, throwing
    NSInternalInconsistencyException: Error enumerating commits, and passes
    after it: 127 tests green.
  • The run after the change carries the report itself, confirming the error is
    surfaced rather than merely not thrown:
    Failed to enumerate commits: Error Domain=GTGitErrorDomain Code=-1 "the walk could not be continued".
  • PBGitRevListRaceConditionTests still passes, so nothing in this class
    relied on the assertion firing.

Note that this reports to the console, matching how the rest of the class
handles a failed push. Surfacing it to the user would need a channel this
class does not have, since loadRevisionsWithCompletionBlock: takes a bare
void block, and that is a larger change than the issue describes.

The error that ends the load is already in hand, so report it and keep
what was read rather than raising on it.

* Replace the NSAssert ending -addCommitsFromEnumerator: with the log
  this class already uses for a failed push. NS_BLOCK_ASSERTIONS is
  unset in Release, so a repository deleted, moved or unmounted under an
  open window raised NSInternalInconsistencyException and took the
  application down with nothing said about the cause.
* Let the partial walk flush, so the commits read before the failure
  reach the history list instead of being lost with the exception.
* Add PBGitRevListEnumerationErrorTests, driving the walk with an
  enumerator that reports failure immediately.
@goneng
goneng force-pushed the fix-commit-walk-error-reporting branch from 08eadcb to 43353c2 Compare September 15, 2026 18:41
@goneng goneng changed the title Fix a failed commit walk aborting the application Fix GitX quitting when its history cannot be loaded Sep 15, 2026
@goneng
goneng marked this pull request as ready for review September 15, 2026 18:45
@goneng goneng added the bugfix label Sep 15, 2026
@hannesa2

Copy link
Copy Markdown
Contributor

Sounds like an edge case. Let's give it a try

@hannesa2
hannesa2 merged commit 71e2905 into gitx:master Sep 15, 2026
3 checks passed
@goneng
goneng deleted the fix-commit-walk-error-reporting branch September 15, 2026 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GitX quits when its history cannot be loaded

2 participants