pcottle/learnGitBranching · warning · GitError
command-disabled
Error message
command-disabled
What it means
Thrown by DisabledMap.getInstantCommands' onMatch closure when a command the current level has disabled matches the user's input. Levels can blacklist commands (to force alternative solutions), and any match immediately throws GitError with the localized 'command-disabled' message instead of executing.
Source
Thrown at src/js/level/disabledMap.js:22
var Errors = require('../util/errors');
var GitError = Errors.GitError;
function DisabledMap(options) {
options = options || {};
this.disabledMap = options.disabledMap || {
'git cherry-pick': true,
'git rebase': true
};
}
DisabledMap.prototype.getInstantCommands = function() {
// this produces an array of regex / function pairs that can be
// piped into a parse waterfall to disable certain git commands
// :D
var instants = [];
var onMatch = function() {
throw new GitError({
msg: intl.str('command-disabled')
});
};
Object.keys(this.disabledMap).forEach(function(disabledCommand) {
// XXX get hold of vcs from disabledMap
var vcs = 'git';
disabledCommand = disabledCommand.slice(vcs.length + 1);
var gitRegex = Commands.commands.getRegexMap()[vcs][disabledCommand];
if (!gitRegex) {
throw new Error('wuttttt this disbaled command' + disabledCommand +
' has no regex matching');
}
instants.push([gitRegex, onMatch]);
}.bind(this));
return instants;
};
View on GitHub (pinned to 5b09d0ff96)
Solutions
- Use a different, non-disabled command to achieve the level goal
- Re-read the level instructions for which commands are restricted
- If you genuinely need the command (sandbox mode), exit the level or switch to a level/mode without that disable entry
Defensive patterns
Strategy: validation
Validate before calling
var banned = levelDisabledMap.disabledMap || {};
var firstWord = input.trim().split(/\s+/)[0];
if (banned[firstWord]) { /* warn user instead of dispatching */ } Try / catch
try { dispatch(input); } catch (e) { if (e instanceof GitError && e.msg === intl.str('command-disabled')) { /* suggest alternative command */ } else throw e; } Prevention
- Inspect the level's disabledMap before attempting commands
- Read level instructions for banned commands
When it happens
Trigger: Typing a command listed in the level's disabledMap (e.g. 'commit' in a level that bans committing) — the generated instant regexes intercept it during the parse waterfall.
Common situations: Levels that teach rebasing by disabling cherry-pick, or merging by disabling merge; users attempting shortcuts the level forbids.
Related errors
- git-error-exist
- cannot fetch to ' + ref + ' when checked out on ' + ref
- ' + ref + ' is not a branch
- ' + ref + ' is not a remote branch
- ' + generalArgs[0] + ' is not a remote in your repository! t
AI-assisted analysis of pcottle/learnGitBranching@5b09d0ff96 (2026-08-27).
Data as JSON: /api/errors/736a0581ba4d33ce.
Report an issue: GitHub.