summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Aniszczyk <caniszczyk@gmail.com>2010-12-07 09:34:25 -0500
committerCode Review <codereview-daemon@eclipse.org>2010-12-07 09:34:25 -0500
commit48b73efe1e08c5aea4422cf13bd09d92fcde2511 (patch)
treeaa41da6eecef422fdbb5107ad0d953bb595fd961
parenta51f44edb068daa96d3908dc8bfef77a7568aafe (diff)
parentad96546ca023c260ed7250c447f4c8abe168afd3 (diff)
downloadjgit-48b73efe1e08c5aea4422cf13bd09d92fcde2511.tar.gz
jgit-48b73efe1e08c5aea4422cf13bd09d92fcde2511.zip
Merge "Rebase Interoperability third part: handle stop upon conflict"
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java27
1 files changed, 26 insertions, 1 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java
index fbe7debc45..78ddf87079 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java
@@ -44,6 +44,7 @@ package org.eclipse.jgit.api;
import java.io.BufferedReader;
import java.io.BufferedWriter;
+import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -63,6 +64,7 @@ import org.eclipse.jgit.api.errors.JGitInternalException;
import org.eclipse.jgit.api.errors.NoHeadException;
import org.eclipse.jgit.api.errors.RefNotFoundException;
import org.eclipse.jgit.api.errors.WrongRepositoryStateException;
+import org.eclipse.jgit.diff.DiffFormatter;
import org.eclipse.jgit.dircache.DirCacheCheckout;
import org.eclipse.jgit.lib.AbbreviatedObjectId;
import org.eclipse.jgit.lib.Constants;
@@ -204,7 +206,7 @@ public class RebaseCommand extends GitCommand<RebaseResult> {
.call();
monitor.endTask();
if (newHead == null) {
- return new RebaseResult(commitToPick);
+ return stop(commitToPick);
}
stepsToPop++;
}
@@ -227,6 +229,29 @@ public class RebaseCommand extends GitCommand<RebaseResult> {
}
}
+ private RebaseResult stop(RevCommit commitToPick) throws IOException {
+ StringBuilder sb = new StringBuilder(100);
+ sb.append("GIT_AUTHOR_NAME='");
+ sb.append(commitToPick.getAuthorIdent().getName());
+ sb.append("'\n");
+ sb.append("GIT_AUTHOR_EMAIL='");
+ sb.append(commitToPick.getAuthorIdent().getEmailAddress());
+ sb.append("'\n");
+ sb.append("GIT_AUTHOR_DATE='");
+ sb.append(commitToPick.getAuthorIdent().getWhen());
+ sb.append("'\n");
+ createFile(rebaseDir, "author-script", sb.toString());
+ createFile(rebaseDir, "message", commitToPick.getShortMessage());
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ DiffFormatter df = new DiffFormatter(bos);
+ df.setRepository(repo);
+ df.format(commitToPick.getParent(0), commitToPick);
+ createFile(rebaseDir, "patch", new String(bos.toByteArray(), "UTF-8"));
+ createFile(rebaseDir, "stopped-sha", repo.newObjectReader().abbreviate(
+ commitToPick).name());
+ return new RebaseResult(commitToPick);
+ }
+
/**
* Removes the number of lines given in the parameter from the
* <code>git-rebase-todo</code> file but preserves comments and other lines