pcottle/learnGitBranching · info · CommandResult
<dynamic branch listing>
Error message
<dynamic branch listing>
What it means
Not a failure: printBranches formats the branch listing (selected branch prefixed with '* ', display names unquoted via split('"')[1]) and delivers it by throwing a CommandResult, the app's control-flow mechanism for command output.
Source
Thrown at src/js/git/index.js:853
};
GitEngine.prototype.printBranchesWithout = function(without) {
var commitToBranches = this.getUpstreamBranchSet();
var commitID = this.getCommitFromRef(without).get('id');
var toPrint = commitToBranches[commitID].map(function (branchJSON) {
branchJSON.selected = this.HEAD.get('target').get('id') == branchJSON.id;
return branchJSON;
}, this);
this.printBranches(toPrint);
};
GitEngine.prototype.printBranches = function(branches) {
var result = '';
branches.forEach(branch => {
result += (branch.selected ? '* ' : '') + this.resolveName(branch.id).split('"')[1] + '\n';
});
throw new CommandResult({
msg: result
});
};
GitEngine.prototype.printTags = function(tags) {
var result = '';
tags.forEach(function (tag) {
result += tag.id + '\n';
});
throw new CommandResult({
msg: result
});
};
GitEngine.prototype.printRemotes = function(options) {
var result = '';
if (options.verbose) {
result += 'origin (fetch)\n';View on GitHub (pinned to 5b09d0ff96)
Solutions
- Catch CommandResult separately from GitError when driving GitEngine programmatically
- Use CommandResult.prototype instanceof checks to distinguish output from failure
- Rely on the built-in command pipeline rather than calling printBranches directly
Example fix
// before
engine.printBranches(branches); // throws
// after
try { engine.printBranches(branches); }
catch (e) { if (e instanceof CommandResult) display(e.msg); else throw e; } Defensive patterns
Strategy: try-catch
Type guard
function isCommandResult(e){ return e instanceof CommandResult; } Try / catch
try { engine.printBranches(branches); } catch (e) { if (e instanceof CommandResult) { show(e.msg); } else { throw e; } } Prevention
- Never call print* methods without a CommandResult catch
- Prefer the command pipeline for display
When it happens
Trigger: Any `git branch` (or branch listing variant) executed successfully; the thrown CommandResult is caught by the command pipeline and displayed.
Common situations: Not applicable as an error; only relevant when writing code that calls GitEngine directly and doesn't expect the throw-for-output pattern.
Related errors
- <dynamic tag listing>
- <dynamic remote listing>
- ' + ref + ' is not a branch
- ' + ref + ' is not a remote branch
- ' + branchName + ' is not a branch!
AI-assisted analysis of pcottle/learnGitBranching@5b09d0ff96 (2026-08-27).
Data as JSON: /api/errors/db76c17ffaca4953.
Report an issue: GitHub.