diff options
author | Mathias Kinzler | 2011-02-04 21:57:06 +0000 |
---|---|---|
committer | Matthias Sohn | 2011-02-04 21:57:32 +0000 |
commit | 6bfa7be26b140e222f8846c8ff561241c7c9caa9 (patch) | |
tree | 2cf78f35f0fdcf153f92d8a82d6e6a49b5b7b6b1 | |
parent | 1b30bfc57274a74213625f0c209680a595ae1838 (diff) | |
download | egit-6bfa7be26b140e222f8846c8ff561241c7c9caa9.tar.gz egit-6bfa7be26b140e222f8846c8ff561241c7c9caa9.tar.xz egit-6bfa7be26b140e222f8846c8ff561241c7c9caa9.zip |
Create Branch: wrong initialization of "upstream config"
This results in the wrong configuration if the user does not click on
any of the "Pull Strategy" buttons.
Change-Id: Ib5e7768a627088137c1cb0621bf380dcd9152c83
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r-- | org.eclipse.egit.core/src/org/eclipse/egit/core/op/CreateLocalBranchOperation.java | 12 | ||||
-rw-r--r-- | org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/CreateBranchPage.java | 28 |
2 files changed, 14 insertions, 26 deletions
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/CreateLocalBranchOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/CreateLocalBranchOperation.java index f15fd5ea73..112e14b6b9 100644 --- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/CreateLocalBranchOperation.java +++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/CreateLocalBranchOperation.java @@ -92,11 +92,15 @@ public class CreateLocalBranchOperation implements IEGitOperation { actMonitor.beginTask(taskName, 1); Git git = new Git(repository); try { - if (upstreamConfig != null - && upstreamConfig != UpstreamConfig.NONE) + if (ref != null) { + SetupUpstreamMode mode; + if (upstreamConfig == UpstreamConfig.NONE) + mode = SetupUpstreamMode.NOTRACK; + else + mode = SetupUpstreamMode.SET_UPSTREAM; git.branchCreate().setName(name).setStartPoint( - ref.getName()).setUpstreamMode( - SetupUpstreamMode.TRACK).call(); + ref.getName()).setUpstreamMode(mode).call(); + } else git.branchCreate().setName(name).setStartPoint(commit) .setUpstreamMode(SetupUpstreamMode.NOTRACK) diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/CreateBranchPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/CreateBranchPage.java index c25908ee58..f4d71bdbfc 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/CreateBranchPage.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/CreateBranchPage.java @@ -73,9 +73,7 @@ class CreateBranchPage extends WizardPage { private Composite warningComposite; - private UpstreamConfig upstreamConfig = UpstreamConfig.REBASE; - - private final UpstreamConfig defaultUpstreamConfig; + private UpstreamConfig upstreamConfig; private Group upstreamConfigGroup; @@ -102,8 +100,7 @@ class CreateBranchPage extends WizardPage { this.myBaseCommit = null; this.myValidator = ValidationUtils.getRefNameInputValidator( myRepository, Constants.R_HEADS, true); - this.defaultUpstreamConfig = getDefaultUpstreamConfig(repo, baseRef - .getName()); + this.upstreamConfig = getDefaultUpstreamConfig(repo, baseRef.getName()); setTitle(UIText.CreateBranchPage_Title); setMessage(UIText.CreateBranchPage_ChooseBranchAndNameMessage); } @@ -125,7 +122,7 @@ class CreateBranchPage extends WizardPage { this.myBaseCommit = baseCommit; this.myValidator = ValidationUtils.getRefNameInputValidator( myRepository, Constants.R_HEADS, true); - this.defaultUpstreamConfig = UpstreamConfig.NONE; + this.upstreamConfig = UpstreamConfig.NONE; setTitle(UIText.CreateBranchPage_Title); setMessage(UIText.CreateBranchPage_ChooseNameMessage); } @@ -264,18 +261,6 @@ class CreateBranchPage extends WizardPage { buttonConfigNone .setToolTipText(UIText.CreateBranchPage_PullNoneTooltip); - switch (defaultUpstreamConfig) { - case REBASE: - buttonConfigRebase.setSelection(true); - break; - case MERGE: - buttonConfigMerge.setSelection(true); - break; - case NONE: - buttonConfigNone.setSelection(true); - break; - } - boolean isBare = myRepository.isBare(); checkout = new Button(main, SWT.CHECK); checkout.setText(UIText.CreateBranchPage_CheckoutButton); @@ -305,11 +290,10 @@ class CreateBranchPage extends WizardPage { nameText.setText(myBaseRef .substring(myBaseRef.lastIndexOf('/') + 1)); nameText.selectAll(); - checkPage(); - } else { + } else // in any case, we will have to enter the name setPageComplete(false); - } + checkPage(); // add the listener just now to avoid unneeded checkPage() nameText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { @@ -322,7 +306,7 @@ class CreateBranchPage extends WizardPage { setErrorMessage(null); try { GridData gd = (GridData) warningComposite.getLayoutData(); - gd.exclude = branchCombo.getText().startsWith(Constants.R_REMOTES); + gd.exclude = !branchCombo.getText().startsWith(Constants.R_HEADS); warningComposite.setVisible(!gd.exclude); gd = (GridData) upstreamConfigGroup.getLayoutData(); |