A JGit-beginner-question:
I use JGit to read a file (BLOB) from a repository and manipulate its content. After that, I want to write the new content with the same filename back to the repository as a new commit. But how can I commit the new content with JGit?
My pseudo-code:
String gitUrl = "path/to/repository/.git";
Repository repository = new FileRepository(gitUrl);
String filename = "test/seppl.txt";
blobId = getIdOf(filename);
ObjectLoader object = repository.open(blobId, Constants.OBJ_BLOB);
ObjectStream is = object.openStream();
String newContent = processStream(is);
// How to commit the newContent in filename?
Do I have to write the newContent
into a file and commit this file with the AddCommand and CommitCommand? Or can I write the String "on-the-fly" into the repository under the same filename?
Is there anywhere in the web an example how to make a commit with JGit?