@matheusbsbs / matheus-bagliano / commits / 85f77eadcc
Fork 0

git-gui: Copy objects/info/alternates during standard clone

If the source repository is using an objects/info/alternates file we need to copy the file to our new repository so that it can access any objects that won't be copied/hardlinked as they are stored in the alternate location. We explicitly resolve all paths in the objects/info/alternates as relative to the source repository but then convert them into an absolute path for the new clone. This allows the new clone to access the exact same locaton as the source repository, even if relative paths had been used before. Under Cygwin we assume that Git is Cygwin based and that the paths in objects/info/alternates must be valid Cygwin UNIX paths, so we need to run `cygpath --unix` on each line in the alternate list. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed Sep 24, 2007 at 08:50 UTC 85f77eadcc1d6e5a62079ab86988ffe95e9421d5
1 file changed +26
lib/choose_repository.tcl
+26
@@ -470,6 +470,32 @@ method _do_clone2 {} {
470 [mc "buckets"]
471 update
472
473 + if {[file exists [file join $objdir info alternates]]} {
474 + set pwd [pwd]
475 + if {[catch {
476 + file mkdir [gitdir objects info]
477 + set f_in [open [file join $objdir info alternates] r]
478 + set f_cp [open [gitdir objects info alternates] w]
479 + fconfigure $f_in -translation binary -encoding binary
480 + fconfigure $f_cp -translation binary -encoding binary
481 + cd $objdir
482 + while {[gets $f_in line] >= 0} {
483 + if {[is_Cygwin]} {
484 + puts $f_cp [exec cygpath --unix --absolute $line]
485 + } else {
486 + puts $f_cp [file normalize $line]
487 + }
488 + }
489 + close $f_in
490 + close $f_cp
491 + cd $pwd
492 + } err]} {
493 + catch {cd $pwd}
494 + _clone_failed $this [mc "Unable to copy objects/info/alternates: %s" $err]
495 + return
496 + }
497 + }
498 +
499 set tolink [list]
500 set buckets [glob \
501 -tails \