Community
Participate
Working Groups
[ git version ] CGit/2.23.0 JGit/5.11.0.202103091610-r I created the instance of org.eclipse.jgit.transport.UploadPack like this for all requests: public UploadPack create(...) { //..... uploadPack.setRequestPolicy(UploadPack.RequestPolicy.ANY); return uploadPack; } When I tried to fetch an unreachable commit: $ GIT_TRACE_PACKET=1 GIT_CURL_VERBOSE=1 git fetch origin 8276f1c3db57ac6d1a15f0433d5bd35065a6557c 12:50:22.976115 pkt-line.c:80 packet:fetch< 8a7570a00a2a5f94dd83e13a89004e3c0d057ac0 HEAD\0 include-tag multi_ack_detailed multi_ack ofs-delta side-band side-band-64k thin-pack no-progress shallow agent=JGit/5.11.0.202103091610-r filter symref=HEAD:refs/heads/master 12:50:22.976633 pkt-line.c:80 packet:fetch< 8a7570a00a2a5f94dd83e13a89004e3c0d057ac0 refs/heads/master 12:50:22.976663 pkt-line.c:80 packet:fetch< b6484bdf45979938d610ae2d92027ef12a909992 refs/tags/v1.0 12:50:22.976677 pkt-line.c:80 packet:fetch< 0000 12:50:22.983349 pkt-line.c:80 packet:fetch> 0000 error: Server does not allow request for unadvertised object 8276f1c3db57ac6d1a15f0433d5bd35065a6557c the fetch-pack process of CGit didn't send the SHA-1 it wants but reported an error. After I read [1] in CGit, I found that Git server must send capability allow-tip-sha1-in-want or allow-reachable-sha1-in-want to allow fetching any sha1 in the protocol v0/v1. (v2 supports these by default.) CGit sends both of these capabilities, according to [2]. Besides the reason in [2], allowing fetching any sha1 is important for the partital clone, too. We expect JGit to support this feature in any version of the protocol, refer to CGit. [1] https://github.com/git/git/blob/master/fetch-pack.c [2] https://github.com/git/git/commit/f8edeaa05d8623a9f6dad408237496c51101aad8
New Gerrit change created: https://git.eclipse.org/r/c/jgit/jgit/+/180276
New Gerrit change created: https://git.eclipse.org/r/c/jgit/jgit/+/180794
With these changes, we can simply enable Partial Clone[1] on your git server without rewriting code. git config --global uploadpack.allowAnySHA1InWant true git config --global uploadPack.allowFilter true And solve Gerrit problem[2], too. When uploadpack.allowAnySHA1InWant is true, git can fetch any sha1 (even tree/blob object). [1] https://git-scm.com/docs/partial-clone [2] https://groups.google.com/g/repo-discuss/c/NYr9FnbJY90
(In reply to Kyle Zhao from comment #3) > With these changes, we can simply enable Partial Clone[1] on your git server > without rewriting code. > > > git config --global uploadpack.allowAnySHA1InWant true > git config --global uploadPack.allowFilter true > > And solve Gerrit problem[2], too. > > When uploadpack.allowAnySHA1InWant is true, git can fetch any sha1 (even > tree/blob object). > > [1] https://git-scm.com/docs/partial-clone > [2] https://groups.google.com/g/repo-discuss/c/NYr9FnbJY90 I tried to enable partial clone for my gerrit server with the below configuration: git config --global uploadpack.allowAnySHA1InWant true git config --global uploadPack.allowFilter true Doing partial clone with command: git clone --filter=blob:none ssh://GERRIT_SERVER/a/test. clone works fine, but checkout gives an error: error: Server does not allow request for unadvertised object 040ee0a2fbdbc63fc4eb04563cad44496de2f2ca error: Server does not allow request for unadvertised object 3b18e512dba79e4c8300dd08aeb37f8e728b8dad error: Server does not allow request for unadvertised object 3b18e512dba79e4c8300dd08aeb37f8e728b8dad error: Server does not allow request for unadvertised object 3b18e512dba79e4c8300dd08aeb37f8e728b8dad error: unable to read sha1 file of hello.txt (3b18e512dba79e4c8300dd08aeb37f8e728b8dad) error: Server does not allow request for unadvertised object 040ee0a2fbdbc63fc4eb04563cad44496de2f2ca error: Server does not allow request for unadvertised object 040ee0a2fbdbc63fc4eb04563cad44496de2f2ca error: unable to read sha1 file of src/hello.go (040ee0a2fbdbc63fc4eb04563cad44496de2f2ca) fatal: unable to checkout working tree warning: Clone succeeded, but checkout failed. The version of my gerrit server is 3.0.1. Does the jgit used by this version of gerrit support partial clone?
These changes are still in review hence no existing Gerrit release has them included.
(In reply to Matthias Sohn from comment #5) > These changes are still in review hence no existing Gerrit release has them > included. Thank you for your response. Is there any way to make gerrit 3.0.1 support partial clone now? Do I have to update jgit in order to support partial clone?
(In reply to Longping Tang from comment #6) > (In reply to Matthias Sohn from comment #5) > > These changes are still in review hence no existing Gerrit release has them > > included. > > Thank you for your response. > > Is there any way to make gerrit 3.0.1 support partial clone now? You should ask this question on the gerrit mailing list [1]. Gerrit 3.0 is EOL since Dec 1, 2020 [2]. So I think your best way forward is to upgrade Gerrit to a supported release, 3.4.5, 3.5.2 or 3.6.1 [3]. Always upgrade to the latest service release to benefit from all bug fixes and improvements. > Do I have to update jgit in order to support partial clone? Which features of partial cloning are you looking for ? [1] https://groups.google.com/g/repo-discuss [2] https://www.gerritcodereview.com/support.html [3] https://www.gerritcodereview.com/releases-readme.html
(In reply to Matthias Sohn from comment #7) > (In reply to Longping Tang from comment #6) > > (In reply to Matthias Sohn from comment #5) > > > These changes are still in review hence no existing Gerrit release has them > > > included. > > > > Thank you for your response. > > > > Is there any way to make gerrit 3.0.1 support partial clone now? > > You should ask this question on the gerrit mailing list [1]. > Gerrit 3.0 is EOL since Dec 1, 2020 [2]. So I think your best way forward is > to upgrade Gerrit to a supported release, 3.4.5, 3.5.2 or 3.6.1 [3]. Always > upgrade to the latest service release to benefit from all bug fixes and > improvements. I have asked the question a few days ago, but no reply. [1] https://groups.google.com/g/repo-discuss/c/fJvdpyEGoYg > > Do I have to update jgit in order to support partial clone? > > Which features of partial cloning are you looking for ? > I want to use the --filter=blob:none option. I tried to enable partial clone for my gerrit server with the below configuration: git config --global uploadpack.allowAnySHA1InWant true git config --global uploadPack.allowFilter true Doing partial clone with command: git clone --filter=blob:none ssh://GERRIT_SERVER/a/test. clone works fine, but checkout gives an error: error: Server does not allow request for unadvertised object 040ee0a2fbdbc63fc4eb04563cad44496de2f2ca error: Server does not allow request for unadvertised object 3b18e512dba79e4c8300dd08aeb37f8e728b8dad error: Server does not allow request for unadvertised object 3b18e512dba79e4c8300dd08aeb37f8e728b8dad error: Server does not allow request for unadvertised object 3b18e512dba79e4c8300dd08aeb37f8e728b8dad error: unable to read sha1 file of hello.txt (3b18e512dba79e4c8300dd08aeb37f8e728b8dad) error: Server does not allow request for unadvertised object 040ee0a2fbdbc63fc4eb04563cad44496de2f2ca error: Server does not allow request for unadvertised object 040ee0a2fbdbc63fc4eb04563cad44496de2f2ca error: unable to read sha1 file of src/hello.go (040ee0a2fbdbc63fc4eb04563cad44496de2f2ca) fatal: unable to checkout working tree warning: Clone succeeded, but checkout failed. Gerrit uses jgit, I guess this error is related to jgit. Is the error caused by the lack of these two changes [1][2]? [1]https://git.eclipse.org/r/c/jgit/jgit/+/180276 [2]https://git.eclipse.org/r/c/jgit/jgit/+/180794
(In reply to Longping Tang from comment #8) > (In reply to Matthias Sohn from comment #7) > > (In reply to Longping Tang from comment #6) > > > (In reply to Matthias Sohn from comment #5) > > > > These changes are still in review hence no existing Gerrit release has them > > > > included. > > > > > > Thank you for your response. > > > > > > Is there any way to make gerrit 3.0.1 support partial clone now? > > > > You should ask this question on the gerrit mailing list [1]. > > Gerrit 3.0 is EOL since Dec 1, 2020 [2]. So I think your best way forward is > > to upgrade Gerrit to a supported release, 3.4.5, 3.5.2 or 3.6.1 [3]. Always > > upgrade to the latest service release to benefit from all bug fixes and > > improvements. > > I have asked the question a few days ago, but no reply. > [1] https://groups.google.com/g/repo-discuss/c/fJvdpyEGoYg > > > > > Do I have to update jgit in order to support partial clone? > > > > Which features of partial cloning are you looking for ? > > > I want to use the --filter=blob:none option. > > I tried to enable partial clone for my gerrit server with the below > configuration: > git config --global uploadpack.allowAnySHA1InWant true > git config --global uploadPack.allowFilter true > > Doing partial clone with command: git clone --filter=blob:none > ssh://GERRIT_SERVER/a/test. > > clone works fine, but checkout gives an error: > > error: Server does not allow request for unadvertised object > 040ee0a2fbdbc63fc4eb04563cad44496de2f2ca > error: Server does not allow request for unadvertised object > 3b18e512dba79e4c8300dd08aeb37f8e728b8dad > error: Server does not allow request for unadvertised object > 3b18e512dba79e4c8300dd08aeb37f8e728b8dad > error: Server does not allow request for unadvertised object > 3b18e512dba79e4c8300dd08aeb37f8e728b8dad > error: unable to read sha1 file of hello.txt > (3b18e512dba79e4c8300dd08aeb37f8e728b8dad) > error: Server does not allow request for unadvertised object > 040ee0a2fbdbc63fc4eb04563cad44496de2f2ca > error: Server does not allow request for unadvertised object > 040ee0a2fbdbc63fc4eb04563cad44496de2f2ca > error: unable to read sha1 file of src/hello.go > (040ee0a2fbdbc63fc4eb04563cad44496de2f2ca) > fatal: unable to checkout working tree > warning: Clone succeeded, but checkout failed. > > Gerrit uses jgit, I guess this error is related to jgit. Is the error caused > by the lack of these two changes [1][2]? > [1]https://git.eclipse.org/r/c/jgit/jgit/+/180276 > [2]https://git.eclipse.org/r/c/jgit/jgit/+/180794 You are right, To support partial clone, jgit should call uploadPack.setRequestPolicy(UploadPack.RequestPolicy.ANY); This has been verified at my team, we use our own compiled version of jgit which is able to support partial clone. I've searched for gerrit's code and it looks like there is no part to modify the RequestPolicy of uploadPack. > git config --global uploadpack.allowAnySHA1InWant true > git config --global uploadPack.allowFilter true These didn't work because my patches were not merged into the jgit trunk yet. It looks like my patches conflict with the master branch, I will update them.
(In reply to Longping Tang from comment #8) > (In reply to Matthias Sohn from comment #7) > > (In reply to Longping Tang from comment #6) > > > (In reply to Matthias Sohn from comment #5) > > > > These changes are still in review hence no existing Gerrit release has them > > > > included. > > > > > > Thank you for your response. > > > > > > Is there any way to make gerrit 3.0.1 support partial clone now? > > > > You should ask this question on the gerrit mailing list [1]. > > Gerrit 3.0 is EOL since Dec 1, 2020 [2]. So I think your best way forward is > > to upgrade Gerrit to a supported release, 3.4.5, 3.5.2 or 3.6.1 [3]. Always > > upgrade to the latest service release to benefit from all bug fixes and > > improvements. > > I have asked the question a few days ago, but no reply. > [1] https://groups.google.com/g/repo-discuss/c/fJvdpyEGoYg > > > > > Do I have to update jgit in order to support partial clone? > > > > Which features of partial cloning are you looking for ? > > > I want to use the --filter=blob:none option. > > I tried to enable partial clone for my gerrit server with the below > configuration: > git config --global uploadpack.allowAnySHA1InWant true > git config --global uploadPack.allowFilter true > > Doing partial clone with command: git clone --filter=blob:none > ssh://GERRIT_SERVER/a/test. > > clone works fine, but checkout gives an error: > > error: Server does not allow request for unadvertised object > 040ee0a2fbdbc63fc4eb04563cad44496de2f2ca > error: Server does not allow request for unadvertised object > 3b18e512dba79e4c8300dd08aeb37f8e728b8dad > error: Server does not allow request for unadvertised object > 3b18e512dba79e4c8300dd08aeb37f8e728b8dad > error: Server does not allow request for unadvertised object > 3b18e512dba79e4c8300dd08aeb37f8e728b8dad > error: unable to read sha1 file of hello.txt > (3b18e512dba79e4c8300dd08aeb37f8e728b8dad) > error: Server does not allow request for unadvertised object > 040ee0a2fbdbc63fc4eb04563cad44496de2f2ca > error: Server does not allow request for unadvertised object > 040ee0a2fbdbc63fc4eb04563cad44496de2f2ca > error: unable to read sha1 file of src/hello.go > (040ee0a2fbdbc63fc4eb04563cad44496de2f2ca) > fatal: unable to checkout working tree > warning: Clone succeeded, but checkout failed. > > Gerrit uses jgit, I guess this error is related to jgit. Is the error caused > by the lack of these two changes [1][2]? > [1]https://git.eclipse.org/r/c/jgit/jgit/+/180276 > [2]https://git.eclipse.org/r/c/jgit/jgit/+/180794 Or you can try to implement gerrit's interface UploadPackInitializer. Try to execute uploadPack.setRequestPolicy(UploadPack.RequestPolicy.ANY); in method com.google.gerrit.server.git.UploadPackInitializer#init(Project.NameKey project, UploadPack uploadPack);
*** Bug 580632 has been marked as a duplicate of this bug. ***
Gerrit change https://git.eclipse.org/r/c/jgit/jgit/+/180794 was merged to [master]. Commit: http://git.eclipse.org/c/jgit/jgit.git/commit/?id=d789fe2f4d8a6ca0c22108bed4e6e7a6e96d04dd