aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java
Commit message (Collapse)AuthorAgeFilesLines
* Deprecate Repository#getReflogReader methodsMatthias Sohn2025-01-271-21/+28
| | | | | | instead use Repository.getRefDatabase().getReflogReader(). Change-Id: I5e66a512c12e11d0ec3275fffde4adb8483430f2
* RebaseCommandTest: replace deprecated PersonIdent constructorMatthias Sohn2024-12-291-6/+11
| | | | Change-Id: Ib5e367c88662defc0471a0487a576bb4b750b778
* [errorprone] Fix pattern CatchFailMatthias Sohn2024-04-291-1/+3
| | | | | | See https://errorprone.info/bugpattern/CatchFail Change-Id: If1c637a420c4e669a5bdbe4abcefc5c3a2b3a43b
* RebaseCommand: fix stopping on root commit conflictsThomas Wolf2024-01-281-0/+34
| | | | | | | | | If rebasing runs into a conflict when applying a root commit from an independent branch, there is no parent commit. Write an empty patch file in that case like C git does. Bug: jgit-6 Change-Id: I315313673d2abf29639d7d96c958d599961ba276 Signed-off-by: Thomas Wolf <twolf@apache.org>
* RebaseCommand: return correct status on stash apply conflictsThomas Wolf2023-10-131-1/+52
| | | | | | | | Ensure that also the fast-forward cases return status STASH_APPLY_CONFLICTS when applying the stash produces conflicts. Bug: 582526 Change-Id: Ib989ff431dca6e301eb05156ca054a7115fa6ad5 Signed-off-by: Thomas Wolf <twolf@apache.org>
* Support rebasing independent branchesThomas Wolf2023-04-291-0/+141
| | | | | | | | | With completely independent branches, there is no merge base. In this case, the list of commits must include the root commit of the branch to be rebased. Bug: 581832 Change-Id: I0f5bdf179d5b07ff09f1a274d61c7a0b1c0011c6 Signed-off-by: Thomas Wolf <twolf@apache.org>
* Use git config core.commentCharThomas Wolf2022-03-261-0/+96
| | | | | | | | | | | | | This concerns committing, creating merge conflict messages and creating and editing squash messages. In a squash message, once the comment character has been determined initially is always the first character. Note that if core.commentChar=auto and there is a sequence of squashes, it may be necessary to change the comment character when a new message is added. Bug: 579325 Change-Id: Idca19284a0240cd322e7512ea299a03658e1b2c1 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* RebaseCommand: fix commit message in "fixup" caseThomas Wolf2022-02-021-6/+28
| | | | | | | | | | | | | | | | | | | JGit accumulated in MESSAGE_FIXUP commit messages of a fixup sequence, just like it did in MESSAGE_SQUASH, and on the last step of a sequence of fixups used that file, after stripping all comment lines, as the commit message. That also stripped any lines from the original commit message that happened to start with the comment character. This is not how this is supposed to work. MESSAGE_FIXUP must contain the original commit message of the base commit that is amended, and the file contains the verbatim commit message for the final fixup.[1] Change the implementation accordingly, and add new tests. [1] https://github.com/git/git/blob/df3c41adeb/sequencer.c#L86 ff. Bug: 513726 Change-Id: I885a2b7f10d6c74460a8693aa6cbf867ee0494a1 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* Revert "RevWalk: stop mixing lines of history in topo sort"Alex Spradlin2020-02-261-2/+2
| | | | | | | | | | | | This reverts commit b5e764abd21bd4593287361a625ecc49bc0efd77. PlotWalk uses the TopoSortGenerator, which is causing problems for EGit users who rely on the emission of commits being somewhat based on date as in the previous topo-sort algorithm. Bug: 560529 Change-Id: I3dbd3598a7aeb960de3fc39352699b4f11a8c226 Signed-off-by: Alex Spradlin <alexaspradlin@google.com>
* RevWalk: stop mixing lines of history in topo sortAlex Spradlin2020-02-181-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The topological sort algorithm in TopoSortGenerator for RevWalk may mix multiple lines of history, producing results that differ from C git's git log whose man page states: "Show no parents before all of its children are shown, and avoid showing commits on multiple lines of history intermixed." Lines of history are mixed because TopoSortGenerator merely delays a commit until all of its children have been produced; it does not immediately produce a commit after its last child has been produced. Therefore, when the last child of a commit has been produced, unpop the commit so that it will be returned upon the subsequent call to next() in TopoSortGenerator. To avoid producing duplicates, mark commits that have not yet been produced as TOPO_QUEUED so that when a commit is popped, it is produced if and only if TOPO_QUEUED is set. To support nesting with other generators that may produce the same commit multiple times like DepthGenerator (for example, StartGenerator does this), do not increment parent inDegree for the same child commit more than once. Modify tests that assert that TopoSortGenerator mixes lines of commit history. Change-Id: I4ee03c7a8e5265d61230b2a01ae3858745b2432b Signed-off-by: Alex Spradlin <alexaspradlin@google.com>
* Update EDL 1.0 license headers to new short SPDX compliant formatMatthias Sohn2020-01-041-38/+5
| | | | | | | | | | This is the format given by the Eclipse legal doc generator [1]. [1] https://www.eclipse.org/projects/tools/documentation.php?id=technology.jgit Bug: 548298 Change-Id: I8d8cabc998ba1b083e3f0906a8d558d391ffb6c4 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* WorkingTreeModifiedEvent: must be fired explicitly after mergeThomas Wolf2019-11-031-9/+5
| | | | | | | | | | | | A merge may write files to the working tree. After a successful merge one must fire a WorkingTreeModifiedEvent explicitly if getModifiedFiles() is not empty. Also, any touched files must be reported by the WorkingTreeModifiedEvent fired by DirCacheCheckout.checkout(). Bug: 552636 Change-Id: I5fab8279ed8be8a4ae34cddfa726836b9277aea6 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* Close RevWalks in testsThomas Wolf2019-10-161-4/+6
| | | | Change-Id: Id28804ace2572e8f659271660e78454a0d6ccc49 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* Deprecate Constants.CHARSET in favor of StandardCharsets.UTF_8David Pursehouse2018-09-041-4/+4
| | | | | Change-Id: I3b748620f067582afef20f144feebe40d0332be2 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* ResolveMerger: don't try needlessly to delete directoriesThomas Wolf2018-07-191-0/+60
| | | | | | | | | | | | | | | | | | Don't try to delete folders if the merger chooses THEIRS, but all of BASE, OURS, and THEIRS contain the folder. Add a test for rebase with auto-stash and subdirectories that verifies this case. The needless directory deletion and reporting such directories in getModifiedFiles() was the root cause of bug 536880. Note even with this fix, bug 536880 will not be fixed in all cases yet. There may still be cases where the set of modified files ends up containing directories. This will be dealt with in EGit where this set is used. (See https://git.eclipse.org/r/#/c/126242/ .) Bug: 536880 Change-Id: I62b4571a1c1d4415934a6cb4270e0c8036deb2e9 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* Consistently use Constants.CHARSET rather than StandardCharsets.UTF_8David Pursehouse2018-03-111-4/+4
| | | | | Change-Id: I6714fc3666e1bced22abba94ceb700477349586e Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* Use StandardCharsets.UTF_8 in testsDavid Pursehouse2018-03-071-1/+1
| | | | | | | Replace hard-coded "UTF-8" string with the constant. Change-Id: Ie812add2df28e984090563ec7c6e2c0366616424 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* RebaseCommandTest: Open BufferedReader in try-with-resourceDavid Pursehouse2018-03-051-5/+2
| | | | | Change-Id: If8d77431edfdaec4a49a3c4ffe66a99e6d31c682 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* Use constants from StandardCharsets instead of hard-coded stringsDavid Pursehouse2017-12-071-2/+3
| | | | | | | | | | | | | | | | Instead of hard-coding the charset strings "US-ASCII", "UTF-8", and "ISO-8859-1", use the corresponding constants from StandardCharsets. UnsupportedEncodingException is not thrown when the StandardCharset constants are used, so remove the now redundant handling. Because the encoding names are no longer hard-coded strings, also remove redundant $NON-NLS warning suppressions. Also replace existing usages of the constants with static imports. Change-Id: I0a4510d3d992db5e277f009a41434276f95bda4e Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* Enable and fix 'Should be tagged with @Override' warningDavid Pursehouse2017-02-191-0/+40
| | | | | | | | | | | | | | | | | | | | | | | Set missingOverrideAnnotation=warning in Eclipse compiler preferences which enables the warning: The method <method> of type <type> should be tagged with @Override since it actually overrides a superclass method Justification for this warning is described in: http://stackoverflow.com/a/94411/381622 Enabling this causes in excess of 1000 warnings across the entire code-base. They are very easy to fix automatically with Eclipse's "Quick Fix" tool. Fix all of them except 2 which cause compilation failure when the project is built with mvn; add TODO comments on those for further investigation. Change-Id: I5772061041fd361fe93137fd8b0ad356e748a29c Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* RebaseCommandTest: Open RevWalk in try-with-resourceDavid Pursehouse2016-01-251-178/+200
| | | | | Change-Id: If7b7a90171d1349d634a84f135471ebac29e3210 Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
* Replace deprecated release() methods by close()Matthias Sohn2015-05-211-16/+15
| | | | | | | | See the discussion [1] in the Gerrit mailing list. [1] https://groups.google.com/forum/#!topic/repo-discuss/RRQT_xCqz4o Change-Id: I2c67384309c5c2e8511a7d0d4e088b4e95f819ff Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Make RepositoryState.REBASING_MERGE reachable again.Laurent Delaigue2015-03-271-5/+5
| | | | | | | | | | | If a non interactive rebase is launched, stopping after a conflict should set the repository state to RepositoryState.REBASING_MERGE instead of RepositoryState.REBASING_INTERACTIVE. Bug: 452623 Change-Id: Ie885aab6d71dabd158a718af0d14fff643c9b850 Also-by: Arthur Daussy <arthur.daussy@obeo.fr> Signed-off-by: Laurent Delaigue <laurent.delaigue@obeo.fr> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Rebase: Add --preserve-merges supportKonrad Kügler2014-07-151-0/+278
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With --preserve-merges C Git re-does merges using the rewritten merge parents, discarding the old merge commit. For the common use-case of pull with rebase this is unfortunate, as it loses the merge conflict resolution (and other fixes in the merge), which may have taken quite some time to get right in the first place. To overcome this we use a two-fold approach: If any of the (non-first) merge parents of a merge were rewritten, we also redo the merge, to include the (potential) new changes in those commits. If only the first parent was rewritten, i.e. we are merging a branch that is otherwise unaffected by the rebase, we instead cherry-pick the merge commit at hand. This is done with the --mainline 1 and --no-commit options to apply the changes introduced by the merge. Then we set up an appropriate MERGE_HEAD and commit the result, thus effectively forging a merge. Apart from the approach taken to rebase merge commits, this implementation closely follows C Git. As a result, both Git implementations can continue rebases of each other. Preserving merges works for both interactive and non-interactive rebase, but as in C Git it is easy do get undesired outcomes with interactive rebase. CommitCommand supports committing merges during rebase now. Bug: 439421 Change-Id: I4cf69b9d4ec6109d130ab8e3f42fcbdac25a13b2 Signed-off-by: Konrad Kügler <swamblumat-eclipsebugs@yahoo.de>
* Interactive rebase: Fix order of commit messages on squashStefan Lay2014-03-271-5/+5
| | | | | | | Bug: 431214 Change-Id: I295bfdc5751545b046d7fe7efc3f8b39ab4f5415 Signed-off-by: Stefan Lay <stefan.lay@sap.com> Signed-off-by: Robin Rosennberg <robin.rosenberg@dewire.com>
* Fix fast forward rebase with rebase.autostash=trueStefan Lay2014-01-151-0/+39
| | | | | | | | | The folder .git/rebase-merge was not removed in this case. The repository was then still in rebase state, but neither abort nor continue worked. Bug: 425742 Change-Id: I43cea6c9e5f3cef9d6b15643722fddecb40632d9
* Don't use API exception in RebaseTodoLineChristian Halstrick2013-12-111-36/+114
| | | | | | | | | | | | | This came up while testing the proposed buck build for jgit. With buck we can introduce smaller modules to allow for more concurrency during build and to better control inner structure of jgit. Trying to put the porcelain API into a different module than lower level implementation classes failed since RebaseTodoLine used a porcelain API exception causing a dependency cycle on the proposed modules. Using an exception defined on the same abstraction level fixes this problem. Change-Id: I26a5353e1a8fc23e67d8ce61309bd964f7665bcb Signed-off-by: Matthias Sohn <matthias.sohn@sap.com> Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
* Fix aborting rebase with detached headStefan Lay2013-12-101-0/+63
| | | | | Bug: 423670 Change-Id: Ia6052867f85d4974c4f60ee5a6c820501e8d2427
* Implement rebase.autostashStefan Lay2013-12-041-0/+137
| | | | | | | This feature was introduced in native git with version 1.8.4. Bug: 422951 Change-Id: I42f194174d64d7ada6631e2156c2a7bf93b5e91c Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Do not allow non-ff-rebase if there are uncommitted changesStefan Lay2013-12-021-28/+152
| | | | | | | | | | | | | With this change jgit checks for uncommitted changes before a rebase is started. This is also done by native git. One reason is that an abort would override such changes. The check is skipped for a non-interactive rebase when it will result in a fast-forward. In this case there can be only checkout conflicts but no merge conflicts, so there cannot be an abort which overrides uncommitted changes. Bug: 422352 Change-Id: I1e0b59b2a4d80a686b67a6729e441924362b1236 Signed-off-by: Stefan Lay <stefan.lay@sap.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Fix FIXUP error for blank lines in interactive rebaseStefan Lay2013-11-221-0/+38
| | | | | | | | Empty lines of discarded commit messages were added to the commit message because they were not commented out properly. Bug: 422246 Change-Id: I263e8a6b30a3392d8b4f09c0695505068a0a485d Signed-off-by: Stefan Lay <stefan.lay@sap.com>
* Fix parsing Rebase todo lines when commit message is missingStefan Lay2013-11-211-0/+13
| | | | | Bug: 422253 Change-Id: I9739b16c91d2df31a481360a712d3479a4eeee2e Signed-off-by: Stefan Lay <stefan.lay@sap.com>
* Interactive Rebase: Do actions if there were conflictsStefan Lay2013-11-081-0/+207
| | | | | | | | | If a commit was marked for edit, reword, squash or fixup, but the interactive rebase stopped because of a conflict, the step was not done after conflict resolution. This is done now. Change-Id: If8e7ccc50469165744f2b8a53d180f9ba0f72330 Signed-off-by: Stefan Lay <stefan.lay@sap.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Rebase interactive should finish if last step is editStefan Lay2013-11-061-0/+33
| | | | | | | | When the last step was an edit step, rebase interactive did not finish after continuing the rebase. Instead, it returned with the status FAST_FORWARD. Change-Id: Ib19857474ac089dfeaae665ad5e95c66c21099b0
* Add additional RebaseResult for editing commitsStefan Lay2013-11-051-1/+1
| | | | | | | | | With the new RebaseResult.EDIT a client can now distinguish if rebase stopped due to a conflict or because the commit was marked for edit in an interactive rebase. Change-Id: I40f2311cf43ed5f290dcda65a7bd85ba770a85f5 Signed-off-by: Stefan Lay <stefan.lay@sap.com>
* Add Squash/Fixup support for rebase interactive in RebaseCommandTobias Pfeifer2013-11-051-1/+338
| | | | | | | | | | | | | | | | The rebase command now supports squash and fixup. Both actions are not allowed as the first step of the rebase. In JGit, before any rebase step is performed, the next commit is already cherry-picked. This commit keeps that behaviour. In case of squash or fixup a soft reset to the parent is perfomed afterwards. CQ: 7684 Bug: 396510 Change-Id: I3c4190940b4d7f19860e223d647fc78705e57203 Signed-off-by: Tobias Pfeifer <to.pfeifer@web.de> Signed-off-by: Stefan Lay <stefan.lay@sap.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Parse commitId and shortMessage of a commented out line in rebase todoTobias Pfeifer2013-10-311-0/+119
| | | | | | | | | | | | | A rebase todo file consists of regular non-comment action lines and comment lines. In case that a regular action line has been commented out (i.e. prefixed with a hash '#'), the RebaseTodoLine that is representing this line should hold the values for commitId and shortMessage even though it's a comment line. This allows to switch between comment and non-comment easily even after the file has been persisted and reread. Change-Id: I56ec2ba08eaf3772e2d74d937dd496209a744d4b Signed-off-by: Tobias Pfeifer <to.pfeifer@web.de> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Enhance reading of git-rebase-todo formatted filesChristian Halstrick2013-10-311-25/+122
| | | | | | | | | | | | | | | | | | | | Reading and writing files formatted like the git-rebase-todo files was hidden in the RebaseCommand. Certain constructs (like leading tabs and spaces) have not been handled as in native git. Also the upcoming rebase interactive feature in EGit needs reading/writing these files independently from a RebaseCommand. Therefore reading and writing those files has been moved to the Repository class. RebaseCommand gets smaller because of that and doesn't have to deal with reading/writing files. Additional tests for empty todo-list files, or files containing comments have been added. Change-Id: I323f3619952fecdf28ddf50139a88e0bea34f5ba Signed-off-by: Christian Halstrick <christian.halstrick@sap.com> Also-by: Tobias Pfeifer <to.pfeifer@sap.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Update reflog like C Git during rebase (non-interactive)Robin Rosenberg2013-07-211-2/+90
| | | | | | Bug: 346350 Change-Id: I119766a00bc52a810c51cffaa19207cb8555ca22 Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
* Make JGit test work with both hamcrest 1.1 (juno) and 1.3 (kepler)Robin Rosenberg2013-06-091-2/+2
| | | | | | | The hamcrest library has moved things around. This problem applies only to the test, not plugin runtime. Change-Id: I5b97f356d8595dbdc9e91d157558e40561a6a30d Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Support aborting non-interactive rebase started from C GitRobin Stocker2013-03-161-1/+23
| | | | | | | | | Continuing is trickier, as .git/rebase-apply contains no message file and no git-rebase-todo. Bug: 336820 Change-Id: I4eb87c850078ca187b38b81cc91c92afb1176945 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Do not cherry-pick merge commits during rebaseRobin Rosenberg2013-03-081-32/+51
| | | | | | | | | | | Rebase computes the list of commits that are included in the merges, just like Git does, so do not try to include the merge commits. Re-recreating merges during rebase is a bit more complicated and might be a useful future extension, but for now just linearize during rebase. Change-Id: I61239d265f395e5ead580df2528e46393dc6bdbd Signed-off-by: Robin Stocker <robin@nibor.org>
* Move base test classes to the junit bundle for reuse for Java 7 testsRobin Rosenberg2013-02-041-1/+1
| | | | Change-Id: Iedb54eb9d8396bc3ae66d8754c1527fd9ca655f9
* Improve handling of checkout conflictsMarkus Duft2013-01-111-48/+26
| | | | | | | This converts a checkout conflict exception into a RebaseResult / MergeResult containing the conflicting paths, which enables EGit (or others) to handle the situation in a user-friendly way Change-Id: I48d9bdcc1e98095576513a54a225a42409f301f3
* Add support for rebase interactive 'edit' commandDariusz Luksza2012-11-191-0/+52
| | | | | | | | | | The 'edit' command allows you to change arbitrary commit content and the message of any commit in the repository. Bug: 394577 Change-Id: I43a44782cdb10b29f13784fa75ab37fe5d4da01b Signed-off-by: Dariusz Luksza <dariusz@luksza.org> Signed-off-by: Chris Aniszczyk <zx@twitter.com>
* Add support for rebase interactive 'reword' commandDariusz Luksza2012-11-191-0/+58
| | | | | | | | | | 'reword' command is used to change commit message of any commit in git history. Bug: 394575 Change-Id: Ic974e76dfd923fd6f0cb8f07d1a6fbecd9abbf31 Signed-off-by: Dariusz Luksza <dariusz@luksza.org> Signed-off-by: Chris Aniszczyk <zx@twitter.com>
* DirCacheCheckout: Fix handling of files not in indexRobin Stocker2012-09-011-0/+32
| | | | | | | | | | | | | | | | | | | | | | When a file is not in the index and neither contents nor mode differ between "head" and "merge", the index state should be kept. If they differ, a checkout conflict should occur. This is described in Git's git-read-tree.txt. JGit used to replace the index state with "merge" in both of the above cases. A confusing effect of this was that when one removed a file and then did a rebase, the file silently reappeared again. The changes to dir/file conflict handling are a consequence of this change, as the index handling change made tests in DirCacheCheckoutTest break. I compared these cases to C Git and the new behavior there also matches what C Git does. Bug: 387390 Change-Id: I5beb781f12172a68f98c67d4c8029eb51ceae62d Signed-off-by: Robin Stocker <robin@nibor.org>
* Improve ours/theirs conflict markers for rebase, cherry-pickRobin Stocker2012-08-181-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On conflicts in rebase or cherry-pick, the conflict markers were like this: <<<<<<< OURS a ======= b >>>>>>> THEIRS This is technically correct, but it could be better. It's especially confusing during a rebase, where the meaning of OURS/THEIRS is not obvious. The intuition is that "ours" is the commits that "I" did before the rebase, but it's the other way around because of the way rebase works. See various bug reports and stackoverflow discussions. With this change, in the case of a cherry-pick while on master, the markers will be like this: <<<<<<< master a ======= b >>>>>>> bad1dea Message of the commit I'm cherry-picking In the case of a "git rebase master": <<<<<<< Upstream, based on master a ======= b >>>>>>> b161dea Message of a commit I'm rebasing It's not "master" because that would only be correct for the first cherry-pick during a rebase, after that, it's master + already cherry-picked commits. And in the case of a "git pull --rebase": <<<<<<< Upstream, based on branch 'master' of git@example.org:repo a ======= b >>>>>>> b161dea Message of a commit I'm rebasing Bug: 336819 Change-Id: I1333a8dd170bb0077f491962013485efb6f2a926 Signed-off-by: Robin Stocker <robin@nibor.org> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Allow JGit to read C Git rebase stateRobin Rosenberg2012-08-071-2/+2
| | | | | | C Git prefixes the time stamp in the author script with a "@" Change-Id: I140b29519acc101da78296eef562368fc6b61135
* Ignore empty lines when parsing git-rebase-todoRobin Stocker2012-06-231-2/+25
| | | | | | | | | | | | | | | | 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>