Community
Participate
Working Groups
We built a pre-receive hook to check the format of the commit messages before they're accepted. For this we call a java application from the hook which is built on JGit. We use a RevWalk object to walk through the new commits. Since git 2.11 this solution does not work, because the line below throws an exception: RevCommit commit = rw.parseCommit(ref.getLeaf().getObjectId()); rw.markStart(commit); // the exception is thrown here The exception: Caused by: org.eclipse.jgit.errors.MissingObjectException: Missing commit c96c33d3c9a7793836caa6260a5fd69637d348ca at org.eclipse.jgit.storage.file.WindowCursor.open(WindowCursor.java:126) at org.eclipse.jgit.revwalk.RevWalk.getCachedBytes(RevWalk.java:855) at org.eclipse.jgit.revwalk.RevCommit.parseHeaders(RevCommit.java:136) at org.eclipse.jgit.revwalk.RevWalk.markStart(RevWalk.java:282) at org.eclipse.jgit.api.LogCommand.add(LogCommand.java:237) at org.eclipse.jgit.api.LogCommand.add(LogCommand.java:155) As far as I understood the problem is that git no longer stores the new commits in the repo, but stores them in the quarantine. Is there a way to access the commits in the quarantine using JGit?
What do you mean with "since git 2.11". What is the exact use case and how does the native git version comes into play. Are you running JGit and native git parallel on repos on the server side?
Hi Christian, yes, we run native git on the server and we call the java code from the pre-receive hook started by the native git. And this is where jgit comes into play. So the pre-receive hook starts the java app built on jgit and we try to parse the incoming changes. Since git 2.1.1 our code does not work, I guess because the incoming changes are stored in a quarantine directory since that version.
see https://github.com/git/git/commit/722ff7f876c8a2ad99c42434f58af098e61b96e8 and https://github.com/git/git/commit/eaeed077a69ad1e26b0c329ac0f6cbd397f5be9e
Ok, thanks for the explanation. Now I got the point. Yes, I think you are pointing to a missing feature in JGit. We are currently not inspecting the environment and setting up a repo with additional object directories before we execute the hook. I guess that would be required now. The repo could receive multiple pushes and just adding all incoming-* folders to the list of object directories is not correct. Also making sure that all new git objects created by the hook are put into the temporary object directory first has to be implemented. Maybe as a workaround this can be done in the java based hook. Inspect the environment for information about extra object directory and tweak the jgit repository to also look there. Just thinking loud ....