JGit frequently throws jgit.errors.MissingObjectException: Missing commit while merging [message #655815] |
Tue, 22 February 2011 17:13 |
m0 Messages: 11 Registered: August 2010 |
Junior Member |
|
|
Hello,
I am trying to reproduce the following exception:
org.eclipse.jgit.api.errors.JGitInternalException: Exception caught during execution of merge command. org.eclipse.
jgit.errors.MissingObjectException: Missing commit d8cce2103d8e36d0d924d93f1ac6b882c10b9a20
at org.eclipse.jgit.api.MergeCommand.call(MergeCommand.java:220)
at org.eclipse.jgit.api.PullCommand.call(PullCommand.java:255)
It happens frequently, and I don't understand why the fetching would miss that objectId.
When that exception occurs, I went to native git, and ran "git status"
$ git status
fatal: bad object HEAD
Then I wanted to read the tree to see if it is valid:
$ git read-tree HEAD
fatal: failed to unpack tree object HEAD
The only way to fix this, is to "git pull" from native git, pulling from JGit always throws the above exception:
$ git pull
error: refs/heads/master does not point to a valid object!
error: refs/remotes/origin/master does not point to a valid object!
error: refs/heads/master does not point to a valid object!
error: refs/remotes/origin/master does not point to a valid object!
error: refs/heads/master does not point to a valid object!
error: refs/remotes/origin/master does not point to a valid object!
error: refs/heads/master does not point to a valid object!
error: refs/remotes/origin/master does not point to a valid object!
remote: Counting objects: 1684, done.
remote: Compressing objects: 100% (1128/1128), done.
remote: Total 1684 (delta 452), reused 1453 (delta 376)
Receiving objects: 100% (1684/1684), 232.59 KiB, done.
Resolving deltas: 100% (452/452), done.
From localhost:/test
* [new branch] master -> origin/master
Already up-to-date.
The missing commit comes back to life. The only way for me to recover is from native git.
$ git status
# On branch master
nothing to commit (working directory clean)
Any ideas how to solve this issue? All I am doing in JGit is:
It works usually, but frequently (once per day) the whole repository goes in lock mode and I can't use JGit anymore, I would have to resort to "git pull" in native Git to make it function again.
Thanks!
|
|
|
|
Re: JGit frequently throws jgit.errors.MissingObjectException: Missing commit while merging [message #655975 is a reply to message #655950] |
Wed, 23 February 2011 15:36 |
m0 Messages: 11 Registered: August 2010 |
Junior Member |
|
|
Hi Matthias,
git fsck returns nothing. (I already recovered using native git).
Right now, my short term solution is to fall back to native git pull instead of JGit pull:
public boolean refresh() {
boolean status = false;
try {
git.pull().call();
status = true;
}
catch (JGitInternalException e) {
if (e.getCause() instanceof MissingObjectException) {
log.error("JGit Error occurred, trying to recover with Native Git");
// Lets attempt and recover using Native Git. Something went
// wrong using JGit Merge.
status = nativeRefresh();
} else {
log.error("JGit Error recovery failed. " + e.getMessage(), e);
}
}
catch (GitAPIException e) {
log.error("Cannot find Git repository. " + e.getMessage(), e);
}
return status;
}
private boolean nativeRefresh() {
boolean status = false;
String[] commandLine = new String[] {
"c:/Git/bin/sh.exe",
"--login",
"-i",
"-c",
"git pull"
};
ProcessBuilder pb = new ProcessBuilder(commandLine);
pb.directory(new File("C:/repo/"));
pb.redirectErrorStream(true);
try {
Process p = pb.start();
status = p.waitFor() == 0 ? true : false;
p.destroy();
} catch (IOException e) {
log.error("Git pull process cannot successfully start. ", e);
} catch (InterruptedException e) {
log.error("Something went wrong waiting for Git pull to complete", e);
}
return status;
}
What do you recommend me to do next to help solve this issue? The git repo is linear, and JGit is the only one pushing to it no one else. No branches are being made, everything is done in Master.
Thanks in advance.
[Updated on: Wed, 23 February 2011 15:38] Report message to a moderator
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04534 seconds