Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Agit fetch apparently completes, but new commits are not displayed #92

Closed
maisonobe opened this issue Mar 1, 2013 · 5 comments
Closed

Comments

@maisonobe
Copy link

Since a few weeks, I am completely unable to use Agit. It clones public repositories properly the first time, but it never sees new commits. When I force it to fetch with the spin arrows at the right of the top red bar, it notifies me about fetch, then say fetch is complete, but the last commit is always the one the was created at clone time. New commits never appear.

I have tried on several git repositories with several protocols. An example using git protocol is git://git.apache.org/commons-math.git, and an example with http protocol is http://www.orekit.org/git/orekit.

I looked at the /sdcard/git-repos/the-repo-name.git/FETCH_HEAD, and the sha1 seemed correct and seemed to point to the latest commit, as if it was correctly retrieved from the remote server. However, looking into the objects directory, I found only an empty info and a pack directory with a few pack file, but all of them were older than the more recent commit. I did not find the bunch of classical directories 00, 01 ... ff that hold objects as in my desktop computer (I use a Debian Linux computer).

@sakekasi
Copy link

sakekasi commented Mar 1, 2013

It works if you uncheck the bare option when cloning.

@rtyley
Copy link
Owner

rtyley commented Mar 1, 2013

I've just verified this issue when using a bare clone of https://github.com/rtyley/jgit - damn, thanks @maisonobe for reporting this, it's a pretty awful regression.

There doesn't seem to be any obvious reason why this regression would have occurred in the last release, apart from 470d0a7, which was an update to the latest version of JGit at the time, v2.2.0.

I'll look into it - thanks for reporting the issue.

rtyley added a commit that referenced this issue Mar 2, 2013
Agit v1.36 updated JGit from v2.0 to v2.2. It looks like some change was
introduced with JGit 2.1 (and all subsequent versions I've checked)
that makes the ref update fail... perhaps addressing the ref with the
wrong name (or made it sensitive to using the wrong name), as we see
debug like this:

TrackingRefUpdate : refs/heads//master old=AnyObjectId[0000000000000000000000000000000000000000] new=AnyObjectId[ce1e0703402e989bedf03d5df535401340f54b42]

The ref had a proper value before the ref update, so should not have
been 00000000... and the correct new value we see is lost, not stored
to any place I can see. Not sure what's going on with the double slash,
JGit 2.0 has it too.

Weirdly, I've only been able to reproduce this issue with repos cloned
by Agit - so 'testFetchUpdatesFromLocalTestServer()' always passes,
but 'testFetchUpdatesOnCloneFromLocalTestServer()' fails with JGit 2.1
and above.
@rtyley
Copy link
Owner

rtyley commented Mar 2, 2013

I've released Agit v1.37 to the Google Play Store, it should start showing up there within a few hours. This is an interim release, just to get things working again. It reverts back to using JGit 2.0, as JGit 2.1 introduced some unknown change that cause the problem - I'm still investigating what exactly that is, and will likely make another release with the latest version of JGit (v2.3.1) once I work out what's going on.

Integration tests for this issue have been added with 6fd4b1c to ensure there's no further chance for regression here.

@maisonobe
Copy link
Author

I confirm he issue is fixed with the latest version from the Google Play Store.

Thanks a lot for this really quick fix!

@rtyley rtyley closed this as completed in 06ef150 Mar 11, 2013
@rtyley
Copy link
Owner

rtyley commented Mar 11, 2013

The full fix for this issue (commit 06ef150) is in release v1.38, just released to the Google Play Store. The fix is a patched version of JGit that includes these two patches:

https://git.eclipse.org/r/10810 - don't generate malformed fetch refspecs
https://git.eclipse.org/r/11027 - tolerate malformed refspecs (to cope with repos already cloned with an old version)

Thanks again for the bug report!

shabanovd pushed a commit to eXist-db/jgit that referenced this issue Nov 11, 2013
CloneCommand has been creating fetch refspecs like this on bare clones:

[remote "origin"]
        url = ssh://example.com/my-repo.git
        fetch = +refs/heads/*:refs/heads//*

As you can see, the destination ref pattern has a superfluous slash.

It looks like this behaviour has always been the case for CloneCommand,
at least since cc2197e when code catering to bare-clone fetch refspecs
was added. That was released with JGit v1.0 almost 2 years ago, so
there will probably be some bare repos in the wild which will have been
cloned with JGit and have these corrupted refspecs.

The effect of the corrupted fetch refspec is quite interesting. Up to
and including JGit 2.0, the corrupt refspec was tolerated and fetches
would work as intended with no indication to the user that anything was
amiss. With JGit 2.1, a change was introduced which made JGit less
tolerant, and fetches now attempt to update the non-existing ref
"refs/heads//master". No exception is raised, but the real ref -
"refs/heads/master" - is not updated.

This behaviour was noticed by a user of Agit (which does bare clones by
default and recently updated from JGit v2.0 to v2.2), reported here:

rtyley/agit#92


If you run C-Git fetch on a bare-repo cloned by JGit, it flat-out
rejects the refspec (checked against v1.7.10.4):

fatal: Invalid refspec '+refs/heads/*:refs/heads//*'

Incidentally, C-Git does not create an explicit fetch refspec at all
when performing a bare clone - the full remote config generated by C-Git
looks like this:

[remote "origin"]
        url = ssh://example.com/my-repo.git

Using JGit on such a repository works fine, so omitting the fetch
refspec entirely is also an option.

Change-Id: I14b0d359dc69b8908f68e02cea7a756ac34bf881
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants