Resolves #154 input escaping issue when accessing remote branch locally to push remote, fixed others too

This commit is contained in:
Peter Cottle 2014-01-06 10:04:03 -08:00
parent 0bb6133f87
commit f952bd7061
2 changed files with 18 additions and 4 deletions

View file

@ -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"}}}'
);
});
});

View file

@ -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)