diff options
author | Robin Stocker <robin@nibor.org> | 2014-11-30 21:20:26 +1100 |
---|---|---|
committer | Christian Halstrick <christian.halstrick@sap.com> | 2014-12-10 12:56:10 +0100 |
commit | 47927ac95ee7ddc09a29f55af5eee51f139dd60a (patch) | |
tree | aa559ed97aadc830226255d699ac5970c7a52494 /org.eclipse.jgit | |
parent | c9a5fdb3cd92d5774aa7041b9fc9fc579dc26edc (diff) | |
download | jgit-47927ac95ee7ddc09a29f55af5eee51f139dd60a.tar.gz jgit-47927ac95ee7ddc09a29f55af5eee51f139dd60a.zip |
CheckoutCommand: Fix checking out ours/theirs when no base stage exists
In case of an add/add conflict, no base stage exists. The previous
implementation would skip over the entries because the condition
expected the base stage to always exist.
Change-Id: Ie2b3685d958c09b241991b74e6177401e8a1ebc9
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/CheckoutCommand.java | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutCommand.java index 1820932286..3787ac5117 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutCommand.java @@ -405,14 +405,17 @@ public class CheckoutCommand extends GitCommand<Ref> { DirCacheIterator dci = new DirCacheIterator(dc); treeWalk.addTree(dci); + String previousPath = null; + final ObjectReader r = treeWalk.getObjectReader(); DirCacheEditor editor = dc.editor(); while (treeWalk.next()) { - DirCacheEntry entry = dci.getDirCacheEntry(); + String path = treeWalk.getPathString(); // Only add one edit per path - if (entry != null && entry.getStage() > DirCacheEntry.STAGE_1) + if (path.equals(previousPath)) continue; - editor.add(new PathEdit(treeWalk.getPathString()) { + + editor.add(new PathEdit(path) { public void apply(DirCacheEntry ent) { int stage = ent.getStage(); if (stage > DirCacheEntry.STAGE_0) { @@ -429,6 +432,8 @@ public class CheckoutCommand extends GitCommand<Ref> { } } }); + + previousPath = path; } editor.commit(); } |