diff options
Diffstat (limited to 'org.eclipse.egit.core/src/org/eclipse/egit/core/internal/storage/IndexResourceVariant.java')
-rw-r--r-- | org.eclipse.egit.core/src/org/eclipse/egit/core/internal/storage/IndexResourceVariant.java | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/storage/IndexResourceVariant.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/storage/IndexResourceVariant.java new file mode 100644 index 0000000000..14b3b0be44 --- /dev/null +++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/storage/IndexResourceVariant.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (C) 2015, Obeo. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.egit.core.internal.storage; + +import org.eclipse.core.resources.IStorage; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jgit.dircache.DirCacheEntry; +import org.eclipse.jgit.lib.FileMode; +import org.eclipse.jgit.lib.ObjectId; +import org.eclipse.jgit.lib.Repository; +import org.eclipse.team.core.TeamException; + +/** + * Implementation of a resource variant populated through a Repository's + * DirCache information. + */ +public class IndexResourceVariant extends AbstractGitResourceVariant { + private IndexResourceVariant(Repository repository, String path, + boolean isContainer, ObjectId objectId, int rawMode) { + super(repository, path, isContainer, objectId, rawMode); + } + + /** + * Constructs a resource variant corresponding to the given DirCache entry. + * + * @param repository + * Repository from which this DirCacheEntry was extracted. + * @param entry + * The DirCacheEntry for which content we need an + * IResourceVariant. + * @return The created variant. + */ + public static IndexResourceVariant create(Repository repository, + DirCacheEntry entry) { + final String path = entry.getPathString(); + final boolean isContainer = FileMode.TREE.equals(entry.getFileMode()); + final ObjectId objectId = entry.getObjectId(); + final int rawMode = entry.getRawMode(); + + return new IndexResourceVariant(repository, path, isContainer, + objectId, rawMode); + } + + public IStorage getStorage(IProgressMonitor monitor) throws TeamException { + return new IndexBlobStorage(repository, path, objectId); + } +} |