]> source.dussan.org Git - jgit.git/commitdiff
Respect "unshallow" lines in protocol v2 04/124804/2
authorJonathan Nieder <jrn@google.com>
Thu, 21 Jun 2018 04:19:11 +0000 (21:19 -0700)
committerJonathan Nieder <jrn@google.com>
Thu, 21 Jun 2018 04:20:41 +0000 (21:20 -0700)
If I run

 git config --global protocol.version 2
 mkdir repo
 cd repo
 git init --bare
 git remote add origin https://go.googlesource.com/proposal
 git fetch --depth=1
 git fetch --unshallow

then I expect to have a full history, just as though I had fetched
without --depth in the first place.  Instead, it reports success
but does not fetch enough objects:

 $ git fsck
 notice: HEAD points to an unborn branch (master)
 Checking object directories: 100% (256/256), done.
 Checking objects: 100% (468/468), done.
 broken link from  commit 2c6bc83f234085c8eadb7ea33405ce6223c44d1b
               to  commit 878975cf2b600675b4c905e5d9591bd24541ae9e
 missing commit 878975cf2b600675b4c905e5d9591bd24541ae9e
 dangling commit 314be00dae78dd526851f5635e6349014e2ad0c2

The false success indicates problems in the client and the server.
Git 2.18-rc2 (the client) ought to have been more defensive, noticing
the incomplete history.  The greater error is in JGit (the server),
which neglects to send the objects requested.

When serving protocol v0 requests, JGit sends the correct objects by
taking unshallowCommits into account when generating the pack to send
to the client.  Do the same in the protocol v2 code path.  I forgot to
do this in v5.0.0.201806050710-rc3~6 (Teach UploadPack shallow fetch
in protocol v2, 2018-03-15).

Reported-by: Russ Cox <rsc@golang.org>
Change-Id: I282b45f47616a641b9e8d6210b4a070d3efdbb9b
Signed-off-by: Jonathan Nieder <jrn@google.com>
org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java

index f70ead9294af047bfe19c3275a40efbb2a46fc47..7de0506bb3d6d44749b6388e6abb26f93f6a6f1e 100644 (file)
@@ -1082,7 +1082,7 @@ public class UploadPack {
                                        includeTag
                                                ? db.getRefDatabase().getRefsByPrefix(R_TAGS)
                                                : null,
-                                       new ArrayList<ObjectId>());
+                                       unshallowCommits);
                }
                pckOut.end();
        }