Cannot retrieve file from SHA-1 string [message #842420] |
Thu, 12 April 2012 05:26  |
Eclipse User |
|
|
|
Hi,
if I want to retrieve the content of a specific version of a file from a git repository, given the SHA-1 code, I could type in the bash console:
$ cd /path/to/repository
$ git show 7c66f31affb6861abafd9b5217f06ebdd25bc5d8
and I have the content of the file in the version I'm asking for.
I'm trying to do the same in java with jgit api:
FileRepositoryBuilder builder = new FileRepositoryBuilder();
Repository repo = builder.setGitDir(path).readEnvironment().findGitDir().build();
ObjectId object= repo.resolve("7c66f31affb6861abafd9b5217f06ebdd25bc5d8");
String result = new String(repo.open(object).getCachedBytes(), "UTF-8");
but I have a "Missing unknown 7c66f31affb6861abafd9b5217f06ebdd25bc5d8" exception in return
Where am I wrong?
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.28953 seconds