]> source.dussan.org Git - jgit.git/commitdiff
Fix parsing Rebase todo lines when commit message is missing 69/18669/1
authorStefan Lay <stefan.lay@sap.com>
Thu, 21 Nov 2013 13:46:12 +0000 (14:46 +0100)
committerStefan Lay <stefan.lay@sap.com>
Thu, 21 Nov 2013 13:47:24 +0000 (14:47 +0100)
Bug: 422253
Change-Id: I9739b16c91d2df31a481360a712d3479a4eeee2e
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java
org.eclipse.jgit/src/org/eclipse/jgit/lib/RebaseTodoFile.java

index 241d099d197961f618f7fa78afb15eca0d035658..a3d652b73785d5cf04b8a3bb4c7eddc04fe0ca60 100644 (file)
@@ -1641,6 +1641,19 @@ public class RebaseCommandTest extends RepositoryTestCase {
                assertEquals("2222222", steps.get(1).getCommit().name());
        }
 
+       @Test
+       public void testRebaseShouldBeAbleToHandleLinesWithoutCommitMessageInRebaseTodoFile()
+                       throws IOException {
+               String todo = "pick 1111111 \n" + "pick 2222222 Commit 2\n"
+                               + "# Comment line at end\n";
+               write(getTodoFile(), todo);
+
+               List<RebaseTodoLine> steps = db.readRebaseTodo(GIT_REBASE_TODO, false);
+               assertEquals(2, steps.size());
+               assertEquals("1111111", steps.get(0).getCommit().name());
+               assertEquals("2222222", steps.get(1).getCommit().name());
+       }
+
        @Test
        public void testRebaseShouldNotFailIfUserAddCommentLinesInPrepareSteps()
                        throws Exception {
index cac67e11e939b20ba5ee22da84ec1c63cd414684..ef61e220323ff83baeab72b7fdb3416504f1bcbb 100644 (file)
@@ -197,6 +197,8 @@ public class RebaseTodoFile {
                        }
                        tokenCount++;
                }
+               if (tokenCount == 2)
+                       return new RebaseTodoLine(action, commit, ""); //$NON-NLS-1$
                return null;
        }