aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Baumgart2010-09-02 11:09:44 (EDT)
committerJens Baumgart2010-09-02 11:09:44 (EDT)
commit375f4c14888f793d859ce71482bacc8f96f00846 (patch)
tree3201dbf9ddb0ae1180fe43d7492f79807e7dafe2
parente42e2d61222fbb90078e7b3b9a52e5c2fe892801 (diff)
downloadegit-375f4c14888f793d859ce71482bacc8f96f00846.zip
egit-375f4c14888f793d859ce71482bacc8f96f00846.tar.gz
egit-375f4c14888f793d859ce71482bacc8f96f00846.tar.bz2
Reset now resets merging staterefs/changes/06/1506/1
ResetOperation did not reset the repository state merging / merging resolved on a hard / mixed reset. Now MERGE_HEAD and MERGE_MSG are removed on hard / mixed reset. Change-Id: If9cc7cfa5c32aa1f9d98d0a2b3998c222a18e38c Signed-off-by: Jens Baumgart <jens.baumgart@sap.com>
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/CoreText.java3
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/coretext.properties1
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/ResetOperation.java26
3 files changed, 28 insertions, 2 deletions
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/CoreText.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/CoreText.java
index 52b4b1c..1463f53 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/CoreText.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/CoreText.java
@@ -173,6 +173,9 @@ public class CoreText extends NLS {
public static String ResetOperation_readingIndex;
/** */
+ public static String ResetOperation_resetMergeFailed;
+
+ /** */
public static String ResetOperation_updatingFailed;
/** */
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/coretext.properties b/org.eclipse.egit.core/src/org/eclipse/egit/core/coretext.properties
index 8e6920d..8dc7220 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/coretext.properties
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/coretext.properties
@@ -65,6 +65,7 @@ ResetOperation_lookingUpRef=looking up ref {0}
ResetOperation_mappingTreeForCommit=mapping tree for commit
ResetOperation_performingReset=Performing {0} reset to {1}
ResetOperation_readingIndex=Reading index
+ResetOperation_resetMergeFailed=Resetting merge mode failed
ResetOperation_updatingFailed=Updating {0} failed
ResetOperation_writingIndex=Writing index
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ResetOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ResetOperation.java
index 0650c47..d774b87 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ResetOperation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ResetOperation.java
@@ -28,6 +28,7 @@ import org.eclipse.jgit.lib.GitIndex;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.RefUpdate;
import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.lib.RepositoryState;
import org.eclipse.jgit.lib.WorkDirCheckout;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevTree;
@@ -115,11 +116,17 @@ public class ResetOperation implements IEGitOperation {
private void reset(IProgressMonitor monitor) throws CoreException {
monitor.beginTask(NLS.bind(CoreText.ResetOperation_performingReset,
- type.toString().toLowerCase(), refName), 6);
+ type.toString().toLowerCase(), refName), 7);
IProject[] validProjects = null;
if (type == ResetType.HARD)
validProjects = ProjectUtil.getValidProjects(repository);
+ boolean merging = false;
+ if (repository.getRepositoryState().equals(RepositoryState.MERGING)
+ || repository.getRepositoryState().equals(
+ RepositoryState.MERGING_RESOLVED))
+ merging = true;
+
mapObjects();
monitor.worked(1);
@@ -134,6 +141,9 @@ public class ResetOperation implements IEGitOperation {
monitor.worked(1);
writeIndex();
monitor.worked(1);
+ if (merging)
+ resetMerge();
+ monitor.worked(1);
// only refresh if working tree changes
ProjectUtil.refreshValidProjects(validProjects, new SubProgressMonitor(
monitor, 1));
@@ -146,16 +156,28 @@ public class ResetOperation implements IEGitOperation {
monitor.worked(1);
writeIndex();
monitor.worked(3);
+ if (merging)
+ resetMerge();
+ monitor.worked(1);
break;
case SOFT:
// only change the ref
- monitor.worked(4);
+ monitor.worked(5);
}
monitor.done();
}
+ private void resetMerge() throws CoreException {
+ try {
+ repository.writeMergeHeads(null);
+ repository.writeMergeCommitMsg(null);
+ } catch (IOException e) {
+ throw new TeamException(CoreText.ResetOperation_resetMergeFailed, e);
+ }
+ }
+
private void mapObjects() throws TeamException {
final ObjectId commitId;
try {