now executing all codepaths for git push args, need to fix level still though

This commit is contained in:
Peter Cottle 2013-10-15 17:36:29 -07:00
parent e99b6d7c61
commit e5b4ac5b1c
3 changed files with 24 additions and 17 deletions

View file

@ -205,5 +205,12 @@ describe('Git Remotes', function() {
);
});
it('will push to the remote tracking branch WHILE NOT on branch if it is set up', function() {
expectTreeAsync(
'git clone; git checkout -b foo o/master; git commit; go master; git push origin foo',
'{"branches":{"master":{"target":"C1","id":"master","remoteTrackingBranchID":"o/master"},"o/master":{"target":"C2","id":"o/master","remoteTrackingBranchID":null},"foo":{"target":"C2","id":"foo","remoteTrackingBranchID":"o/master"}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"},"C2":{"parents":["C1"],"id":"C2"}},"HEAD":{"target":"master","id":"HEAD"},"originTree":{"branches":{"master":{"target":"C2","id":"master","remoteTrackingBranchID":null}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"},"C2":{"parents":["C1"],"id":"C2"}},"HEAD":{"target":"master","id":"HEAD"}}}'
);
});
});

View file

@ -562,31 +562,33 @@ var commandConfig = {
}
var options = {};
var destination;
var source;
var sourceObj;
// git push is pretty complex in terms of
// the arguments it wants as well -- see
// git pull for a more detailed description.
// the arguments it wants as well... get ready!
var generalArgs = command.getGeneralArgs();
command.twoArgsImpliedOrigin(generalArgs);
assertOriginSpecified(generalArgs);
var destination;
var source;
var firstArg = generalArgs[1];
if (firstArg) {
if (isColonRefspec(firstArg)) {
if (firstArg && isColonRefspec(firstArg)) {
var refspecParts = firstArg.split(':');
source = refspecParts[0];
destination = validateBranchName(engine, refspecParts[1]);
} else {
if (firstArg) {
// we are using this arg as destination AND source. the dest branch
// can be created on demand but we at least need this to be a source
// locally otherwise we will fail
source = destination = firstArg;
}
assertIsRef(engine, firstArg);
sourceObj = engine.refs[firstArg];
} else {
// since they have not specified a source or destination, then
// we source from the branch we are on (or HEAD)
var sourceObj = engine.getOneBeforeCommit('HEAD');
sourceObj = engine.getOneBeforeCommit('HEAD');
}
source = sourceObj.get('id');
// HOWEVER we push to either the remote tracking branch we have

View file

@ -19,8 +19,6 @@ Argument things:
aka fetch + merge, just like expected. ill probably still update o/master just for sanity. master is the source on the remote and HEAD is the source on local (place to merge). o/master gets updated regardless
2) ok so say I'm on a new branch banana thats not on remote. if I do "git push" then it will MAKE a new branch on remote and push my commits there. same thing with "git push origin banana". Basically banana has to be a local ref, and if so, it will just make the ref on remote.
so "git push origin branchNotOnLocal" fails but "git push origin someBranch" will make the someBranch on remote.
3) HOWEVER if I'm git push-ing on banana and I say "git push origin master" then it pretends Im checked out on master. aka master is both source and destination, as expected. this is really 3