summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2016-06-14 00:11:37 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2016-06-14 00:11:37 +0200
commit48cb5ffba6d2b11aea407cdd93e5a8ffb7bfec17 (patch)
treeed55d9ec704f92778591a1ccf8a2dd6983c61e3f /org.eclipse.jgit
parenta418c2eb4d6caf778973557b042f50fb5729df61 (diff)
parent0900dc08f59de482b38862094936e80fca39df2a (diff)
downloadjgit-48cb5ffba6d2b11aea407cdd93e5a8ffb7bfec17.tar.gz
jgit-48cb5ffba6d2b11aea407cdd93e5a8ffb7bfec17.zip
Merge branch 'stable-4.4'
* stable-4.4: Prepare 4.4.1-SNAPSHOT builds JGit v4.4.0.201606070830-r Prepare 4.4.0-SNAPSHOT builds JGit v4.4.0.201606011500-rc2 Prepare 4.4.0-SNAPSHOT builds JGit v4.4.0.201605250940-rc1 Update Orbit repository for Neon to R20160520211859 Fix computation of id in WorkingTreeIterator with autocrlf and smudging Prepare 4.3.2-SNAPSHOT builds JGit v4.3.1.201605051710-r Prepare 4.4.0-SNAPSHOT builds JGit v4.4.0.201605041135-m1 Run Maven build in release.sh concurrently to speedup release Change-Id: I25ef0497a4455b8229b453e1023abb4631d4b6d3 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/treewalk/TreeWalk.java20
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java57
2 files changed, 63 insertions, 14 deletions
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 501d676735..7dac50a89a 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/TreeWalk.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/TreeWalk.java
@@ -580,18 +580,32 @@ public class TreeWalk implements AutoCloseable, AttributesProvider {
}
/**
+ * @param opType
+ * the operationtype (checkin/checkout) which should be used
* @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.3
*/
- public @Nullable EolStreamType getEolStreamType() {
+ // TODO(msohn) make this method public in 4.4
+ @Nullable
+ EolStreamType getEolStreamType(OperationType opType) {
if (attributesNodeProvider == null || config == null)
return null;
- return EolStreamTypeUtil.detectStreamType(operationType,
+ return EolStreamTypeUtil.detectStreamType(opType,
config.get(WorkingTreeOptions.KEY), getAttributes());
}
+ /**
+ * @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.3
+ */
+ // TODO(msohn) deprecate this method in 4.4
+ public @Nullable EolStreamType getEolStreamType() {
+ return (getEolStreamType(operationType));
+ }
+
/** Reset this walker so new tree iterators can be added to it. */
public void reset() {
attrs = null;
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 39176c621e..c8de3de83c 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java
@@ -86,6 +86,7 @@ import org.eclipse.jgit.lib.ObjectLoader;
import org.eclipse.jgit.lib.ObjectReader;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.submodule.SubmoduleWalk;
+import org.eclipse.jgit.treewalk.TreeWalk.OperationType;
import org.eclipse.jgit.util.FS;
import org.eclipse.jgit.util.FS.ExecutionResult;
import org.eclipse.jgit.util.Holder;
@@ -361,7 +362,8 @@ public abstract class WorkingTreeIterator extends AbstractTreeIterator {
state.initializeDigestAndReadBuffer();
final long len = e.getLength();
- InputStream filteredIs = possiblyFilteredInputStream(e, is, len);
+ InputStream filteredIs = possiblyFilteredInputStream(e, is, len,
+ OperationType.CHECKIN_OP);
return computeHash(filteredIs, canonLen);
} finally {
safeClose(is);
@@ -374,8 +376,15 @@ public abstract class WorkingTreeIterator extends AbstractTreeIterator {
private InputStream possiblyFilteredInputStream(final Entry e,
final InputStream is, final long len) throws IOException {
+ return possiblyFilteredInputStream(e, is, len, null);
+
+ }
+
+ private InputStream possiblyFilteredInputStream(final Entry e,
+ final InputStream is, final long len, OperationType opType)
+ throws IOException {
if (getCleanFilterCommand() == null
- && getEolStreamType() == EolStreamType.DIRECT) {
+ && getEolStreamType(opType) == EolStreamType.DIRECT) {
canonLen = len;
return is;
}
@@ -385,7 +394,7 @@ public abstract class WorkingTreeIterator extends AbstractTreeIterator {
byte[] raw = rawbuf.array();
int n = rawbuf.limit();
if (!isBinary(raw, n)) {
- rawbuf = filterClean(raw, n);
+ rawbuf = filterClean(raw, n, opType);
raw = rawbuf.array();
n = rawbuf.limit();
}
@@ -398,13 +407,14 @@ public abstract class WorkingTreeIterator extends AbstractTreeIterator {
return is;
}
- final InputStream lenIs = filterClean(e.openInputStream());
+ final InputStream lenIs = filterClean(e.openInputStream(),
+ opType);
try {
canonLen = computeLength(lenIs);
} finally {
safeClose(lenIs);
}
- return filterClean(is);
+ return filterClean(is, opType);
}
private static void safeClose(final InputStream in) {
@@ -430,17 +440,23 @@ public abstract class WorkingTreeIterator extends AbstractTreeIterator {
}
}
- private ByteBuffer filterClean(byte[] src, int n) throws IOException {
+ private ByteBuffer filterClean(byte[] src, int n, OperationType opType)
+ throws IOException {
InputStream in = new ByteArrayInputStream(src);
try {
- return IO.readWholeStream(filterClean(in), n);
+ return IO.readWholeStream(filterClean(in, opType), n);
} finally {
safeClose(in);
}
}
private InputStream filterClean(InputStream in) throws IOException {
- in = handleAutoCRLF(in);
+ return filterClean(in, null);
+ }
+
+ private InputStream filterClean(InputStream in, OperationType opType)
+ throws IOException {
+ in = handleAutoCRLF(in, opType);
String filterCommand = getCleanFilterCommand();
if (filterCommand != null) {
FS fs = repository.getFS();
@@ -469,8 +485,9 @@ public abstract class WorkingTreeIterator extends AbstractTreeIterator {
return in;
}
- private InputStream handleAutoCRLF(InputStream in) throws IOException {
- return EolStreamTypeUtil.wrapInputStream(in, getEolStreamType());
+ private InputStream handleAutoCRLF(InputStream in, OperationType opType)
+ throws IOException {
+ return EolStreamTypeUtil.wrapInputStream(in, getEolStreamType(opType));
}
/**
@@ -1332,10 +1349,28 @@ public abstract class WorkingTreeIterator extends AbstractTreeIterator {
* @since 4.3
*/
public EolStreamType getEolStreamType() throws IOException {
+ return getEolStreamType(null);
+ }
+
+ /**
+ * @param opType
+ * The operationtype (checkin/checkout) which should be used
+ * @return the eol stream type for the current entry or <code>null</code> if
+ * it cannot be determined. When state or state.walk is null or the
+ * {@link TreeWalk} is not based on a {@link Repository} then null
+ * is returned.
+ * @throws IOException
+ */
+ private EolStreamType getEolStreamType(OperationType opType)
+ throws IOException {
if (eolStreamTypeHolder == null) {
EolStreamType type=null;
if (state.walk != null) {
- type=state.walk.getEolStreamType();
+ if (opType != null) {
+ type = state.walk.getEolStreamType(opType);
+ } else {
+ type=state.walk.getEolStreamType();
+ }
} else {
switch (getOptions().getAutoCRLF()) {
case FALSE: