Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jgit-dev] Bug 475615 - git clone --depth

Dear all,

I am currently playing around with the JGit source-code and bug 475615 at
https://bugs.eclipse.org/bugs/show_bug.cgi?id=475615
(you can view my experiments made so far at https://github.com/timeraider4u/jgit in the branch
called depth). I have added test cases for the CloneCommand at
https://github.com/timeraider4u/jgit/blob/depth/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java#L659
The Git repository which is set-up and used by these JUnit test cases can also be found at
https://github.com/timeraider4u/jgit_test_repo I have found a description of the GIT protocol at
https://github.com/git/git/blob/master/Documentation/technical/pack-protocol.txt#L243
and https://github.com/git/git/blob/master/Documentation/technical/shallow.txt You can also use
GIT_TRACE_PACKET=1 git clone -b master --depth 2 https://github.com/timeraider4u/jgit_test_repo.git
to print some debugging information about the Git server-client transfer protocol. But, unfortunately, now I am stuck when I am trying to read the server response
"shallow <GIT_COMMIT_SHA1_HASH>" an exception is thrown.
Seems like I am missing some very important point...

So to be more concrete: In /org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackFetchConnection.java
in the method "private boolean sendWants(final Collection<Ref> want) throws IOException {"
after the following piece of code
line.append("want "); //$NON-NLS-1$
line.append(objectId.name());
if (first) {
line.append(enableCapabilities());
first = false;
}
line.append('\n');

I have added the following (depth is just an integer that is set in CloneCommand.java and then passed through):
if (depth != Transport.DEPTH_INFINITE) {
line.append("deepen "); //$NON-NLS-1$
line.append(depth);
line.append('\n');
}

which gives me the following (with some additional System.out debug info):
main: BasePackFetchConnection.sendWants.line='want c21676d47a0f506cfa26596c5bb8f33430603054 no-progress ofs-delta multi_ack_detailed thin-pack side-band-64k agent=JGit/unknown'
main: BasePackFetchConnection.sendWants.line='deepen 2'
main: PacketLineOut.end.flushOnEnd

So it is sent correctly from client side. But then I get the following StackTrace:
org.eclipse.jgit.errors.PackProtocolException: Expected ACK/NAK, got: shallow 9007666656678b23b58b5d88ec76107a9948c006
at org.eclipse.jgit.transport.PacketLineIn.readACK(PacketLineIn.java:148)
at org.eclipse.jgit.transport.BasePackFetchConnection.negotiate(BasePackFetchConnection.java:748)
at org.eclipse.jgit.transport.BasePackFetchConnection.doFetch(BasePackFetchConnection.java:374)
at org.eclipse.jgit.transport.BasePackFetchConnection.fetch(BasePackFetchConnection.java:314)
at org.eclipse.jgit.transport.BasePackFetchConnection.fetch(BasePackFetchConnection.java:303)
at org.eclipse.jgit.transport.FetchProcess.fetchObjects(FetchProcess.java:277)
at org.eclipse.jgit.transport.FetchProcess.executeImp(FetchProcess.java:177)
at org.eclipse.jgit.transport.FetchProcess.execute(FetchProcess.java:123)
at org.eclipse.jgit.transport.Transport.fetch(Transport.java:1290)
at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:237)
at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:318)
at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:193)
at org.eclipse.jgit.api.CloneCommandTest.testCloneRepositoryWithDepth2(CloneCommandTest.java:817)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
JGit-Upload-Pack: RevWalk.next.pending='class org.eclipse.jgit.revwalk.StartGenerator'
JGit-Upload-Pack: RevWalk.next.pending='class org.eclipse.jgit.revwalk.DepthGenerator'
JGit-Upload-Pack: RevWalk.next.pending='class org.eclipse.jgit.revwalk.DepthGenerator'
java.io.IOException: Pipe closed
at java.io.PipedInputStream.checkStateForReceive(PipedInputStream.java:260)
at java.io.PipedInputStream.receive(PipedInputStream.java:226)
at java.io.PipedOutputStream.write(PipedOutputStream.java:149)
at org.eclipse.jgit.transport.UploadPack$ResponseBufferedOutputStream.write(UploadPack.java:1608)
at org.eclipse.jgit.transport.SideBandOutputStream.writeBuffer(SideBandOutputStream.java:171)
at org.eclipse.jgit.transport.SideBandOutputStream.flushBuffer(SideBandOutputStream.java:127)
at org.eclipse.jgit.transport.SideBandOutputStream.flush(SideBandOutputStream.java:132)
at org.eclipse.jgit.internal.storage.pack.PackOutputStream.flush(PackOutputStream.java:136)
at org.eclipse.jgit.internal.storage.pack.PackWriter.writePack(PackWriter.java:1083)
at org.eclipse.jgit.transport.UploadPack.sendPack(UploadPack.java:1557)
at org.eclipse.jgit.transport.UploadPack.sendPack(UploadPack.java:1406)
at org.eclipse.jgit.transport.UploadPack.service(UploadPack.java:785)
at org.eclipse.jgit.transport.UploadPack.upload(UploadPack.java:674)
at org.eclipse.jgit.transport.InternalFetchConnection$2.run(InternalFetchConnection.java:94)



Hope someone can help me!


Best wishes,


Harald.




Back to the top