I'm writing my program in java using Class Repository from JGit.
This class has the method resolve(String revstr).
Basically this methoad parses a git revision string and returns an object id. There are specific combinations of these operators which are supported:
HEAD, MERGE_HEAD, FETCH_HEAD
SHA-1: a complete or abbreviated SHA-1
refs/...: a complete reference name
short-name: a short reference name under refs/heads, refs/tags, or refs/remotes namespace
tag-NN-gABBREV: output from describe, parsed by treating ABBREV as an abbreviated SHA-1.
id^: first parent of commit id, this is the same as id^1
id^0: ensure id is a commit
id^n: n-th parent of commit id
id~n: n-th historical ancestor of id, by first parent. id~3 is equivalent to id^1^1^1 or id^^^.
id:path: Lookup path under tree named by id
id^{commit}: ensure id is a commit
id^{tree}: ensure id is a tree
id^{tag}: ensure id is a tag
id^{blob}: ensure id is a blob
I want to use this method
Repository repo;
ObjectId commit = repo.resolve("cnfuwfxmiazsdixfnsdiufsdhfiusfhsfisfh^{tree}");
System.out.println(commit );
Expected Ouput:
cnfuwfxmiazsdixfnsdiufsdhfiusfhsfisfh
Output:
sjakfshdofcsmdfocsdfjdofdjgdhgfdgfhgf
//Output is another commit in project.
I want to have the commit which I've inserted, but it shows me another commit. I think because it is the first parent of the commit id.
Is there any way to get the same commit id which I put into the method resolve()
?