Correct reference to EPL in source headers
[egit/chris.git] / org.eclipse.egit.core / src / org / eclipse / egit / core / internal / storage / IndexFileRevision.java
blob87dc2830a7f225ea26f4b0a595a4382869587863
1 /*******************************************************************************
2 * Copyright (C) 2007, Robin Rosenberg <me@lathund.dewire.com>
3 * Copyright (C) 2006, Robin Rosenberg <robin.rosenberg@dewire.com>
4 * Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
6 * All rights reserved. This program and the accompanying materials
7 * are made available under the terms of the Eclipse Public License v1.0
8 * which accompanies this distribution, and is available at
9 * http://www.eclipse.org/legal/epl-v10.html
10 *******************************************************************************/
11 package org.eclipse.egit.core.internal.storage;
13 import java.io.IOException;
15 import org.eclipse.core.internal.resources.ResourceException;
16 import org.eclipse.core.resources.IResourceStatus;
17 import org.eclipse.core.resources.IStorage;
18 import org.eclipse.core.runtime.CoreException;
19 import org.eclipse.core.runtime.IProgressMonitor;
20 import org.eclipse.core.runtime.Path;
21 import org.eclipse.team.core.history.IFileRevision;
22 import org.spearce.jgit.lib.GitIndex;
23 import org.spearce.jgit.lib.ObjectId;
24 import org.spearce.jgit.lib.Repository;
25 import org.spearce.jgit.lib.GitIndex.Entry;
27 /** An {@link IFileRevision} for the version in the Git index. */
28 class IndexFileRevision extends GitFileRevision implements IFileRevision {
29 private final Repository db;
31 private final String path;
33 private ObjectId blobId;
35 IndexFileRevision(final Repository repo, final String fileName) {
36 super(fileName);
37 db = repo;
38 path = fileName;
41 public IStorage getStorage(IProgressMonitor monitor) throws CoreException {
42 if (blobId == null)
43 blobId = locateBlobObjectId();
44 return new BlobStorage(db, path, blobId);
47 public boolean isPropertyMissing() {
48 return false;
51 public IFileRevision withAllProperties(IProgressMonitor monitor)
52 throws CoreException {
53 return null;
56 public String getAuthor() {
57 return "";
60 public long getTimestamp() {
61 return -1;
64 public String getComment() {
65 return null;
68 public String getContentIdentifier() {
69 return INDEX;
72 private ObjectId locateBlobObjectId() throws CoreException {
73 try {
74 final GitIndex idx = db.getIndex();
75 final Entry e = idx.getEntry(path);
76 if (e == null)
77 throw new ResourceException(IResourceStatus.FAILED_READ_LOCAL,
78 Path.fromPortableString(path),
79 "Git index entry not found", null);
80 return e.getObjectId();
82 } catch (IOException e) {
83 throw new ResourceException(IResourceStatus.FAILED_READ_LOCAL, Path
84 .fromPortableString(path),
85 "IO error looking up path in index.", e);