Example usage for org.eclipse.jgit.treewalk WorkingTreeOptions getAutoCRLF

List of usage examples for org.eclipse.jgit.treewalk WorkingTreeOptions getAutoCRLF

Introduction

In this page you can find the example usage for org.eclipse.jgit.treewalk WorkingTreeOptions getAutoCRLF.

Prototype

public AutoCRLF getAutoCRLF() 

Source Link

Document

Get automatic CRLF conversion configuration.

Usage

From source file:org.eclipse.egit.core.storage.GitBlobStorage.java

License:Open Source License

private InputStream open() throws IOException, CoreException, IncorrectObjectTypeException {
    if (blobId == null)
        return new ByteArrayInputStream(new byte[0]);

    try {/* ww  w . j a  va 2 s.c  o m*/
        WorkingTreeOptions workingTreeOptions = db.getConfig().get(WorkingTreeOptions.KEY);
        final InputStream objectInputStream = db.open(blobId, Constants.OBJ_BLOB).openStream();
        switch (workingTreeOptions.getAutoCRLF()) {
        case INPUT:
            // When autocrlf == input the working tree could be either CRLF or LF, i.e. the comparison
            // itself should ignore line endings.
        case FALSE:
            return objectInputStream;
        case TRUE:
        default:
            return new AutoCRLFInputStream(objectInputStream, true);
        }
    } catch (MissingObjectException notFound) {
        throw new CoreException(
                Activator.error(NLS.bind(CoreText.BlobStorage_blobNotFound, blobId.name(), path), notFound));
    }
}