summaryrefslogtreecommitdiff
path: root/plugins/git4idea/src/git4idea/config
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/git4idea/src/git4idea/config')
-rw-r--r--plugins/git4idea/src/git4idea/config/GitVcsPanel.form11
-rw-r--r--plugins/git4idea/src/git4idea/config/GitVcsPanel.java15
-rw-r--r--plugins/git4idea/src/git4idea/config/GitVcsSettings.java29
3 files changed, 40 insertions, 15 deletions
diff --git a/plugins/git4idea/src/git4idea/config/GitVcsPanel.form b/plugins/git4idea/src/git4idea/config/GitVcsPanel.form
index 0f24aaf99d56..87d3578f7c0a 100644
--- a/plugins/git4idea/src/git4idea/config/GitVcsPanel.form
+++ b/plugins/git4idea/src/git4idea/config/GitVcsPanel.form
@@ -91,7 +91,7 @@
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
- <grid id="4d15a" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
+ <grid id="4d15a" layout-manager="GridLayoutManager" row-count="5" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
@@ -134,6 +134,15 @@
<text value="Warn if &amp;CRLF line separators are about to be committed"/>
</properties>
</component>
+ <component id="29d5c" class="javax.swing.JCheckBox" binding="myWarnAboutDetachedHead">
+ <constraints>
+ <grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+ </constraints>
+ <properties>
+ <selected value="true"/>
+ <text value="Warn when committing in detached HEAD or during rebase"/>
+ </properties>
+ </component>
</children>
</grid>
</children>
diff --git a/plugins/git4idea/src/git4idea/config/GitVcsPanel.java b/plugins/git4idea/src/git4idea/config/GitVcsPanel.java
index a8ebfe66140f..c8c2ad46a274 100644
--- a/plugins/git4idea/src/git4idea/config/GitVcsPanel.java
+++ b/plugins/git4idea/src/git4idea/config/GitVcsPanel.java
@@ -15,18 +15,17 @@
*/
package git4idea.config;
+import com.intellij.dvcs.branch.DvcsBranchSync;
import com.intellij.openapi.application.ApplicationNamesInfo;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
-import com.intellij.openapi.util.SystemInfo;
import com.intellij.ui.components.JBCheckBox;
import git4idea.GitVcs;
import git4idea.i18n.GitBundle;
import git4idea.repo.GitRepositoryManager;
-import git4idea.ui.branch.GitBranchSyncSetting;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@@ -52,6 +51,7 @@ public class GitVcsPanel {
private JBCheckBox mySyncBranchControl;
private JCheckBox myAutoCommitOnCherryPick;
private JBCheckBox myWarnAboutCrlf;
+ private JCheckBox myWarnAboutDetachedHead;
public GitVcsPanel(@NotNull Project project) {
myVcs = GitVcs.getInstance(project);
@@ -119,9 +119,10 @@ public class GitVcsPanel {
myGitField.setText(settings.getAppSettings().getPathToGit());
mySSHExecutableComboBox.setSelectedItem(settings.isIdeaSsh() ? IDEA_SSH : NATIVE_SSH);
myAutoUpdateIfPushRejected.setSelected(settings.autoUpdateIfPushRejected());
- mySyncBranchControl.setSelected(settings.getSyncSetting() == GitBranchSyncSetting.SYNC);
+ mySyncBranchControl.setSelected(settings.getSyncSetting() == DvcsBranchSync.SYNC);
myAutoCommitOnCherryPick.setSelected(settings.isAutoCommitOnCherryPick());
myWarnAboutCrlf.setSelected(settings.warnAboutCrlf());
+ myWarnAboutDetachedHead.setSelected(settings.warnAboutDetachedHead());
}
/**
@@ -133,9 +134,10 @@ public class GitVcsPanel {
return !settings.getAppSettings().getPathToGit().equals(getCurrentExecutablePath()) ||
(settings.isIdeaSsh() != IDEA_SSH.equals(mySSHExecutableComboBox.getSelectedItem())) ||
!settings.autoUpdateIfPushRejected() == myAutoUpdateIfPushRejected.isSelected() ||
- ((settings.getSyncSetting() == GitBranchSyncSetting.SYNC) != mySyncBranchControl.isSelected() ||
+ ((settings.getSyncSetting() == DvcsBranchSync.SYNC) != mySyncBranchControl.isSelected() ||
settings.isAutoCommitOnCherryPick() != myAutoCommitOnCherryPick.isSelected() ||
- settings.warnAboutCrlf() != myWarnAboutCrlf.isSelected());
+ settings.warnAboutCrlf() != myWarnAboutCrlf.isSelected() ||
+ settings.warnAboutDetachedHead() != myWarnAboutDetachedHead.isSelected());
}
/**
@@ -151,9 +153,10 @@ public class GitVcsPanel {
GitVcsApplicationSettings.SshExecutable.NATIVE_SSH);
settings.setAutoUpdateIfPushRejected(myAutoUpdateIfPushRejected.isSelected());
- settings.setSyncSetting(mySyncBranchControl.isSelected() ? GitBranchSyncSetting.SYNC : GitBranchSyncSetting.DONT);
+ settings.setSyncSetting(mySyncBranchControl.isSelected() ? DvcsBranchSync.SYNC : DvcsBranchSync.DONT);
settings.setAutoCommitOnCherryPick(myAutoCommitOnCherryPick.isSelected());
settings.setWarnAboutCrlf(myWarnAboutCrlf.isSelected());
+ settings.setWarnAboutDetachedHead(myWarnAboutDetachedHead.isSelected());
}
}
diff --git a/plugins/git4idea/src/git4idea/config/GitVcsSettings.java b/plugins/git4idea/src/git4idea/config/GitVcsSettings.java
index 1b5860631e59..7dd7f9b1004b 100644
--- a/plugins/git4idea/src/git4idea/config/GitVcsSettings.java
+++ b/plugins/git4idea/src/git4idea/config/GitVcsSettings.java
@@ -15,12 +15,16 @@
*/
package git4idea.config;
+import com.intellij.dvcs.branch.DvcsBranchSync;
+import com.intellij.dvcs.branch.DvcsSyncBranchSettings;
import com.intellij.lifecycle.PeriodicalTasksCloser;
-import com.intellij.openapi.components.*;
+import com.intellij.openapi.components.PersistentStateComponent;
+import com.intellij.openapi.components.State;
+import com.intellij.openapi.components.Storage;
+import com.intellij.openapi.components.StoragePathMacros;
import com.intellij.openapi.project.Project;
import com.intellij.util.ArrayUtil;
import git4idea.reset.GitResetMode;
-import git4idea.ui.branch.GitBranchSyncSetting;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -32,8 +36,8 @@ import java.util.Map;
/**
* Git VCS settings
*/
-@State(name = "Git.Settings", roamingType = RoamingType.DISABLED, storages = {@Storage(file = StoragePathMacros.WORKSPACE_FILE)})
-public class GitVcsSettings implements PersistentStateComponent<GitVcsSettings.State> {
+@State(name = "Git.Settings", storages = {@Storage(file = StoragePathMacros.WORKSPACE_FILE)})
+public class GitVcsSettings implements PersistentStateComponent<GitVcsSettings.State>, DvcsSyncBranchSettings {
private static final int PREVIOUS_COMMIT_AUTHORS_LIMIT = 16; // Limit for previous commit authors
@@ -56,12 +60,13 @@ public class GitVcsSettings implements PersistentStateComponent<GitVcsSettings.S
public UpdateChangesPolicy UPDATE_CHANGES_POLICY = UpdateChangesPolicy.STASH;
public UpdateMethod UPDATE_TYPE = UpdateMethod.BRANCH_DEFAULT;
public boolean PUSH_AUTO_UPDATE = false;
- public GitBranchSyncSetting SYNC_SETTING = GitBranchSyncSetting.NOT_DECIDED;
+ public DvcsBranchSync SYNC_SETTING = DvcsBranchSync.NOT_DECIDED;
public String RECENT_GIT_ROOT_PATH = null;
public Map<String, String> RECENT_BRANCH_BY_REPOSITORY = new HashMap<String, String>();
public String RECENT_COMMON_BRANCH = null;
public boolean AUTO_COMMIT_ON_CHERRY_PICK = false;
public boolean WARN_ABOUT_CRLF = true;
+ public boolean WARN_ABOUT_DETACHED_HEAD = true;
public GitResetMode RESET_MODE = null;
}
@@ -72,7 +77,7 @@ public class GitVcsSettings implements PersistentStateComponent<GitVcsSettings.S
public GitVcsApplicationSettings getAppSettings() {
return myAppSettings;
}
-
+
public static GitVcsSettings getInstance(Project project) {
return PeriodicalTasksCloser.getInstance().safeGetService(project, GitVcsSettings.class);
}
@@ -128,11 +133,11 @@ public class GitVcsSettings implements PersistentStateComponent<GitVcsSettings.S
}
@NotNull
- public GitBranchSyncSetting getSyncSetting() {
+ public DvcsBranchSync getSyncSetting() {
return myState.SYNC_SETTING;
}
- public void setSyncSetting(@NotNull GitBranchSyncSetting syncSetting) {
+ public void setSyncSetting(@NotNull DvcsBranchSync syncSetting) {
myState.SYNC_SETTING = syncSetting;
}
@@ -179,6 +184,14 @@ public class GitVcsSettings implements PersistentStateComponent<GitVcsSettings.S
myState.WARN_ABOUT_CRLF = warn;
}
+ public boolean warnAboutDetachedHead() {
+ return myState.WARN_ABOUT_DETACHED_HEAD;
+ }
+
+ public void setWarnAboutDetachedHead(boolean warn) {
+ myState.WARN_ABOUT_DETACHED_HEAD = warn;
+ }
+
@Nullable
public GitResetMode getResetMode() {
return myState.RESET_MODE;