git-gui: Copy objects/info/alternates during standard clone
[gitweb.git] / lib / choose_repository.tcl
index 4ad1f781f77357d3da8566cc261a0cc3b2cced72..f7b8c930950d85f94f38e211ce7cef4eae8df9f5 100644 (file)
@@ -470,6 +470,32 @@ method _do_clone2 {} {
                        [mc "buckets"]
                update
 
+               if {[file exists [file join $objdir info alternates]]} {
+                       set pwd [pwd]
+                       if {[catch {
+                               file mkdir [gitdir objects info]
+                               set f_in [open [file join $objdir info alternates] r]
+                               set f_cp [open [gitdir objects info alternates] w]
+                               fconfigure $f_in -translation binary -encoding binary
+                               fconfigure $f_cp -translation binary -encoding binary
+                               cd $objdir
+                               while {[gets $f_in line] >= 0} {
+                                       if {[is_Cygwin]} {
+                                               puts $f_cp [exec cygpath --unix --absolute $line]
+                                       } else {
+                                               puts $f_cp [file normalize $line]
+                                       }
+                               }
+                               close $f_in
+                               close $f_cp
+                               cd $pwd
+                       } err]} {
+                               catch {cd $pwd}
+                               _clone_failed $this [mc "Unable to copy objects/info/alternates: %s" $err]
+                               return
+                       }
+               }
+
                set tolink  [list]
                set buckets [glob \
                        -tails \