diff --git a/src/commandModel.js b/src/commandModel.js index c56684d7..57e7c64e 100644 --- a/src/commandModel.js +++ b/src/commandModel.js @@ -282,7 +282,8 @@ OptionParser.prototype.getMasterOptionMap = function() { '--amend': false, '-a': false, // warning '-am': false, // warning - '-m': false + '-m': false, + '-C': false }, status: {}, log: {}, @@ -291,7 +292,8 @@ OptionParser.prototype.getMasterOptionMap = function() { branch: { '-d': false, '-D': false, - '-f': false + '-f': false, + '--contains': false }, checkout: { '-b': false, diff --git a/src/git.js b/src/git.js index 98ff67f0..b112347e 100644 --- a/src/git.js +++ b/src/git.js @@ -281,8 +281,19 @@ GitEngine.prototype.getBranches = function() { return toReturn; }; -GitEngine.prototype.printBranches = function() { - var branches = this.getBranches(); +GitEngine.prototype.printBranchesWithout = function(without) { + var commitToBranches = this.getUpstreamBranchSet(); + var commitID = this.getCommitFromRef(without).get('id'); + + var toPrint = []; + _.each(commitToBranches[commitID], function(branchJSON) { + branchJSON.selected = this.HEAD.get('target').get('id') == branchJSON.id; + toPrint.push(branchJSON); + }, this); + this.printBranches(toPrint); +}; + +GitEngine.prototype.printBranches = function(branches) { var result = ''; _.each(branches, function(branch) { result += (branch.selected ? '* ' : '') + branch.id + '\n'; @@ -292,13 +303,6 @@ GitEngine.prototype.printBranches = function() { }); }; -GitEngine.prototype.logBranches = function() { - var branches = this.getBranches(); - _.each(branches, function(branch) { - console.log((branch.selected ? '* ' : '') + branch.id); - }); -}; - GitEngine.prototype.makeCommit = function(parents, id, options) { // ok we need to actually manually create commit IDs now because // people like nikita (thanks for finding this!) could @@ -527,10 +531,23 @@ GitEngine.prototype.commitStarter = function() { GitEngine.prototype.commit = function() { var targetCommit = this.getCommitFromRef(this.HEAD); var id = undefined; + // if we want to ammend, go one above if (this.commandOptions['--amend']) { targetCommit = this.resolveID('HEAD~1'); + // if they specify -C, go there + if (this.commandOptions['-C']) { + this.validateArgBounds(this.commandOptions['-C'], 1, 1, '-C'); + targetCommit = this.numBackFrom(this.getCommitFromRef(this.commandOptions['-C'][0]), 1); + } + id = this.rebaseAltID(this.getCommitFromRef('HEAD').get('id')); + } else { + if (this.commandOptions['-C']) { + throw new GitError({ + msg: 'I only support -C when doing --amend, sorry' + }); + } } var newCommit = this.makeCommit([targetCommit], id); @@ -1188,6 +1205,13 @@ GitEngine.prototype.branchStarter = function() { return; } + if (this.commandOptions['--contains']) { + var args = this.commandOptions['--contains']; + this.validateArgBounds(args, 1, 1, '--contains'); + this.printBranchesWithout(args[0]); + return; + } + if (this.commandOptions['-f']) { var args = this.commandOptions['-f']; this.twoArgsImpliedHead(args, '-f'); @@ -1199,7 +1223,7 @@ GitEngine.prototype.branchStarter = function() { if (this.generalArgs.length == 0) { - this.printBranches(); + this.printBranches(this.getBranches()); return; } diff --git a/todo.txt b/todo.txt index 2bcb7996..5d355ee2 100644 --- a/todo.txt +++ b/todo.txt @@ -23,6 +23,9 @@ Big Bugs to fix: - load and save no longer work... +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + Pre-publish things: ~~~~~~~~~~~~~~~~~~~~~~~~~~~ - cross browser support @@ -31,12 +34,11 @@ Pre-publish things: extra command ideas: -git branch --contains git log branchA ^branchB -git status -sb git commit --amend -C HEAD 2013 Things ~~~~~~~~~~~~~~~~~~~~~~~~~~~ Tree layout with the layout engine provided in d3.js, that white-paper algorithm. Only tricky thing is that merge commits mess up the "tree" aspect and it doesn't directly support weighting, but I can probably throw that in. +Would require mixing both algorthims and probably some real time dedication