Rebase Interoperability third part: handle stop upon conflict

There are some files that need to exist so that the CLI can continue
after the rebase has been stopped due to conflicts

Change-Id: I3cb4dc98609c059bf0cf9fd5f9e47a9c681cea2d
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
This commit is contained in:
Mathias Kinzler 2010-12-07 13:34:44 +01:00
parent 59e62ba7e1
commit ad96546ca0
1 changed files with 26 additions and 1 deletions

View File

@ -44,6 +44,7 @@
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.BufferedWriter; import java.io.BufferedWriter;
import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
@ -63,6 +64,7 @@
import org.eclipse.jgit.api.errors.NoHeadException; import org.eclipse.jgit.api.errors.NoHeadException;
import org.eclipse.jgit.api.errors.RefNotFoundException; import org.eclipse.jgit.api.errors.RefNotFoundException;
import org.eclipse.jgit.api.errors.WrongRepositoryStateException; import org.eclipse.jgit.api.errors.WrongRepositoryStateException;
import org.eclipse.jgit.diff.DiffFormatter;
import org.eclipse.jgit.dircache.DirCacheCheckout; import org.eclipse.jgit.dircache.DirCacheCheckout;
import org.eclipse.jgit.lib.AbbreviatedObjectId; import org.eclipse.jgit.lib.AbbreviatedObjectId;
import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.Constants;
@ -204,7 +206,7 @@ public RebaseResult call() throws NoHeadException, RefNotFoundException,
.call(); .call();
monitor.endTask(); monitor.endTask();
if (newHead == null) { if (newHead == null) {
return new RebaseResult(commitToPick); return stop(commitToPick);
} }
stepsToPop++; stepsToPop++;
} }
@ -227,6 +229,29 @@ public RebaseResult call() throws NoHeadException, RefNotFoundException,
} }
} }
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 * Removes the number of lines given in the parameter from the
* <code>git-rebase-todo</code> file but preserves comments and other lines * <code>git-rebase-todo</code> file but preserves comments and other lines