Skip to main content



      Home
Home » Eclipse Projects » EGit / JGit » How can I get content of a file from git index?
How can I get content of a file from git index? [message #654949] Thu, 17 February 2011 12:52 Go to next message
Eclipse UserFriend
Can someone give me a tip how could I implement this using JGit API?

Or could the question in title be answered in a different way?

[Updated on: Thu, 17 February 2011 12:52] by Moderator

Re: How can I get content of a file from git index? [message #655149 is a reply to message #654949] Fri, 18 February 2011 08:53 Go to previous message
Eclipse UserFriend
Let me answer my own question. Here is how I did it:

Repository db = new FileRepository(gitDir);
DirCache cache = db.readDirCache();
DirCacheEntry entry = cache.getEntry(path.toString());
ObjectId blobId = entry.getObjectId();
return db.open(blobId, Constants.OBJ_BLOB).openStream();


Problem solved. Or is there an simpler way of doing that?
Previous Topic:ANT Support?
Next Topic:Getting revisions for a specific folder/file
Goto Forum:
  


Current Time: Wed Jul 02 19:06:24 EDT 2025

Powered by FUDForum. Page generated in 0.04690 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top