|
|
@ -672,15 +672,15 @@ public class RebaseCommand extends GitCommand<RebaseResult> { |
|
|
|
FileUtils.delete(currentCommitFile); |
|
|
|
FileUtils.delete(currentCommitFile); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private RebaseResult finishRebase(RevCommit newHead, |
|
|
|
private RebaseResult finishRebase(RevCommit finalHead, |
|
|
|
boolean lastStepWasForward) throws IOException, GitAPIException { |
|
|
|
boolean lastStepIsForward) throws IOException, GitAPIException { |
|
|
|
String headName = rebaseState.readFile(HEAD_NAME); |
|
|
|
String headName = rebaseState.readFile(HEAD_NAME); |
|
|
|
updateHead(headName, newHead, upstreamCommit); |
|
|
|
updateHead(headName, finalHead, upstreamCommit); |
|
|
|
boolean stashConflicts = autoStashApply(); |
|
|
|
boolean stashConflicts = autoStashApply(); |
|
|
|
FileUtils.delete(rebaseState.getDir(), FileUtils.RECURSIVE); |
|
|
|
FileUtils.delete(rebaseState.getDir(), FileUtils.RECURSIVE); |
|
|
|
if (stashConflicts) |
|
|
|
if (stashConflicts) |
|
|
|
return RebaseResult.STASH_APPLY_CONFLICTS_RESULT; |
|
|
|
return RebaseResult.STASH_APPLY_CONFLICTS_RESULT; |
|
|
|
if (lastStepWasForward || newHead == null) |
|
|
|
if (lastStepIsForward || finalHead == null) |
|
|
|
return RebaseResult.FAST_FORWARD_RESULT; |
|
|
|
return RebaseResult.FAST_FORWARD_RESULT; |
|
|
|
return RebaseResult.OK_RESULT; |
|
|
|
return RebaseResult.OK_RESULT; |
|
|
|
} |
|
|
|
} |
|
|
@ -753,7 +753,7 @@ public class RebaseCommand extends GitCommand<RebaseResult> { |
|
|
|
private RevCommit squashIntoPrevious(boolean sequenceContainsSquash, |
|
|
|
private RevCommit squashIntoPrevious(boolean sequenceContainsSquash, |
|
|
|
RebaseTodoLine nextStep) |
|
|
|
RebaseTodoLine nextStep) |
|
|
|
throws IOException, GitAPIException { |
|
|
|
throws IOException, GitAPIException { |
|
|
|
RevCommit newHead; |
|
|
|
RevCommit retNewHead; |
|
|
|
String commitMessage = rebaseState |
|
|
|
String commitMessage = rebaseState |
|
|
|
.readFile(MESSAGE_SQUASH); |
|
|
|
.readFile(MESSAGE_SQUASH); |
|
|
|
|
|
|
|
|
|
|
@ -765,7 +765,7 @@ public class RebaseCommand extends GitCommand<RebaseResult> { |
|
|
|
commitMessage = interactiveHandler |
|
|
|
commitMessage = interactiveHandler |
|
|
|
.modifyCommitMessage(commitMessage); |
|
|
|
.modifyCommitMessage(commitMessage); |
|
|
|
} |
|
|
|
} |
|
|
|
newHead = new Git(repo).commit() |
|
|
|
retNewHead = new Git(repo).commit() |
|
|
|
.setMessage(stripCommentLines(commitMessage)) |
|
|
|
.setMessage(stripCommentLines(commitMessage)) |
|
|
|
.setAmend(true).call(); |
|
|
|
.setAmend(true).call(); |
|
|
|
rebaseState.getFile(MESSAGE_SQUASH).delete(); |
|
|
|
rebaseState.getFile(MESSAGE_SQUASH).delete(); |
|
|
@ -773,11 +773,11 @@ public class RebaseCommand extends GitCommand<RebaseResult> { |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// Next step is either Squash or Fixup
|
|
|
|
// Next step is either Squash or Fixup
|
|
|
|
newHead = new Git(repo).commit() |
|
|
|
retNewHead = new Git(repo).commit() |
|
|
|
.setMessage(commitMessage).setAmend(true) |
|
|
|
.setMessage(commitMessage).setAmend(true) |
|
|
|
.call(); |
|
|
|
.call(); |
|
|
|
} |
|
|
|
} |
|
|
|
return newHead; |
|
|
|
return retNewHead; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static String stripCommentLines(String commitMessage) { |
|
|
|
private static String stripCommentLines(String commitMessage) { |
|
|
@ -862,13 +862,13 @@ public class RebaseCommand extends GitCommand<RebaseResult> { |
|
|
|
return ourCommitName; |
|
|
|
return ourCommitName; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void updateHead(String headName, RevCommit newHead, RevCommit onto) |
|
|
|
private void updateHead(String headName, RevCommit aNewHead, RevCommit onto) |
|
|
|
throws IOException { |
|
|
|
throws IOException { |
|
|
|
// point the previous head (if any) to the new commit
|
|
|
|
// point the previous head (if any) to the new commit
|
|
|
|
|
|
|
|
|
|
|
|
if (headName.startsWith(Constants.R_REFS)) { |
|
|
|
if (headName.startsWith(Constants.R_REFS)) { |
|
|
|
RefUpdate rup = repo.updateRef(headName); |
|
|
|
RefUpdate rup = repo.updateRef(headName); |
|
|
|
rup.setNewObjectId(newHead); |
|
|
|
rup.setNewObjectId(aNewHead); |
|
|
|
rup.setRefLogMessage("rebase finished: " + headName + " onto " //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
rup.setRefLogMessage("rebase finished: " + headName + " onto " //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
+ onto.getName(), false); |
|
|
|
+ onto.getName(), false); |
|
|
|
Result res = rup.forceUpdate(); |
|
|
|
Result res = rup.forceUpdate(); |
|
|
|