Browse Source

Remove an old work-around for core.autocrlf = input

The removed code was trying to avoid mistakenly reporting differences
when core.autocrlf was set to "input" but a file had already been
committed with CR-LF. It did that by running the blob from the cache
through a CRLF-to-LF filter because older JGit would also run the file
from the working tree through such a filter.

The real fix for this case was done in commit 60cf85a. Since then files
are not normalized if they have already been committed with CR-LF and
this old fix attempt from bug 372834 is no longer needed.

Change-Id: Ib4facc153d81325cb48b4ee956a596b423f36241
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
next
Thomas Wolf 5 years ago committed by Matthias Sohn
parent
commit
2e75fe6be1
  1. 36
      org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java

36
org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java

@ -101,7 +101,6 @@ import org.eclipse.jgit.util.Paths;
import org.eclipse.jgit.util.RawParseUtils; import org.eclipse.jgit.util.RawParseUtils;
import org.eclipse.jgit.util.TemporaryBuffer; import org.eclipse.jgit.util.TemporaryBuffer;
import org.eclipse.jgit.util.TemporaryBuffer.LocalFile; import org.eclipse.jgit.util.TemporaryBuffer.LocalFile;
import org.eclipse.jgit.util.io.AutoLFInputStream;
import org.eclipse.jgit.util.io.EolStreamTypeUtil; import org.eclipse.jgit.util.io.EolStreamTypeUtil;
import org.eclipse.jgit.util.sha1.SHA1; import org.eclipse.jgit.util.sha1.SHA1;
@ -1097,41 +1096,8 @@ public abstract class WorkingTreeIterator extends AbstractTreeIterator {
return !new File(readSymlinkTarget(current())).equals( return !new File(readSymlinkTarget(current())).equals(
new File(readContentAsNormalizedString(entry, reader))); new File(readContentAsNormalizedString(entry, reader)));
} }
// Content differs: that's a real change, perhaps // Content differs: that's a real change
if (reader == null) // deprecated use, do no further checks
return true; return true;
switch (getEolStreamType()) {
case DIRECT:
return true;
default:
try {
ObjectLoader loader = reader.open(entry.getObjectId());
if (loader == null)
return true;
// We need to compute the length, but only if it is not
// a binary stream.
long dcInLen;
try (InputStream dcIn = new AutoLFInputStream(
loader.openStream(), true,
true /* abort if binary */)) {
dcInLen = computeLength(dcIn);
} catch (AutoLFInputStream.IsBinaryException e) {
return true;
}
try (InputStream dcIn = new AutoLFInputStream(
loader.openStream(), true)) {
byte[] autoCrLfHash = computeHash(dcIn, dcInLen);
boolean changed = getEntryObjectId()
.compareTo(autoCrLfHash, 0) != 0;
return changed;
}
} catch (IOException e) {
return true;
}
}
} }
} }

Loading…
Cancel
Save