From a2e691351f4c5217a908410c1bd796efa6b01023 Mon Sep 17 00:00:00 2001 From: Robin Stocker Date: Sun, 23 Sep 2012 01:37:09 +0200 Subject: DirCacheEditor: Apply PathEdit for each stage This behavior was defined in the Javadoc of PathEdit, but not actually implemented. It's necessary when one wants to use a PathEdit to check out a specific stage in apply. Bug: 390147 Change-Id: Iaed5cf60c554fc17e6c4d188caf4f0231da920d0 Signed-off-by: Chris Aniszczyk --- .../src/org/eclipse/jgit/dircache/DirCacheEditor.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'org.eclipse.jgit/src/org/eclipse') diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEditor.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEditor.java index 6c12c402b6..b0cb34c352 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEditor.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEditor.java @@ -146,18 +146,21 @@ public class DirCacheEditor extends BaseDirCacheEditor { continue; } - final DirCacheEntry ent; if (missing) { - ent = new DirCacheEntry(e.path); + final DirCacheEntry ent = new DirCacheEntry(e.path); e.apply(ent); if (ent.getRawMode() == 0) throw new IllegalArgumentException(MessageFormat.format(JGitText.get().fileModeNotSetForPath , ent.getPathString())); + fastAdd(ent); } else { - ent = cache.getEntry(eIdx); - e.apply(ent); + // Apply to all entries of the current path (different stages) + for (int i = eIdx; i < lastIdx; i++) { + final DirCacheEntry ent = cache.getEntry(i); + e.apply(ent); + fastAdd(ent); + } } - fastAdd(ent); } final int cnt = maxIdx - lastIdx; -- cgit v1.2.3