git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: More problems...

From
Linus Torvalds <torvalds@osdl.org>
Date
Apr 29, 2005, 20:21 UTC
Message-ID
<Pine.LNX.4.58.0504291311320.18901@ppc970.osdl.org>
In-Reply-To
<20050429195055.GE1233@mythryan2.michonline.com>
On Fri, 29 Apr 2005, Ryan Anderson wrote:
> 
> Why not just use "rsync" for both remote and local synchronization, and
> provide a "relink" command to scan two .git/objects/ repositories and
> hardlink matching files together?

Absolutely. I use the same "git-pull-script" between two local directories on disk. The only issue there is that you have to give the ".git" directory, ie you should do

	git-pull-script ~/by/other/repository/.git
instead of pointing to the other repo's root.
Of course, I don't bother with the linking. But that's the trivial part.
Show 5 quoted lines
> With the SHA1 hash, you can even have a --unsafe option that just
> compares the has names and does a link based purely off of that and the
> stat(2) results of both files.  (I'd expect that a ... safer variant
> would extract both files and compare them, but the --unsafe should be
> sufficient, in practice, I would think.)

I don't think there is any point to unsafe. The assumption is that if you do things this way, the "unlinked" files will the the uncommon case, so what you do is

 - remember the list of files you copied when you did the pull (you had to 
   have this list at some point anyway). Sort by name,
 - create a list of names of both repositories, sorted by name
 - do the union of those three lists (cheap, thanks to the sorting)
 - stat each name to see if it's already linked (which it will be, most of 
   the time), continue to the next one..
 - if they aren't linked, just do a "cmp" on them, and warn if they aren't 
   the same, continue to the next one.
 - else link them.

And if you want to, you can skip the first stage, and just relink two trees without looking at a list of "known new" files - it's going to be expensive to link two big repositories the _first_ time, but hey even the "expensive" part is likely to be pretty cheap in the end. If it takes an hour or two to relink some years of history, big deal. Do it overnight, you only need it once.

		Linus
Previous: Thomas GlanzmannNext: Junio C Hamano
Message 7 of 24 in “More problems...”
  1. Russell KingApr 29, 2005
  2. Russell KingApr 29, 2005
  3. Linus TorvaldsApr 29, 2005
  4. Petr BaudisApr 29, 2005
  5. Ryan AndersonApr 29, 2005
  6. Thomas GlanzmannApr 29, 2005
  7. Linus TorvaldsApr 29, 2005
  8. Junio C HamanoApr 29, 2005
  9. Russell KingApr 29, 2005
  10. Anton AltaparmakovApr 29, 2005
  11. Petr BaudisMay 2, 2005
  12. Dave KleikampMay 2, 2005
  13. Thomas GlanzmannMay 2, 2005
  14. Anton AltaparmakovMay 2, 2005
  15. Linus TorvaldsMay 2, 2005
  16. Petr BaudisMay 3, 2005
  17. Daniel BarkalowMay 3, 2005
  18. Andreas GalMay 3, 2005
  19. Junio C HamanoMay 3, 2005
  20. Daniel BarkalowApr 29, 2005
  21. Junio C HamanoApr 29, 2005
  22. Split out "pull" from particular methodsDaniel Barkalow, Apr 30, 2005
  23. Add git-relink-script, a tool to hardlink two existing repositories.Ryan Anderson, May 4, 2005
  24. Petr BaudisMay 2, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.