git checkout - working

This commit is contained in:
Peter Cottle 2012-11-04 22:17:05 -08:00
parent c523d3735a
commit 6cf842c2f6
3 changed files with 30 additions and 3 deletions

View file

@ -295,7 +295,8 @@ OptionParser.prototype.getMasterOptionMap = function() {
}, },
checkout: { checkout: {
'-b': false, '-b': false,
'-B': false '-B': false,
'-': false
}, },
reset: { reset: {
'--hard': false, '--hard': false,

View file

@ -1132,6 +1132,18 @@ GitEngine.prototype.checkoutStarter = function() {
return; 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']) { if (this.commandOptions['-B']) {
var args = this.commandOptions['-B']; var args = this.commandOptions['-B'];
this.twoArgsImpliedHead(args, '-B'); this.twoArgsImpliedHead(args, '-B');
@ -1438,6 +1450,21 @@ var Ref = Backbone.Model.extend({
throw new Error('must be given an id'); throw new Error('must be given an id');
} }
this.set('type', 'general ref'); 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() { toString: function() {
@ -1476,7 +1503,7 @@ var Commit = Backbone.Model.extend({
circularFields: ['gitVisuals', 'visNode', 'children'] circularFields: ['gitVisuals', 'visNode', 'children']
}, },
getLogEntry: function() { getLogEntry: function() {
// for now we are just joining all these things with newlines which // 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 // 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 // it's better than making an entire template and all that jazz

View file

@ -11,7 +11,6 @@ Big things:
Medium things: Medium things:
~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
- gitEngine loads from tree immediately, not the weird thing we have now! - gitEngine loads from tree immediately, not the weird thing we have now!
- help better
Small things to implement: Small things to implement:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~