diff options
author | Christian Halstrick <christian.halstrick@sap.com> | 2014-12-12 04:54:46 -0500 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org <gerrit@eclipse.org> | 2014-12-12 04:54:46 -0500 |
commit | 80b1da1aae418fbfefd99fb88c3588d64e04680b (patch) | |
tree | 31d0bf73d82491da4bf7b87cc679f7bf5b12f4fd /org.eclipse.jgit | |
parent | 1b9130e8dbc5c5703ef5f03ade5106d83a105ba2 (diff) | |
parent | 47927ac95ee7ddc09a29f55af5eee51f139dd60a (diff) | |
download | jgit-80b1da1aae418fbfefd99fb88c3588d64e04680b.tar.gz jgit-80b1da1aae418fbfefd99fb88c3588d64e04680b.zip |
Merge "CheckoutCommand: Fix checking out ours/theirs when no base stage exists" into stable-3.6
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(); } |