Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » JGit frequently throws jgit.errors.MissingObjectException: Missing commit while merging
JGit frequently throws jgit.errors.MissingObjectException: Missing commit while merging [message #655815] Tue, 22 February 2011 17:13 Go to next message
m0 is currently offline m0Friend
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:

git.pull().call();


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 #655950 is a reply to message #655815] Wed, 23 February 2011 13:47 Go to previous messageGo to next message
Matthias Sohn is currently offline Matthias SohnFriend
Messages: 1268
Registered: July 2009
Senior Member
What's the output of "git fsck" [1] run on your repository ?

[1] http://www.kernel.org/pub/software/scm/git/docs/git-fsck.htm l
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 Go to previous messageGo to next message
m0 is currently offline m0Friend
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

Re: JGit frequently throws jgit.errors.MissingObjectException: Missing commit while merging [message #656120 is a reply to message #655975] Thu, 24 February 2011 10:01 Go to previous messageGo to next message
Matthias Sohn is currently offline Matthias SohnFriend
Messages: 1268
Registered: July 2009
Senior Member
Are you using egit here or is this your own implementation using jgit ?
Re: JGit frequently throws jgit.errors.MissingObjectException: Missing commit while merging [message #656302 is a reply to message #656120] Fri, 25 February 2011 00:06 Go to previous messageGo to next message
m0 is currently offline m0Friend
Messages: 11
Registered: August 2010
Junior Member
I am creating an application using the JGit jar (the stable one on the site)

As you have seen in my previous comment, when a MissingObjectException occurs, it uses msysgit to do a "git pull". From looking at the logs, I still see it failing but when it does, it recovers now since I added that msysgit ProcessBuilder addition. It does that when I stress the git pull / push.

Is there some sort of magical command to enable more verbose messages on what is happening, perhaps I can log those and try to solve why this exception occurs frequently.

Even those this bandage solution works, I would rather help fix the bug than living with maintaining two git implementations. (I didn't want to install msysgit or native git on the box).
Re: JGit frequently throws jgit.errors.MissingObjectException: Missing commit while merging [message #708658 is a reply to message #656302] Wed, 03 August 2011 03:39 Go to previous messageGo to next message
endoplasmicR is currently offline endoplasmicRFriend
Messages: 1
Registered: August 2011
Junior Member
Hi, I have run into the very same problem just recently, the error messages are exactly the same and the code structure is very similar, I wonder if this issue has been resolved.
Also, I am running it on Windows Vista if it matters.

Thanks in advance.
Re: JGit frequently throws jgit.errors.MissingObjectException: Missing commit while merging [message #720710 is a reply to message #708658] Wed, 31 August 2011 06:07 Go to previous messageGo to next message
Maxime Jeanmart is currently offline Maxime JeanmartFriend
Messages: 35
Registered: November 2010
Member
Same problem for me yesterday. The local repository was corrupted with the following message: "refs/remotes/origin/master does not point to a valid object".
I had to pull from native git to solve that problem. After that, for some reasons I don't understand, some of my source files had a "modified" marker, like if the merged source files were not locally commited or something like that.
I had to commit manually the merged code. Push was still failing. I had to pull again first.

[Updated on: Wed, 31 August 2011 06:22]

Report message to a moderator

Re: JGit frequently throws jgit.errors.MissingObjectException: Missing commit while merging [message #1125226 is a reply to message #655815] Fri, 04 October 2013 09:35 Go to previous message
sha p is currently offline sha pFriend
Messages: 2
Registered: August 2013
Junior Member
Hi ,
Me using JGIT jars 1)org.eclipse.egit.github.core-2.0.4.jar and 2)org.eclipse.jgit-2.3.1.201302201838-r for a Java project.

While i am trying to retrive the file version from Repository(i.e. a physical directory on my computer file system ).

I am getting the below error:
13:12:10,268 INFO [STDOUT] nothing fouind
13:12:10,283 ERROR [STDERR] org.eclipse.jgit.errors.MissingObjectException: Missing unknown 0000000000000000000000000000000000000000
13:12:10,283 ERROR [STDERR] at org.eclipse.jgit.storage.file.WindowCursor.open(WindowCursor.java:125)
13:12:10,283 ERROR [STDERR] at org.eclipse.jgit.lib.ObjectDatabase.open(ObjectDatabase.java:176)
13:12:10,283 ERROR [STDERR] at org.eclipse.jgit.lib.ObjectDatabase.open(ObjectDatabase.java:147)
13:12:10,283 ERROR [STDERR] at org.eclipse.jgit.lib.Repository.open(Repository.java:243)



Could anyone help me how to recover from this error.
I would be very happy if you provide any Java fix.

Thank you.
shasu

Previous Topic:head not master in decorator text
Next Topic:Diff inside commit dialog
Goto Forum:
  


Current Time: Sat Apr 20 01:54:18 GMT 2024

Powered by FUDForum. Page generated in 0.03073 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top