diff --git a/spec/remote.spec.js b/spec/remote.spec.js index e614e16a..718292e8 100644 --- a/spec/remote.spec.js +++ b/spec/remote.spec.js @@ -353,5 +353,19 @@ describe('Git Remotes', function() { ); }); + it('creates the branch on the fly', function() { + expectTreeAsync( + 'git clone; git commit; go -b side; git push origin side', + '{"branches":{"master":{"target":"C2","id":"master","remoteTrackingBranchID":"o/master"},"o/master":{"target":"C1","id":"o/master","remoteTrackingBranchID":null},"side":{"target":"C2","id":"side","remoteTrackingBranchID":"o/side"},"o/side":{"target":"C2","id":"o/side","remoteTrackingBranchID":null}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"},"C2":{"parents":["C1"],"id":"C2"}},"tags":{},"HEAD":{"target":"side","id":"HEAD"},"originTree":{"branches":{"master":{"target":"C1","id":"master","remoteTrackingBranchID":null},"side":{"target":"C2","id":"side","remoteTrackingBranchID":null}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"},"C2":{"parents":["C1"],"id":"C2"}},"tags":{},"HEAD":{"target":"master","id":"HEAD"}}}' + ); + }); + + it('does not create the o/master branch on remote', function() { + expectTreeAsync( + 'git clone; git commit; git push origin o/master', + '{"branches":{"master":{"target":"C2","id":"master","remoteTrackingBranchID":"o/master"},"o/master":{"target":"C1","id":"o/master","remoteTrackingBranchID":null}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"},"C2":{"parents":["C1"],"id":"C2"}},"tags":{},"HEAD":{"target":"master","id":"HEAD"},"originTree":{"branches":{"master":{"target":"C1","id":"master","remoteTrackingBranchID":null}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"}},"tags":{},"HEAD":{"target":"master","id":"HEAD"}}}' + ); + }); + }); diff --git a/src/js/git/commands.js b/src/js/git/commands.js index 77ef2b01..8d86c40d 100644 --- a/src/js/git/commands.js +++ b/src/js/git/commands.js @@ -48,7 +48,7 @@ var assertNotCheckedOut = function(engine, ref) { var assertIsBranch = function(engine, ref) { assertIsRef(engine, ref); - var obj = engine.refs[ref]; + var obj = engine.resolveID(ref); if (!obj || obj.get('type') !== 'branch') { throw new GitError({ msg: intl.todo( @@ -60,7 +60,7 @@ var assertIsBranch = function(engine, ref) { var assertIsRemoteBranch = function(engine, ref) { assertIsRef(engine, ref); - var obj = engine.refs[ref]; + var obj = engine.resolveID(ref); if (obj.get('type') !== 'branch' || !obj.getIsRemote()) { @@ -87,7 +87,7 @@ var assertOriginSpecified = function(generalArgs) { var assertBranchIsRemoteTracking = function(engine, branchName) { branchName = crappyUnescape(branchName); - if (!engine.refs[branchName]) { + if (!engine.resolveID(branchName)) { throw new GitError({ msg: intl.todo(branchName + ' is not a branch!') }); @@ -697,7 +697,7 @@ var commandConfig = { // can be created on demand but we at least need this to be a source // locally otherwise we will fail assertIsRef(engine, firstArg); - sourceObj = engine.refs[firstArg]; + sourceObj = engine.resolveID(firstArg); } else { // since they have not specified a source or destination, then // we source from the branch we are on (or HEAD)