Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[egit-dev] How can I check if a file is contained in a commit?

"Shawn O. Pearce" wrote:
> Mihael Vrbanec <vrbanec@xxxxxxxxxxxx> wrote:
> > My question is: I have a RevCommit (the entry selected in the history
> > view) and want to obtain the corresponding revision of the file. I
> tried
> > using
> > ...
> > final String gitPath = mapping.getRepoRelativePath(resource);
> > final IFileRevision nextFile = GitFileRevision.inCommit(
> >                        db,
> >                        commit,
> >                        gitPath,
> >                        commit);
> >
> > to no avail.
> Pass null as the last arg, not commit.
> That last argument is the ObjectId of the file revision itself.
> Since you don't have that in hand, you want to pass null so
> GitFileRevision will tell CommitFileRevision to lookup the path
> and translate it to the proper blob ObjectId on demand.

When the file is not in the repo, I get an Exception when I call IFileRevision.getStorage:

org.eclipse.core.internal.resources.ResourceException: Path not in commit 046198cf5f21e5a63e8ec0ecde2ef3fe21db2eae 1254268023 ----sp.

How can I check in advance if the file is in the commit?


Back to the top