JGit bare fix / wood construction

I am trying to pass a single blob directly to the repository using jgit. I know how to insert blob and get it sha1, however I am having difficulty building a tree for this scenario. I can't figure out how to properly use jgit tree abstractions (TreeWalk, etc.), To recursively build a tree that is almost identical to previous commits, with only different parent blob trees.

What is the idiomatic way to do this in JGit?

The reason I ask is because I am writing a program that is a kind of editor for documents living in git repositories. In my case, the whole point of using git is to be able to have multiple versions of documents (aka branch) at the same time. Since this is an editor, I should be able to commit changes, however, since I want to see several versions of a document at the same time, checking, changing a file and transferring using the JGit API are impossible, it should work directly with git objects.

+4
source share
1 answer

The low-level API you can use for this is TreeFormatter along with CommitBuilder.

. .

, , . . TreeWalk#setRecursive TreeWalk#setPostOrderTraversal.

- DirCache, DirCacheEntries , DirCache#writeTree.

+2

Source: https://habr.com/ru/post/1531126/


All Articles