pcottle/learnGitBranching · error · GitError
git-error-args-many (upper: {}, what: git {method})
Error message
git-error-args-many (upper: {}, what: git {method}) What it means
The upper-bound half of validateArgBounds(): when args.length > upper it throws GitError('git-error-args-many') formatted with the upper bound and the command description. This caps how many positional arguments a git/hg command accepts.
Source
Thrown at src/js/models/commandModel.js:252
validateArgBounds(args, lower, upper, option) {
var what = (option === undefined) ?
'git ' + this.get('method') :
this.get('method') + ' ' + option + ' ';
what = 'with ' + what;
if (args.length < lower) {
throw new GitError({
msg: intl.str(
'git-error-args-few',
{
lower: String(lower),
what: what
}
)
});
}
if (args.length > upper) {
throw new GitError({
msg: intl.str(
'git-error-args-many',
{
upper: String(upper),
what: what
}
)
});
}
}
validateAtInit() {
if (this.get('rawStr') === null) {
throw new Error('Give me a string!');
}
if (!this.get('createTime')) {
this.set('createTime', new Date().toString());
}View on GitHub (pinned to 5b09d0ff96)
Solutions
- Remove the extra arguments so only the documented count remains
- Quote multi-word arguments so they parse as a single general arg
- If writing a shim, ensure option values aren't also pushed into general args before bounds validation
Example fix
// before git push origin main extra // after git push origin main
Defensive patterns
Strategy: validation
Validate before calling
if (args.length > upper) { reject(`too many arguments; max ${upper}`); } Type guard
function withinBounds(args, lower, upper) {
return args.length >= lower && args.length <= upper;
} Try / catch
try { command.validateArgBounds(args, lower, upper); } catch (e) { if (e instanceof GitError && /many/.test(e.msg)) { trimArgsHint(); } else throw e; } Prevention
- Quote multi-word arguments so they parse as one token
- Don't re-append option values as positional args in shims
When it happens
Trigger: Calling validateArgBounds() with more arguments than allowed — e.g. a two-arg command given three: `git rebase arg1 arg2 arg3`, or delegating shims that concatenate option values into general args.
Common situations: Paste errors with extra tokens; option values (like -r values) being double-counted as general args in hg shims; commands where quotes were lost so one arg splits into several.
Related errors
- git-error-no-general-args
- git-error-args-few (lower: {}, what: git {method})
- Bad numeric argument: ' + generalArgs[1]
- --delete doesn't make sense without any refs
AI-assisted analysis of pcottle/learnGitBranching@5b09d0ff96 (2026-08-27).
Data as JSON: /api/errors/4f238318909a381c.
Report an issue: GitHub.