mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-26 07:58:34 +02:00
now executing all codepaths for git push args, need to fix level still though
This commit is contained in:
parent
e99b6d7c61
commit
e5b4ac5b1c
3 changed files with 24 additions and 17 deletions
|
@ -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"}}}'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -562,31 +562,33 @@ var commandConfig = {
|
||||||
}
|
}
|
||||||
|
|
||||||
var options = {};
|
var options = {};
|
||||||
|
var destination;
|
||||||
|
var source;
|
||||||
|
var sourceObj;
|
||||||
|
|
||||||
// git push is pretty complex in terms of
|
// git push is pretty complex in terms of
|
||||||
// the arguments it wants as well -- see
|
// the arguments it wants as well... get ready!
|
||||||
// git pull for a more detailed description.
|
|
||||||
var generalArgs = command.getGeneralArgs();
|
var generalArgs = command.getGeneralArgs();
|
||||||
command.twoArgsImpliedOrigin(generalArgs);
|
command.twoArgsImpliedOrigin(generalArgs);
|
||||||
assertOriginSpecified(generalArgs);
|
assertOriginSpecified(generalArgs);
|
||||||
|
|
||||||
var destination;
|
|
||||||
var source;
|
|
||||||
var firstArg = generalArgs[1];
|
var firstArg = generalArgs[1];
|
||||||
if (firstArg) {
|
if (firstArg && isColonRefspec(firstArg)) {
|
||||||
if (isColonRefspec(firstArg)) {
|
var refspecParts = firstArg.split(':');
|
||||||
var refspecParts = firstArg.split(':');
|
source = refspecParts[0];
|
||||||
source = refspecParts[0];
|
destination = validateBranchName(engine, refspecParts[1]);
|
||||||
destination = validateBranchName(engine, refspecParts[1]);
|
} else {
|
||||||
} else {
|
if (firstArg) {
|
||||||
// we are using this arg as destination AND source. the dest branch
|
// 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
|
// can be created on demand but we at least need this to be a source
|
||||||
// locally otherwise we will fail
|
// 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)
|
||||||
|
sourceObj = engine.getOneBeforeCommit('HEAD');
|
||||||
}
|
}
|
||||||
} 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');
|
|
||||||
source = sourceObj.get('id');
|
source = sourceObj.get('id');
|
||||||
|
|
||||||
// HOWEVER we push to either the remote tracking branch we have
|
// HOWEVER we push to either the remote tracking branch we have
|
||||||
|
|
2
todo.txt
2
todo.txt
|
@ -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
|
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.
|
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
|
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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue