From: "Shawn O. Pearce" <spearce@spearce.org>
To: Farrukh Najmi <farrukh@wellfleetsoftware.com>
Cc: git@vger.kernel.org
Subject: Re: Newbie questions regarding jgit
Date: Wed, 12 Nov 2008 11:29:05 -0800 [thread overview]
Message-ID: <20081112192905.GW2932@spearce.org> (raw)
In-Reply-To: <491B18C4.2070000@wellfleetsoftware.com>
Farrukh Najmi <farrukh@wellfleetsoftware.com> wrote:
>
> So far I have figured out how to get the treeWalk for the path filter as
> shown below.
> Now I am lost as to how to get the blob associated with the treeWalk.
> TIA for your help.
>
> /**
> * Gets the content of specified file in git Repo.
> *
> * @parameter relativePath the relative path in jitRepo for desired
> file to get
> * @parameter versionName the versionName for the desired file. It
> will be unmarshalled from String to ObjectId.
> * @return the content of the desired file version packaged as a
> DataHandler.
> */
> public DataHandler get(String relativePath, String versionName) throws
> RepositoryException {
> ObjectId retrieveStart = repository.resolve(versionName);
> RevWalk revWalk = new RevWalk(repository);
> RevCommit entry = revWalk.parseCommit(retrieveStart);
> RevTree revTree = entry.getTree();
>
> TreeWalk treeWalk = TreeWalk.forPath(repository,
> relativePath, revTree);
>
> //Not sure how to get the blob next
if (treeWalk.next()) {
// Path exists
if (treeWalk.getFileMode(0).getObjectType() == Constants.OBJ_BLOB) {
ObjectId blob = treeWalk.getObjectId(0);
} else {
// Not a blob, its something else (tree, gitlink)
}
} else {
// Path not found
}
--
Shawn.
next prev parent reply other threads:[~2008-11-12 19:30 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-11 20:44 Newbie questions regarding jgit Farrukh Najmi
2008-11-11 21:12 ` Farrukh Najmi
2008-11-11 21:37 ` Jonas Fonseca
2008-11-11 21:44 ` Shawn O. Pearce
2008-11-11 22:01 ` Jonas Fonseca
2008-11-11 23:11 ` Shawn O. Pearce
2008-11-11 23:48 ` [PATCH] Add maven distribution management info for the new snapshot repository Jonas Fonseca
2008-11-12 0:58 ` Shawn O. Pearce
2008-11-12 1:01 ` Shawn O. Pearce
2008-11-12 2:24 ` Newbie questions regarding jgit Imran M Yousuf
2008-11-12 12:51 ` Farrukh Najmi
2008-11-12 14:05 ` Farrukh Najmi
2008-11-12 14:33 ` Farrukh Najmi
2008-11-12 17:56 ` Farrukh Najmi
2008-11-12 18:30 ` Jonas Fonseca
2008-11-12 19:29 ` Shawn O. Pearce [this message]
-- strict thread matches above, loose matches on Subject: below --
2008-11-12 22:36 Robin Rosenberg
2008-11-12 22:37 Robin Rosenberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20081112192905.GW2932@spearce.org \
--to=spearce@spearce.org \
--cc=farrukh@wellfleetsoftware.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).