pcottle/learnGitBranching · error · GitError

git-error-no-general-args

Error message

git-error-no-general-args

What it means

CommandModel.acceptNoGeneralArgs() enforces that a command was invoked with zero free-form (positional) arguments. If getGeneralArgs() returns a non-empty array, it throws GitError('git-error-no-general-args'). It's typically called at the top of hg/git command shims that take no loose arguments.

Source

Thrown at src/js/models/commandModel.js:191

  getGeneralArgs() {
    return this.get('generalArgs');
  }

  setGeneralArgs(args) {
    this.set('generalArgs', args);
  }

  setOptionsMap(map) {
    this.set('supportedMap', map);
  }

  getOptionsMap() {
    return this.get('supportedMap');
  }

  acceptNoGeneralArgs() {
    if (this.getGeneralArgs().length) {
      throw new GitError({
        msg: intl.str('git-error-no-general-args')
      });
    }
  }

  argImpliedHead(args, lower, upper, option) {
    // our args we expect to be between {lower} and {upper}
    this.validateArgBounds(args, lower, upper, option);
    // and if it's one, add a HEAD to the back
    this.impliedHead(args, lower);
  }

  oneArgImpliedHead(args, option) {
    this.argImpliedHead(args, 0, 1, option);
  }

  twoArgsImpliedHead(args, option) {
    this.argImpliedHead(args, 1, 2, option);

View on GitHub (pinned to 5b09d0ff96)

Solutions

  1. Remove the extra positional argument from the command
  2. Pass the information via an option flag the command actually supports
  3. If writing a custom command shim, consume/validate general args before calling acceptNoGeneralArgs()

Example fix

// before
hg log -f main
// after
hg log -f
Defensive patterns

Strategy: validation

Validate before calling

if (command.getGeneralArgs().length > 0) { reject('this command takes no loose arguments'); }

Type guard

function hasNoGeneralArgs(cmdModel) {
  return cmdModel.getGeneralArgs().length === 0;
}

Try / catch

try { command.acceptNoGeneralArgs(); } catch (e) { if (e instanceof GitError) { showMsg('remove extra arguments'); } else throw e; }

Prevention

When it happens

Trigger: Calling a command that invokes acceptNoGeneralArgs() (e.g. the hg log shim via commandConfig) with trailing positional text, e.g. `hg log -f somebranch` where somebranch becomes a general arg.

Common situations: Muscle-memory from git where commands accept ref names; passing a branch name to a command that only accepts options; commands delegating internally that forget to consume their general args first.

Related errors


AI-assisted analysis of pcottle/learnGitBranching@5b09d0ff96 (2026-08-27). Data as JSON: /api/errors/535f4cc15ed99142. Report an issue: GitHub.