diff --git a/src/commandModel.js b/src/commandModel.js index 256c5833..c56684d7 100644 --- a/src/commandModel.js +++ b/src/commandModel.js @@ -295,7 +295,8 @@ OptionParser.prototype.getMasterOptionMap = function() { }, checkout: { '-b': false, - '-B': false + '-B': false, + '-': false }, reset: { '--hard': false, diff --git a/src/git.js b/src/git.js index a515cf5b..25213bfd 100644 --- a/src/git.js +++ b/src/git.js @@ -1132,6 +1132,18 @@ GitEngine.prototype.checkoutStarter = function() { return; } + if (this.commandOptions['-']) { + // get the heads last location + var lastPlace = this.HEAD.get('lastLastTarget'); + if (!lastPlace) { + throw new GitError({ + msg: 'Need a previous location to do - switching' + }); + } + this.HEAD.set('target', lastPlace); + return; + } + if (this.commandOptions['-B']) { var args = this.commandOptions['-B']; this.twoArgsImpliedHead(args, '-B'); @@ -1438,6 +1450,21 @@ var Ref = Backbone.Model.extend({ throw new Error('must be given an id'); } this.set('type', 'general ref'); + + if (this.get('id') == 'HEAD') { + this.set('lastLastTarget', null); + this.set('lastTarget', this.get('target')); + // have HEAD remember where it is for checkout - + this.on('change:target', this.targetChanged, this); + } + }, + + targetChanged: function(model, targetValue, ev) { + // push our little 3 stack back. we need to do this because + // backbone doesn't give you what the value WAS, only what it was changed + // TO + this.set('lastLastTarget', this.get('lastTarget')); + this.set('lastTarget', targetValue); }, toString: function() { @@ -1476,7 +1503,7 @@ var Commit = Backbone.Model.extend({ circularFields: ['gitVisuals', 'visNode', 'children'] }, - getLogEntry: function() { + getLogEntry: function() { // for now we are just joining all these things with newlines which // will get placed by paragraph tags. Not really a fan of this, but // it's better than making an entire template and all that jazz diff --git a/todo.txt b/todo.txt index c9e3bd9e..190ea6cf 100644 --- a/todo.txt +++ b/todo.txt @@ -11,7 +11,6 @@ Big things: Medium things: ~~~~~~~~~~~~~~~~~~~~~~~~~~~ - gitEngine loads from tree immediately, not the weird thing we have now! -- help better Small things to implement: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~