Skip to content

Restore the typed reset mode and the history controller's own import - #659

Merged
hannesa2 merged 1 commit into
gitx:masterfrom
goneng:restore-typed-reset-mode
Sep 18, 2026
Merged

hannesa2 merged 1 commit into
gitx:masterfrom
goneng:restore-typed-reset-mode

Conversation

@goneng

@goneng goneng commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

Two lines that #641 changed as collateral while PBGitRepository.h still reached Swift
through PBViewController.h. That is no longer the case, so both can go back.

Why the type matters

-Wswitch only checks exhaustiveness on an enum-typed switch. Typing the parameter
NSInteger turned that check off silently. The same function, compiled both ways with the
same case deliberately omitted:

enum parameter, 'Hard' omitted      warning: enumeration value 'Hard' not handled [-Wswitch]
NSInteger parameter, same omission  (silent)

That matters here because the value falls straight into an array literal:

NSString *modeParam;
switch (mode) { case Soft: ...; case Mixed: ...; case Hard: ...; }   // no default
NSArray *arguments = @[ @"reset", modeParam, refName ];

An unhandled mode leaves modeParam nil, and a nil in an array literal raises and takes the
application down, the same way #645, #648 and #654 did.

Not a live crash

There is one caller, PBGitWindowController.m:782, and it passes
GTRepositoryResetTypeSoft. Nothing reaches the gap today. What this restores is the
compile-time guard, so a fourth reset mode fails the build rather than shipping quietly.

The second change has no behavioural effect: PBGitHistoryController.m imports its own
header again instead of relying on it arriving through PBWebHistoryController.h.

Test plan

  • 129 tests, 0 failures
  • No new warnings from the retyped parameter
  • The two compilations above are the evidence for the -Wswitch claim

Both were collateral from the bridging header cleanup, needed only while
PBGitRepository.h still reached Swift through PBViewController.h.

- Take GTRepositoryResetType in resetRefish: again. PBViewController.h now
  forward declares, so PBGitRepository.h no longer reaches the bridging
  header and the enum resolves. It also restores -Wswitch exhaustiveness:
  as NSInteger, a mode outside the three cases left modeParam nil and the
  argument array raised.
- Import PBGitHistoryController.h in its own implementation again, instead
  of relying on it arriving transitively through PBWebHistoryController.h.
@goneng
goneng force-pushed the restore-typed-reset-mode branch from 0a6e2bc to 5878947 Compare September 17, 2026 21:03
@goneng
goneng marked this pull request as ready for review September 17, 2026 21:38
@hannesa2
hannesa2 merged commit 50803f9 into gitx:master Sep 18, 2026
3 checks passed
@goneng
goneng deleted the restore-typed-reset-mode branch September 18, 2026 07:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants