Browse Source

TreeWalk: Make getEolStreamType(OperationType) public

and deprecate getEolStreamType().

This resolves a TODO that was apparently supposed to be done in
version 4.4.

Change-Id: I5c9861aedabdc3f99dcf47519b3959a979e6a591
stable-4.10
David Pursehouse 7 years ago
parent
commit
6ec5d8ddb1
  1. 8
      org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutCommand.java
  2. 5
      org.eclipse.jgit/src/org/eclipse/jgit/api/StashApplyCommand.java
  3. 5
      org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java
  4. 10
      org.eclipse.jgit/src/org/eclipse/jgit/treewalk/TreeWalk.java
  5. 6
      org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java

8
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<Ref> {
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<Ref> {
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();

5
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<ObjectId> {
// 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());

5
org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java vendored

@ -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);

10
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));
}

6
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:

Loading…
Cancel
Save