When a custom patch is built from a commit and you then check out a branch
that doesn't contain that commit, getPatchCommitIndex() returns -1, which was
passed straight into commits[commitIndex], panicking with 'index out of range
[-1]' (#5802). This affected all five custom-patch menu actions.
Make getPatchCommitIndex() return an error when the patch's commit is no longer
present, and have each action surface it as a friendly message instead of
crashing. Add an integration test reproducing the scenario.