Re: Newbie questions regarding jgit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Farrukh Najmi <farrukh@xxxxxxxxxxxxxxxxxxxxx> 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.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux