diff options
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java | 10 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java | 14 |
2 files changed, 20 insertions, 4 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java index dd812ee81a..9c8f4a7d10 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java @@ -48,6 +48,7 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; +import org.eclipse.jgit.api.RebaseCommand.Action; import org.eclipse.jgit.api.RebaseCommand.Operation; import org.eclipse.jgit.api.RebaseResult.Status; import org.eclipse.jgit.api.errors.RefNotFoundException; @@ -850,7 +851,14 @@ public class RebaseCommandTest extends RepositoryTestCase { try { String line = br.readLine(); while (line != null) { - if (line.startsWith("pick ")) + String actionToken = line.substring(0, line.indexOf(' ')); + Action action = null; + try { + action = Action.parse(actionToken); + } catch (Exception e) { + // ignore + } + if (action != null) count++; line = br.readLine(); } 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 70cf702ec1..36c06702a9 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java @@ -225,8 +225,6 @@ public class RebaseCommand extends GitCommand<RebaseResult> { List<Step> steps = loadSteps(); for (Step step : steps) { - if (step.action != Action.PICK) - continue; popSteps(1); Collection<ObjectId> ids = or.resolve(step.commit); if (ids.size() != 1) @@ -423,6 +421,8 @@ public class RebaseCommand extends GitCommand<RebaseResult> { String popCandidate = br.readLine(); if (popCandidate == null) break; + if (popCandidate.charAt(0) == '#') + continue; int spaceIndex = popCandidate.indexOf(' '); boolean pop = false; if (spaceIndex >= 0) { @@ -686,6 +686,10 @@ public class RebaseCommand extends GitCommand<RebaseResult> { String actionToken = new String(buf, tokenBegin, nextSpace - tokenBegin - 1); tokenBegin = nextSpace; + if (actionToken.charAt(0) == '#') { + tokenCount = 3; + break; + } Action action = Action.parse(actionToken); if (action != null) current = new Step(Action.parse(actionToken)); @@ -783,7 +787,11 @@ public class RebaseCommand extends GitCommand<RebaseResult> { static Action parse(String token) { if (token.equals("pick") || token.equals("p")) return PICK; - return null; + throw new JGitInternalException( + MessageFormat + .format( + "Unknown or unsupported command \"{0}\", only \"pick\" is allowed", + token)); } } |