Merge branch 'jt/fetch-tips-in-partial-clone'
authorJunio C Hamano <gitster@pobox.com>
Fri, 19 Oct 2018 04:34:04 +0000 (13:34 +0900)
committerJunio C Hamano <gitster@pobox.com>
Fri, 19 Oct 2018 04:34:04 +0000 (13:34 +0900)
"git fetch $repo $object" in a partial clone did not correctly
fetch the asked-for object that is referenced by an object in
promisor packfile, which has been fixed.

* jt/fetch-tips-in-partial-clone:
fetch: in partial clone, check presence of targets
connected: document connectivity in partial clones

1  2 
t/t5616-partial-clone.sh
diff --combined t/t5616-partial-clone.sh
index 6ff6146923d945d9514ad5871b845969c2efb269,359d27d0292657fdf956147705cc2da4ee15c398..6391437529ca7c4f742d2668fdefc77df1112743
@@@ -34,12 -34,10 +34,12 @@@ test_expect_success 'setup bare clone f
  # confirm partial clone was registered in the local config.
  test_expect_success 'do partial clone 1' '
        git clone --no-checkout --filter=blob:none "file://$(pwd)/srv.bare" pc1 &&
 -      git -C pc1 rev-list HEAD --quiet --objects --missing=print \
 -              | awk -f print_1.awk \
 -              | sed "s/?//" \
 -              | sort >observed.oids &&
 +
 +      git -C pc1 rev-list --quiet --objects --missing=print HEAD >revs &&
 +      awk -f print_1.awk revs |
 +      sed "s/?//" |
 +      sort >observed.oids &&
 +
        test_cmp expect_1.oids observed.oids &&
        test "$(git -C pc1 config --local core.repositoryformatversion)" = "1" &&
        test "$(git -C pc1 config --local extensions.partialclone)" = "origin" &&
  
  # checkout master to force dynamic object fetch of blobs at HEAD.
  test_expect_success 'verify checkout with dynamic object fetch' '
 -      git -C pc1 rev-list HEAD --quiet --objects --missing=print >observed &&
 +      git -C pc1 rev-list --quiet --objects --missing=print HEAD >observed &&
        test_line_count = 4 observed &&
        git -C pc1 checkout master &&
 -      git -C pc1 rev-list HEAD --quiet --objects --missing=print >observed &&
 +      git -C pc1 rev-list --quiet --objects --missing=print HEAD >observed &&
        test_line_count = 0 observed
  '
  
@@@ -74,8 -72,7 +74,8 @@@ test_expect_success 'push new commits t
  # have the new blobs.
  test_expect_success 'partial fetch inherits filter settings' '
        git -C pc1 fetch origin &&
 -      git -C pc1 rev-list master..origin/master --quiet --objects --missing=print >observed &&
 +      git -C pc1 rev-list --quiet --objects --missing=print \
 +              master..origin/master >observed &&
        test_line_count = 5 observed
  '
  
@@@ -83,8 -80,7 +83,8 @@@
  # we should only get 1 new blob (for the file in origin/master).
  test_expect_success 'verify diff causes dynamic object fetch' '
        git -C pc1 diff master..origin/master -- file.1.txt &&
 -      git -C pc1 rev-list master..origin/master --quiet --objects --missing=print >observed &&
 +      git -C pc1 rev-list --quiet --objects --missing=print \
 +               master..origin/master >observed &&
        test_line_count = 4 observed
  '
  
@@@ -93,8 -89,7 +93,8 @@@
  test_expect_success 'verify blame causes dynamic object fetch' '
        git -C pc1 blame origin/master -- file.1.txt >observed.blame &&
        test_cmp expect.blame observed.blame &&
 -      git -C pc1 rev-list master..origin/master --quiet --objects --missing=print >observed &&
 +      git -C pc1 rev-list --quiet --objects --missing=print \
 +              master..origin/master >observed &&
        test_line_count = 0 observed
  '
  
@@@ -114,8 -109,7 +114,8 @@@ test_expect_success 'push new commits t
  # Verify we have all the new blobs.
  test_expect_success 'override inherited filter-spec using --no-filter' '
        git -C pc1 fetch --no-filter origin &&
 -      git -C pc1 rev-list master..origin/master --quiet --objects --missing=print >observed &&
 +      git -C pc1 rev-list --quiet --objects --missing=print \
 +              master..origin/master >observed &&
        test_line_count = 0 observed
  '
  
@@@ -136,22 -130,16 +136,22 @@@ test_expect_success 'push new commits t
  # perhaps combined with a command in dry-run mode.
  test_expect_success 'manual prefetch of missing objects' '
        git -C pc1 fetch --filter=blob:none origin &&
 -      git -C pc1 rev-list master..origin/master --quiet --objects --missing=print \
 -              | awk -f print_1.awk \
 -              | sed "s/?//" \
 -              | sort >observed.oids &&
 +
 +      git -C pc1 rev-list --quiet --objects --missing=print \
 +               master..origin/master >revs &&
 +      awk -f print_1.awk revs |
 +      sed "s/?//" |
 +      sort >observed.oids &&
 +
        test_line_count = 6 observed.oids &&
        git -C pc1 fetch-pack --stdin "file://$(pwd)/srv.bare" <observed.oids &&
 -      git -C pc1 rev-list master..origin/master --quiet --objects --missing=print \
 -              | awk -f print_1.awk \
 -              | sed "s/?//" \
 -              | sort >observed.oids &&
 +
 +      git -C pc1 rev-list --quiet --objects --missing=print \
 +              master..origin/master >revs &&
 +      awk -f print_1.awk revs |
 +      sed "s/?//" |
 +      sort >observed.oids &&
 +
        test_line_count = 0 observed.oids
  '
  
@@@ -182,6 -170,23 +182,23 @@@ test_expect_success 'partial clone fetc
        git -C dst fsck
  '
  
+ test_expect_success 'fetch what is specified on CLI even if already promised' '
+       rm -rf src dst.git &&
+       git init src &&
+       test_commit -C src foo &&
+       test_config -C src uploadpack.allowfilter 1 &&
+       test_config -C src uploadpack.allowanysha1inwant 1 &&
+       git hash-object --stdin <src/foo.t >blob &&
+       git clone --bare --filter=blob:none "file://$(pwd)/src" dst.git &&
+       git -C dst.git rev-list --objects --quiet --missing=print HEAD >missing_before &&
+       grep "?$(cat blob)" missing_before &&
+       git -C dst.git fetch origin $(cat blob) &&
+       git -C dst.git rev-list --objects --quiet --missing=print HEAD >missing_after &&
+       ! grep "?$(cat blob)" missing_after
+ '
  . "$TEST_DIRECTORY"/lib-httpd.sh
  start_httpd
  
@@@ -206,7 -211,7 +223,7 @@@ test_expect_success 'upon cloning, chec
  
        # Craft a packfile not including that blob.
        git -C "$SERVER" rev-parse HEAD |
 -              git -C "$SERVER" pack-objects --stdout >incomplete.pack &&
 +      git -C "$SERVER" pack-objects --stdout >incomplete.pack &&
  
        # Replace the existing packfile with the crafted one. The protocol
        # requires that the packfile be sent in sideband 1, hence the extra