All of lore.kernel.org
 help / color / mirror / Atom feed
* Retrospectively add alternates to a repository?
@ 2010-02-26 23:54 Steve Folly
  2010-02-27  2:37 ` Tay Ray Chuan
  0 siblings, 1 reply; 7+ messages in thread
From: Steve Folly @ 2010-02-26 23:54 UTC (permalink / raw)
  To: git

Hi,

I have a local mirror of a remote repository (to save time
cloning over a slow network).  But before I created the
local mirror I already cloned the remote repo directly.

Is it possible to retrospectively add an alternates spec
to this local repository (the equivalent of doing what 
--reference does during the clone)?

Thanks for any help.

Regards,
Steve

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Retrospectively add alternates to a repository?
  2010-02-26 23:54 Retrospectively add alternates to a repository? Steve Folly
@ 2010-02-27  2:37 ` Tay Ray Chuan
  2010-02-27  8:34   ` Jeff King
  0 siblings, 1 reply; 7+ messages in thread
From: Tay Ray Chuan @ 2010-02-27  2:37 UTC (permalink / raw)
  To: Steve Folly; +Cc: git

Hi,

On Sat, Feb 27, 2010 at 7:54 AM, Steve Folly <steve@spfweb.co.uk> wrote:
> I have a local mirror of a remote repository (to save time
> cloning over a slow network).  But before I created the
> local mirror I already cloned the remote repo directly.
>
> Is it possible to retrospectively add an alternates spec
> to this local repository (the equivalent of doing what
> --reference does during the clone)?

yes, just make sure the objects/info/alternates file points to the
location of that cloned repo's object directory; for example:

  $ echo /path/to/cloned/repo/.git/objects > .git/objects/info/alternates

-- 
Cheers,
Ray Chuan

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Retrospectively add alternates to a repository?
  2010-02-27  2:37 ` Tay Ray Chuan
@ 2010-02-27  8:34   ` Jeff King
  2010-02-27 11:43     ` Steve Folly
  0 siblings, 1 reply; 7+ messages in thread
From: Jeff King @ 2010-02-27  8:34 UTC (permalink / raw)
  To: Tay Ray Chuan; +Cc: Steve Folly, git

On Sat, Feb 27, 2010 at 10:37:25AM +0800, Tay Ray Chuan wrote:

> yes, just make sure the objects/info/alternates file points to the
> location of that cloned repo's object directory; for example:
> 
>   $ echo /path/to/cloned/repo/.git/objects > .git/objects/info/alternates

You will probably want to then get rid of anything in the child that is
now available in the alternates repository.

I would have thought "git repack -adl" works, but I think there is
something a little funny in the logic. It reports "nothing new to pack",
but does not delete the loose objects. But packing first then worked:

  $ git clone large-parent child
  $ echo $PWD/large-parent/.git/objects >child/.git/objects/info/alternates
  $ cd child

  $ du -sh .git/objects
  51M     .git/objects

  $ git repack -adl && du -sh .git/objects
  Nothing new to pack.
  51M     .git/objects

  $ git repack -ad && du -sh .git/objects
  Counting objects: 3, done.
  Delta compression using up to 2 threads.
  Compressing objects: 100% (2/2), done.
  Writing objects: 100% (3/3), done.
  Total 3 (delta 0), reused 0 (delta 0)
  51M     .git/objects

  $ git repack -adl && du -sh .git/objects
  Nothing new to pack.
  20K     .git/objects

-Peff

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Retrospectively add alternates to a repository?
  2010-02-27  8:34   ` Jeff King
@ 2010-02-27 11:43     ` Steve Folly
  2010-02-27 12:30       ` Jeff King
  0 siblings, 1 reply; 7+ messages in thread
From: Steve Folly @ 2010-02-27 11:43 UTC (permalink / raw)
  To: git

Jeff King <peff <at> peff.net> writes:

> 
> On Sat, Feb 27, 2010 at 10:37:25AM +0800, Tay Ray Chuan wrote:
> 
> > yes, just make sure the objects/info/alternates file points to the
> > location of that cloned repo's object directory; for example:
> > 
> >   $ echo /path/to/cloned/repo/.git/objects > .git/objects/info/alternates
> 
> You will probably want to then get rid of anything in the child that is
> now available in the alternates repository.
> 
> I would have thought "git repack -adl" works, but I think there is
> something a little funny in the logic. It reports "nothing new to pack",
> but does not delete the loose objects. But packing first then worked:
> 
>   $ git clone large-parent child
>   $ echo $PWD/large-parent/.git/objects >child/.git/objects/info/alternates
>   $ cd child
> 
>   $ du -sh .git/objects
>   51M     .git/objects
> 
>   $ git repack -adl && du -sh .git/objects
>   Nothing new to pack.
>   51M     .git/objects
> 
>   $ git repack -ad && du -sh .git/objects
>   Counting objects: 3, done.
>   Delta compression using up to 2 threads.
>   Compressing objects: 100% (2/2), done.
>   Writing objects: 100% (3/3), done.
>   Total 3 (delta 0), reused 0 (delta 0)
>   51M     .git/objects
> 
>   $ git repack -adl && du -sh .git/objects
>   Nothing new to pack.
>   20K     .git/objects
> 
> -Peff
> 

Excellent, this is exactly what I need. Thanks very much Tay
 and Jeff.

I now have a plan to write a script to attach and
detach repositories to and from local mirrors on demand:

attach = 
    echo "/path/to/mirror" > .git/objects/info/alternates && 
    git repack -adl && 
    git repack -ad && 
    git repack -adl

detach = 
    git repack -a && 
    rm .git/objects/info/alternates


Cheers,
Steve

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Retrospectively add alternates to a repository?
  2010-02-27 11:43     ` Steve Folly
@ 2010-02-27 12:30       ` Jeff King
  2010-05-16 13:55         ` Felipe Contreras
  0 siblings, 1 reply; 7+ messages in thread
From: Jeff King @ 2010-02-27 12:30 UTC (permalink / raw)
  To: Steve Folly; +Cc: git

On Sat, Feb 27, 2010 at 11:43:55AM +0000, Steve Folly wrote:

> I now have a plan to write a script to attach and
> detach repositories to and from local mirrors on demand:

I think they should work, but:

> attach = 
>     echo "/path/to/mirror" > .git/objects/info/alternates && 
>     git repack -adl && 
>     git repack -ad && 
>     git repack -adl

I don't think the first repack is doing anything (I showed it in my
example only to show that it was not actually working).

-Peff

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Retrospectively add alternates to a repository?
  2010-02-27 12:30       ` Jeff King
@ 2010-05-16 13:55         ` Felipe Contreras
  2010-05-22  5:38           ` Jeff King
  0 siblings, 1 reply; 7+ messages in thread
From: Felipe Contreras @ 2010-05-16 13:55 UTC (permalink / raw)
  To: Jeff King; +Cc: Steve Folly, git

On Sat, Feb 27, 2010 at 3:30 PM, Jeff King <peff@peff.net> wrote:
> On Sat, Feb 27, 2010 at 11:43:55AM +0000, Steve Folly wrote:
>> attach =
>>     echo "/path/to/mirror" > .git/objects/info/alternates &&
>>     git repack -adl &&
>>     git repack -ad &&
>>     git repack -adl
>
> I don't think the first repack is doing anything (I showed it in my
> example only to show that it was not actually working).

That's a bug, isn't it? Has anyone taken a look into it?

-- 
Felipe Contreras

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Retrospectively add alternates to a repository?
  2010-05-16 13:55         ` Felipe Contreras
@ 2010-05-22  5:38           ` Jeff King
  0 siblings, 0 replies; 7+ messages in thread
From: Jeff King @ 2010-05-22  5:38 UTC (permalink / raw)
  To: Felipe Contreras; +Cc: Steve Folly, git

On Sun, May 16, 2010 at 04:55:21PM +0300, Felipe Contreras wrote:

> On Sat, Feb 27, 2010 at 3:30 PM, Jeff King <peff@peff.net> wrote:
> > On Sat, Feb 27, 2010 at 11:43:55AM +0000, Steve Folly wrote:
> >> attach =
> >>     echo "/path/to/mirror" > .git/objects/info/alternates &&
> >>     git repack -adl &&
> >>     git repack -ad &&
> >>     git repack -adl
> >
> > I don't think the first repack is doing anything (I showed it in my
> > example only to show that it was not actually working).
> 
> That's a bug, isn't it? Has anyone taken a look into it?

Yes, it's a bug. I don't think anybody is looking at it. I started to
write a length explanation, but the more I thought about it, the more I
am not actually sure what is going on. So please, if you are interested,
take a look and see if you can come up with a patch.

-Peff

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-05-22  5:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-26 23:54 Retrospectively add alternates to a repository? Steve Folly
2010-02-27  2:37 ` Tay Ray Chuan
2010-02-27  8:34   ` Jeff King
2010-02-27 11:43     ` Steve Folly
2010-02-27 12:30       ` Jeff King
2010-05-16 13:55         ` Felipe Contreras
2010-05-22  5:38           ` Jeff King

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.