aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org
diff options
context:
space:
mode:
authorStefan Lay <stefan.lay@sap.com>2013-12-10 15:54:48 +0100
committerStefan Lay <stefan.lay@sap.com>2013-12-10 15:54:48 +0100
commite90438c0e867bd105334b75df3a6d640ef8dab01 (patch)
tree93cfb6f300015b33f76d97f5e16a211a0d325cd7 /org.eclipse.jgit/src/org
parent162a5c4c89b289af3755a2f26843cdf908e93c50 (diff)
downloadjgit-e90438c0e867bd105334b75df3a6d640ef8dab01.tar.gz
jgit-e90438c0e867bd105334b75df3a6d640ef8dab01.zip
Fix aborting rebase with detached head
Bug: 423670 Change-Id: Ia6052867f85d4974c4f60ee5a6c820501e8d2427
Diffstat (limited to 'org.eclipse.jgit/src/org')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java31
1 files changed, 18 insertions, 13 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 10b273a744..ac6f5487a1 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java
@@ -1101,24 +1101,29 @@ public class RebaseCommand extends GitCommand<RebaseResult> {
}
try {
String headName = rebaseState.readFile(HEAD_NAME);
- if (headName.startsWith(Constants.R_REFS)) {
monitor.beginTask(MessageFormat.format(
JGitText.get().resettingHead, headName),
ProgressMonitor.UNKNOWN);
+ Result res = null;
+ RefUpdate refUpdate = repo.updateRef(Constants.HEAD, false);
+ refUpdate.setRefLogMessage("rebase: aborting", false); //$NON-NLS-1$
+ if (headName.startsWith(Constants.R_REFS)) {
// update the HEAD
- RefUpdate refUpdate = repo.updateRef(Constants.HEAD, false);
- refUpdate.setRefLogMessage("rebase: aborting", false); //$NON-NLS-1$
- Result res = refUpdate.link(headName);
- switch (res) {
- case FAST_FORWARD:
- case FORCED:
- case NO_CHANGE:
- break;
- default:
- throw new JGitInternalException(
- JGitText.get().abortingRebaseFailed);
- }
+ res = refUpdate.link(headName);
+ } else {
+ refUpdate.setNewObjectId(repo.readOrigHead());
+ res = refUpdate.forceUpdate();
+
+ }
+ switch (res) {
+ case FAST_FORWARD:
+ case FORCED:
+ case NO_CHANGE:
+ break;
+ default:
+ throw new JGitInternalException(
+ JGitText.get().abortingRebaseFailed);
}
boolean stashConflicts = autoStashApply();
// cleanup the files