diff options
author | Mathias Kinzler <mathias.kinzler@sap.com> | 2010-12-10 09:44:51 +0100 |
---|---|---|
committer | Mathias Kinzler <mathias.kinzler@sap.com> | 2010-12-10 09:44:51 +0100 |
commit | 9b039b42e0ecf69640c5f1a34ee72a86dba3f1c2 (patch) | |
tree | 58eeb7353f0339158f89cb85f770d3ab4e47baa6 /org.eclipse.jgit | |
parent | 93a7b2b24d5486b2033ba4b692906c6c758f46ad (diff) | |
download | jgit-9b039b42e0ecf69640c5f1a34ee72a86dba3f1c2.tar.gz jgit-9b039b42e0ecf69640c5f1a34ee72a86dba3f1c2.zip |
Rebase: abort on unknown/unsupported command in git-rebase-todo
This is needed to ensure interoperability with the command line: if
the git-rebase-todo file was created manually (by git rebase -i in the
command line), and any commands other than pick are used (reword,
edit, fixup, squash) JGit must abort as it does not understand these
commands yet.
The same is true if an unknown command is found (e.g. due to a typo);
this is the same behavior as shown by the command line.
Change-Id: I2322014f69460361f7fc09da223e8a5c31f100dd
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java | 14 |
1 files changed, 11 insertions, 3 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 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)); } } |