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 6b20da3ed..db59a9bff 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutCommand.java @@ -43,6 +43,8 @@ */ package org.eclipse.jgit.api; +import static org.eclipse.jgit.treewalk.TreeWalk.OperationType.CHECKOUT_OP; + import java.io.IOException; import java.text.MessageFormat; import java.util.ArrayList; @@ -468,7 +470,8 @@ public class CheckoutCommand extends GitCommand { if (path.equals(previousPath)) continue; - final EolStreamType eolStreamType = treeWalk.getEolStreamType(); + final EolStreamType eolStreamType = treeWalk + .getEolStreamType(CHECKOUT_OP); final String filterCommand = treeWalk .getFilterCommand(Constants.ATTR_FILTER_TYPE_SMUDGE); editor.add(new PathEdit(path) { @@ -508,7 +511,8 @@ public class CheckoutCommand extends GitCommand { while (treeWalk.next()) { final ObjectId blobId = treeWalk.getObjectId(0); final FileMode mode = treeWalk.getFileMode(0); - final EolStreamType eolStreamType = treeWalk.getEolStreamType(); + final EolStreamType eolStreamType = treeWalk + .getEolStreamType(CHECKOUT_OP); final String filterCommand = treeWalk .getFilterCommand(Constants.ATTR_FILTER_TYPE_SMUDGE); final String path = treeWalk.getPathString(); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/StashApplyCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/StashApplyCommand.java index b56fb2519..08fde70ed 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/StashApplyCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/StashApplyCommand.java @@ -42,6 +42,8 @@ */ package org.eclipse.jgit.api; +import static org.eclipse.jgit.treewalk.TreeWalk.OperationType.CHECKOUT_OP; + import java.io.IOException; import java.text.MessageFormat; import java.util.HashSet; @@ -355,7 +357,8 @@ public class StashApplyCommand extends GitCommand { // Not in commit, don't create untracked continue; - final EolStreamType eolStreamType = walk.getEolStreamType(); + final EolStreamType eolStreamType = walk + .getEolStreamType(CHECKOUT_OP); final DirCacheEntry entry = new DirCacheEntry(walk.getRawPath()); entry.setFileMode(cIter.getEntryFileMode()); entry.setObjectIdFromRaw(cIter.idBuffer(), cIter.idOffset()); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java index f8c23ca64..d30f6e45b 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java @@ -42,6 +42,8 @@ package org.eclipse.jgit.dircache; +import static org.eclipse.jgit.treewalk.TreeWalk.OperationType.CHECKOUT_OP; + import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -1148,7 +1150,8 @@ public class DirCacheCheckout { private void update(String path, ObjectId mId, FileMode mode) throws IOException { if (!FileMode.TREE.equals(mode)) { - updated.put(path, new CheckoutMetadata(walk.getEolStreamType(), + updated.put(path, new CheckoutMetadata( + walk.getEolStreamType(CHECKOUT_OP), walk.getFilterCommand(Constants.ATTR_FILTER_TYPE_SMUDGE))); DirCacheEntry entry = new DirCacheEntry(path, DirCacheEntry.STAGE_0); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/TreeWalk.java b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/TreeWalk.java index e063749a2..77cb67aa4 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/TreeWalk.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/TreeWalk.java @@ -592,13 +592,14 @@ public class TreeWalk implements AutoCloseable, AttributesProvider { * @return the EOL stream type of the current entry using the config and * {@link #getAttributes()} Note that this method may return null if * the {@link TreeWalk} is not based on a working tree + * @since 4.10 */ - // TODO(msohn) make this method public in 4.4 @Nullable - EolStreamType getEolStreamType(OperationType opType) { + public EolStreamType getEolStreamType(OperationType opType) { if (attributesNodeProvider == null || config == null) return null; - return EolStreamTypeUtil.detectStreamType(opType, + return EolStreamTypeUtil.detectStreamType( + opType != null ? opType : operationType, config.get(WorkingTreeOptions.KEY), getAttributes()); } @@ -607,8 +608,9 @@ public class TreeWalk implements AutoCloseable, AttributesProvider { * {@link #getAttributes()} Note that this method may return null if * the {@link TreeWalk} is not based on a working tree * @since 4.3 + * @deprecated use {@link #getEolStreamType(OperationType)} instead. */ - // TODO(msohn) deprecate this method in 4.4 + @Deprecated public @Nullable EolStreamType getEolStreamType() { return (getEolStreamType(operationType)); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java index b1b146c85..b2628b49e 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java @@ -1394,11 +1394,7 @@ public abstract class WorkingTreeIterator extends AbstractTreeIterator { if (eolStreamTypeHolder == null) { EolStreamType type=null; if (state.walk != null) { - if (opType != null) { - type = state.walk.getEolStreamType(opType); - } else { - type=state.walk.getEolStreamType(); - } + type = state.walk.getEolStreamType(opType); } else { switch (getOptions().getAutoCRLF()) { case FALSE: