{"thread":{"id":"22838","subject":"Retrospectively add alternates to a repository?","startedAt":"2010-02-26T23:54:07Z","lastAt":"2010-05-22T05:38:46Z","messageCount":7,"participants":["Steve Folly","Tay Ray Chuan","Jeff King","Felipe Contreras"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"135786","messageId":"loom.20100227T004822-959@post.gmane.org","threadId":"22838","inReplyTo":null,"subject":"Retrospectively add alternates to a repository?","fromName":"Steve Folly","fromEmail":"steve@spfweb.co.uk","sentAt":"2010-02-26T23:54:07Z","receivedAt":"2010-02-26T23:54:07Z","isPatch":false,"sender":{"key":"steve@spfweb.co.uk","avatar":null},"body":"Hi,\n\nI have a local mirror of a remote repository (to save time\ncloning over a slow network).  But before I created the\nlocal mirror I already cloned the remote repo directly.\n\nIs it possible to retrospectively add an alternates spec\nto this local repository (the equivalent of doing what \n--reference does during the clone)?\n\nThanks for any help.\n\nRegards,\nSteve\n"},{"id":"135790","messageId":"be6fef0d1002261837g794e8df2yc92261d46f3235bd@mail.gmail.com","threadId":"22838","inReplyTo":"loom.20100227T004822-959@post.gmane.org","subject":"Re: Retrospectively add alternates to a repository?","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2010-02-27T02:37:25Z","receivedAt":"2010-02-27T02:37:25Z","isPatch":false,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"Hi,\n\nOn Sat, Feb 27, 2010 at 7:54 AM, Steve Folly <steve@spfweb.co.uk> wrote:\n> I have a local mirror of a remote repository (to save time\n> cloning over a slow network).  But before I created the\n> local mirror I already cloned the remote repo directly.\n>\n> Is it possible to retrospectively add an alternates spec\n> to this local repository (the equivalent of doing what\n> --reference does during the clone)?\n\nyes, just make sure the objects/info/alternates file points to the\nlocation of that cloned repo's object directory; for example:\n\n  $ echo /path/to/cloned/repo/.git/objects > .git/objects/info/alternates\n\n-- \nCheers,\nRay Chuan\n"},{"id":"135816","messageId":"20100227083418.GC27191@coredump.intra.peff.net","threadId":"22838","inReplyTo":"be6fef0d1002261837g794e8df2yc92261d46f3235bd@mail.gmail.com","subject":"Re: Retrospectively add alternates to a repository?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-02-27T08:34:18Z","receivedAt":"2010-02-27T08:34:18Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sat, Feb 27, 2010 at 10:37:25AM +0800, Tay Ray Chuan wrote:\n\n> yes, just make sure the objects/info/alternates file points to the\n> location of that cloned repo's object directory; for example:\n> \n>   $ echo /path/to/cloned/repo/.git/objects > .git/objects/info/alternates\n\nYou will probably want to then get rid of anything in the child that is\nnow available in the alternates repository.\n\nI would have thought \"git repack -adl\" works, but I think there is\nsomething a little funny in the logic. It reports \"nothing new to pack\",\nbut does not delete the loose objects. But packing first then worked:\n\n  $ git clone large-parent child\n  $ echo $PWD/large-parent/.git/objects >child/.git/objects/info/alternates\n  $ cd child\n\n  $ du -sh .git/objects\n  51M     .git/objects\n\n  $ git repack -adl && du -sh .git/objects\n  Nothing new to pack.\n  51M     .git/objects\n\n  $ git repack -ad && du -sh .git/objects\n  Counting objects: 3, done.\n  Delta compression using up to 2 threads.\n  Compressing objects: 100% (2/2), done.\n  Writing objects: 100% (3/3), done.\n  Total 3 (delta 0), reused 0 (delta 0)\n  51M     .git/objects\n\n  $ git repack -adl && du -sh .git/objects\n  Nothing new to pack.\n  20K     .git/objects\n\n-Peff\n"},{"id":"135820","messageId":"loom.20100227T123539-643@post.gmane.org","threadId":"22838","inReplyTo":"20100227083418.GC27191@coredump.intra.peff.net","subject":"Re: Retrospectively add alternates to a repository?","fromName":"Steve Folly","fromEmail":"steve@spfweb.co.uk","sentAt":"2010-02-27T11:43:55Z","receivedAt":"2010-02-27T11:43:55Z","isPatch":false,"sender":{"key":"steve@spfweb.co.uk","avatar":null},"body":"Jeff King <peff <at> peff.net> writes:\n\n> \n> On Sat, Feb 27, 2010 at 10:37:25AM +0800, Tay Ray Chuan wrote:\n> \n> > yes, just make sure the objects/info/alternates file points to the\n> > location of that cloned repo's object directory; for example:\n> > \n> >   $ echo /path/to/cloned/repo/.git/objects > .git/objects/info/alternates\n> \n> You will probably want to then get rid of anything in the child that is\n> now available in the alternates repository.\n> \n> I would have thought \"git repack -adl\" works, but I think there is\n> something a little funny in the logic. It reports \"nothing new to pack\",\n> but does not delete the loose objects. But packing first then worked:\n> \n>   $ git clone large-parent child\n>   $ echo $PWD/large-parent/.git/objects >child/.git/objects/info/alternates\n>   $ cd child\n> \n>   $ du -sh .git/objects\n>   51M     .git/objects\n> \n>   $ git repack -adl && du -sh .git/objects\n>   Nothing new to pack.\n>   51M     .git/objects\n> \n>   $ git repack -ad && du -sh .git/objects\n>   Counting objects: 3, done.\n>   Delta compression using up to 2 threads.\n>   Compressing objects: 100% (2/2), done.\n>   Writing objects: 100% (3/3), done.\n>   Total 3 (delta 0), reused 0 (delta 0)\n>   51M     .git/objects\n> \n>   $ git repack -adl && du -sh .git/objects\n>   Nothing new to pack.\n>   20K     .git/objects\n> \n> -Peff\n> \n\nExcellent, this is exactly what I need. Thanks very much Tay\n and Jeff.\n\nI now have a plan to write a script to attach and\ndetach repositories to and from local mirrors on demand:\n\nattach = \n    echo \"/path/to/mirror\" > .git/objects/info/alternates && \n    git repack -adl && \n    git repack -ad && \n    git repack -adl\n\ndetach = \n    git repack -a && \n    rm .git/objects/info/alternates\n\n\nCheers,\nSteve\n"},{"id":"135824","messageId":"20100227123056.GA22382@coredump.intra.peff.net","threadId":"22838","inReplyTo":"loom.20100227T123539-643@post.gmane.org","subject":"Re: Retrospectively add alternates to a repository?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-02-27T12:30:57Z","receivedAt":"2010-02-27T12:30:57Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sat, Feb 27, 2010 at 11:43:55AM +0000, Steve Folly wrote:\n\n> I now have a plan to write a script to attach and\n> detach repositories to and from local mirrors on demand:\n\nI think they should work, but:\n\n> attach = \n>     echo \"/path/to/mirror\" > .git/objects/info/alternates && \n>     git repack -adl && \n>     git repack -ad && \n>     git repack -adl\n\nI don't think the first repack is doing anything (I showed it in my\nexample only to show that it was not actually working).\n\n-Peff\n"},{"id":"141771","messageId":"AANLkTin5igmPVoISyyj2DtRV6OWagDq-boBkP6Zqq_z-@mail.gmail.com","threadId":"22838","inReplyTo":"20100227123056.GA22382@coredump.intra.peff.net","subject":"Re: Retrospectively add alternates to a repository?","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2010-05-16T13:55:21Z","receivedAt":"2010-05-16T13:55:21Z","isPatch":false,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Sat, Feb 27, 2010 at 3:30 PM, Jeff King <peff@peff.net> wrote:\n> On Sat, Feb 27, 2010 at 11:43:55AM +0000, Steve Folly wrote:\n>> attach =\n>>     echo \"/path/to/mirror\" > .git/objects/info/alternates &&\n>>     git repack -adl &&\n>>     git repack -ad &&\n>>     git repack -adl\n>\n> I don't think the first repack is doing anything (I showed it in my\n> example only to show that it was not actually working).\n\nThat's a bug, isn't it? Has anyone taken a look into it?\n\n-- \nFelipe Contreras\n"},{"id":"142080","messageId":"20100522053846.GA29118@coredump.intra.peff.net","threadId":"22838","inReplyTo":"AANLkTin5igmPVoISyyj2DtRV6OWagDq-boBkP6Zqq_z-@mail.gmail.com","subject":"Re: Retrospectively add alternates to a repository?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-05-22T05:38:46Z","receivedAt":"2010-05-22T05:38:46Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, May 16, 2010 at 04:55:21PM +0300, Felipe Contreras wrote:\n\n> On Sat, Feb 27, 2010 at 3:30 PM, Jeff King <peff@peff.net> wrote:\n> > On Sat, Feb 27, 2010 at 11:43:55AM +0000, Steve Folly wrote:\n> >> attach =\n> >>     echo \"/path/to/mirror\" > .git/objects/info/alternates &&\n> >>     git repack -adl &&\n> >>     git repack -ad &&\n> >>     git repack -adl\n> >\n> > I don't think the first repack is doing anything (I showed it in my\n> > example only to show that it was not actually working).\n> \n> That's a bug, isn't it? Has anyone taken a look into it?\n\nYes, it's a bug. I don't think anybody is looking at it. I started to\nwrite a length explanation, but the more I thought about it, the more I\nam not actually sure what is going on. So please, if you are interested,\ntake a look and see if you can come up with a patch.\n\n-Peff\n"}]}