diff options
author | Robin Stocker <robin@nibor.org> | 2012-06-04 15:35:16 +0200 |
---|---|---|
committer | Robin Stocker <robin@nibor.org> | 2012-06-23 16:38:54 +0200 |
commit | 14ff22fd74e1720e9d8988c9d58653dd177f6fb6 (patch) | |
tree | 2380d7d4e66467ec62eb2b88dfb7a272cf63c886 /org.eclipse.jgit | |
parent | 3c29bf094111308da2cea79fc36af1eff2f4da7a (diff) | |
download | jgit-14ff22fd74e1720e9d8988c9d58653dd177f6fb6.tar.gz jgit-14ff22fd74e1720e9d8988c9d58653dd177f6fb6.zip |
Ignore empty lines when parsing git-rebase-todo
When starting a rebase with C Git, there may be empty lines in the
git-rebase-todo file. Before this change, JGit would fail to parse the
file with e.g. the following exception:
JGitInternalException: Unknown or unsupported command "
#", only "pick" is allowed.
This happened when there was an empty line just before the comments,
because the nextSpace would be the one from the comment. Now the empty
lines are ignored by checking for nextSpace < ptr outside of the loop.
Change-Id: I94ad299f367c846e7729c74f49c6b8f93f75ae81
Signed-off-by: Robin Stocker <robin@nibor.org>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java | 5 |
1 files changed, 2 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 645c9ff1fc..374db4c9ac 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java @@ -824,7 +824,7 @@ public class RebaseCommand extends GitCommand<RebaseResult> { return true; } - private List<Step> loadSteps() throws IOException { + List<Step> loadSteps() throws IOException { byte[] buf = IO.readFully(new File(rebaseDir, GIT_REBASE_TODO)); int ptr = 0; int tokenBegin = 0; @@ -832,13 +832,12 @@ public class RebaseCommand extends GitCommand<RebaseResult> { while (ptr < buf.length) { tokenBegin = ptr; ptr = RawParseUtils.nextLF(buf, ptr); - int nextSpace = 0; + int nextSpace = RawParseUtils.next(buf, tokenBegin, ' '); int tokenCount = 0; Step current = null; while (tokenCount < 3 && nextSpace < ptr) { switch (tokenCount) { case 0: - nextSpace = RawParseUtils.next(buf, tokenBegin, ' '); String actionToken = new String(buf, tokenBegin, nextSpace - tokenBegin - 1); tokenBegin = nextSpace; |