Search in sources :

Example 1 with AutoCRLFInputStream

use of org.eclipse.jgit.util.io.AutoCRLFInputStream in project egit by eclipse.

the class GitBlobStorage method open.

private InputStream open() throws IOException, CoreException, IncorrectObjectTypeException {
    if (blobId == null)
        return new ByteArrayInputStream(new byte[0]);
    try {
        WorkingTreeOptions workingTreeOptions = db.getConfig().get(WorkingTreeOptions.KEY);
        final InputStream objectInputStream = db.open(blobId, Constants.OBJ_BLOB).openStream();
        switch(workingTreeOptions.getAutoCRLF()) {
            case INPUT:
            // 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));
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) AutoCRLFInputStream(org.eclipse.jgit.util.io.AutoCRLFInputStream) InputStream(java.io.InputStream) AutoCRLFInputStream(org.eclipse.jgit.util.io.AutoCRLFInputStream) WorkingTreeOptions(org.eclipse.jgit.treewalk.WorkingTreeOptions) MissingObjectException(org.eclipse.jgit.errors.MissingObjectException)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 CoreException (org.eclipse.core.runtime.CoreException)1 MissingObjectException (org.eclipse.jgit.errors.MissingObjectException)1 WorkingTreeOptions (org.eclipse.jgit.treewalk.WorkingTreeOptions)1 AutoCRLFInputStream (org.eclipse.jgit.util.io.AutoCRLFInputStream)1