{"thread":{"id":"10725","subject":"[PATCH 4/3] git-fetch: test avoiding unnecessary copying from alternates","startedAt":"2007-11-08T08:22:13Z","lastAt":"2007-11-08T08:34:40Z","messageCount":2,"participants":["Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"58824","messageId":"20071108082213.GA17054@spearce.org","threadId":"10725","inReplyTo":null,"subject":"[PATCH 4/3] git-fetch: test avoiding unnecessary copying from alternates","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-11-08T08:22:13Z","receivedAt":"2007-11-08T08:22:13Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"This test verifies my prior \"avoid local fetching from alternate\"\npatch is functional and doesn't regress in the future during any\nadditional improvements made to git.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n t/t5502-quickfetch.sh |   33 +++++++++++++++++++++++++++++++++\n 1 files changed, 33 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t5502-quickfetch.sh b/t/t5502-quickfetch.sh\nindex b4760f2..16eadd6 100755\n--- a/t/t5502-quickfetch.sh\n+++ b/t/t5502-quickfetch.sh\n@@ -86,4 +86,37 @@ test_expect_success 'quickfetch should not leave a corrupted repository' '\n \n '\n \n+test_expect_success 'quickfetch should not copy from alternate' '\n+\n+\t(\n+\t\tmkdir quickclone &&\n+\t\tcd quickclone &&\n+\t\tgit init-db &&\n+\t\t(cd ../.git/objects && pwd) >.git/objects/info/alternates &&\n+\t\tgit remote add origin .. &&\n+\t\tgit fetch -k -k\n+\t) &&\n+\tobj_cnt=$( (\n+\t\tcd quickclone &&\n+\t\tgit count-objects | sed -e \"s/ *objects,.*//\"\n+\t) ) &&\n+\tpck_cnt=$( (\n+\t\tcd quickclone &&\n+\t\tgit count-objects -v | sed -n -e \"/packs:/{\n+\t\t\t\ts/packs://\n+\t\t\t\tp\n+\t\t\t\tq\n+\t\t\t}\"\n+\t) ) &&\n+\torigin_master=$( (\n+\t\tcd quickclone &&\n+\t\tgit rev-parse origin/master\n+\t) ) &&\n+\techo \"loose objects: $obj_cnt, packfiles: $pck_cnt\" &&\n+\ttest $obj_cnt -eq 0 &&\n+\ttest $pck_cnt -eq 0 &&\n+\ttest z$origin_master = z$(git rev-parse master)\n+\n+'\n+\n test_done\n-- \n1.5.3.5.1590.gfadfad\n"},{"id":"58830","messageId":"20071108083440.GK14735@spearce.org","threadId":"10725","inReplyTo":"20071108082213.GA17054@spearce.org","subject":"Re: [PATCH 4/3] git-fetch: test avoiding unnecessary copying from alternates","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-11-08T08:34:40Z","receivedAt":"2007-11-08T08:34:40Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"\"Shawn O. Pearce\" <spearce@spearce.org> wrote:\n> This test verifies my prior \"avoid local fetching from alternate\"\n> patch is functional and doesn't regress in the future during any\n> additional improvements made to git.\n...\n> +test_expect_success 'quickfetch should not copy from alternate' '\n> +\n> +\t(\n> +\t\tmkdir quickclone &&\n> +\t\tcd quickclone &&\n> +\t\tgit init-db &&\n> +\t\t(cd ../.git/objects && pwd) >.git/objects/info/alternates &&\n> +\t\tgit remote add origin .. &&\n> +\t\tgit fetch -k -k\n\nHmmph.  On second thought I think this is a little sketchy for\na test.  Versions without my quickfetch patch fail this test and\nversions with it pass.  But it depends on the implementation of\n`-k -k` to always call index-pack over unpack-objects.\n\nI'm using -k -k here to ensure we keep the pack fetched as we're only\nfetching 6 objects and they are already reachable in the quickclone\nrepository thanks to the alternate ODB.  If we use unpack-objects\nduring this fetch we will still pass this test because the objects\nwon't be unpacked if they are already reachable locally.\n\nOf course this test is for a performance optimization.  For 6\ntiny objects it really doesn't matter if we copy them or not, or\nif we copy them over a pipe only to discard them because they are\nalready reachable.  It does however matter when you are talking\nabout nearly 300MB worth of objects.  :-\\\n\n-- \nShawn.\n"}]}