]> source.dussan.org Git - jgit.git/commitdiff
RebaseCommand should ignore submodule modifications 26/35126/3
authorChristian Halstrick <christian.halstrick@sap.com>
Fri, 17 Oct 2014 08:05:32 +0000 (10:05 +0200)
committerStefan Lay <stefan.lay@sap.com>
Mon, 3 Nov 2014 09:32:54 +0000 (04:32 -0500)
Before a rebase happens the RebaseCommand checks that the working tree
is clean. We don't want to start a rebase on a dirty working tree. If
the working tree is dirty a rebase should not be allowed. But
RebaseCommand should ignore modifications done to submodules. E.g. if a
submodules HEAD points to <x> but the root repository has in index that
the submodule should point to <y> then this should not prohibit a
rebase. Also native git allows a rebase in this case. Since jgit's
StatusCommand has learned to ignore submodule changes this is now used
by the RebaseCommand to determine the repository state correctly.

Bug: 446922
Change-Id: I487bf7484dca3f5501e6e514584e2871524eea19

org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java

index 7cc682e6b5b7a6744a67becfaa5a2124cab4a1d7..47424a90749d67fedfc23806c22d03481c69b9b3 100644 (file)
@@ -99,6 +99,7 @@ import org.eclipse.jgit.merge.MergeStrategy;
 import org.eclipse.jgit.revwalk.RevCommit;
 import org.eclipse.jgit.revwalk.RevWalk;
 import org.eclipse.jgit.revwalk.filter.RevFilter;
+import org.eclipse.jgit.submodule.SubmoduleWalk.IgnoreSubmoduleMode;
 import org.eclipse.jgit.treewalk.TreeWalk;
 import org.eclipse.jgit.treewalk.filter.TreeFilter;
 import org.eclipse.jgit.util.FileUtils;
@@ -294,7 +295,7 @@ public class RebaseCommand extends GitCommand<RebaseResult> {
                                                                walk.parseCommit(repo.resolve(Constants.HEAD)),
                                                                upstreamCommit)) {
                                        org.eclipse.jgit.api.Status status = Git.wrap(repo)
-                                                       .status().call();
+                                                       .status().setIgnoreSubmodules(IgnoreSubmoduleMode.ALL).call();
                                        if (status.hasUncommittedChanges()) {
                                                List<String> list = new ArrayList<String>();
                                                list.addAll(status.getUncommittedChanges());