[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[jgit-dev] JGit iterate all files of a commit
|
Hi,
I am building a custom workflow around JGit. I have a bare repository and create blobs and commits directly (i.e. without an index) via the API.
My workflow includes the following:
1. Create an "file" at path "1/1/prop/XYZ"
2. Create a commit
3. Retrieve the "tree" at path "1/1/prop"
Currently I am using the ObjectWalk to get the tree object at step #3.
ObjectWalk objectWalk = new ObjectWalk(getObjectReader());
RevCommit revCommit = objectWalk.parseCommit(commitId);
objectWalk.markStart(revCommit);
revCommit = objectWalk.next();
RevObject revObject;
while ((revObject = objectWalk.nextObject()) != null)
{
if (objectWalk path equals to path I look for)
{
// do my stuff
}
}
This works fine so far. In the following there is a difference though:
1. Create an "file" at path "1/1/prop/XYZ"
2. Create an "file" at path "1/2/prop/XYZ" (with the same content as "1/1/prop/XYZ"!)
3. Create a commit
4. Retrieve the "tree" at path "1/2/prop"
The ObjectWalk will never iterate to the object "1/2/prop" because it has the same "contentId" as "1/1/prop". Internally it is marked as "SEEN". I can remove the "SEEN" flag on each object in my loop but I am not sure if this is the most elegant way to do this.
Can somebody think of a better way to iterate through the tree?
Cheers
Philipp