@@ -641,8 +641,8 @@ method _do_clone2 {} {
641641 set pwd [pwd ]
642642 if {[catch {
643643 file mkdir [gitdir objects info]
644- set f_in [open [file join $objdir info alternates] r]
645- set f_cp [open [gitdir objects info alternates] w]
644+ set f_in [safe_open_file [file join $objdir info alternates] r]
645+ set f_cp [safe_open_file [gitdir objects info alternates] w]
646646 fconfigure $f_in -translation binary -encoding binary
647647 fconfigure $f_cp -translation binary -encoding binary
648648 cd $objdir
@@ -727,7 +727,7 @@ method _do_clone2 {} {
727727 [cb _do_clone_tags]
728728 }
729729 shared {
730- set fd [open [gitdir objects info alternates] w]
730+ set fd [safe_open_file [gitdir objects info alternates] w]
731731 fconfigure $fd -translation binary
732732 puts $fd $objdir
733733 close $fd
@@ -760,8 +760,8 @@ method _copy_files {objdir tocopy} {
760760 }
761761 foreach p $tocopy {
762762 if {[catch {
763- set f_in [open [file join $objdir $p ] r]
764- set f_cp [open [file join .git objects $p ] w]
763+ set f_in [safe_open_file [file join $objdir $p ] r]
764+ set f_cp [safe_open_file [file join .git objects $p ] w]
765765 fconfigure $f_in -translation binary -encoding binary
766766 fconfigure $f_cp -translation binary -encoding binary
767767
@@ -818,12 +818,12 @@ method _clone_refs {} {
818818 error_popup [mc " Not a Git repository: %s" [file tail $origin_url ]]
819819 return 0
820820 }
821- set fd_in [git_read for-each-ref \
821+ set fd_in [git_read [ list for-each-ref \
822822 --tcl \
823- {--format=list %(refname) %(objectname) %(*objectname)}]
823+ {--format=list %(refname) %(objectname) %(*objectname)}]]
824824 cd $pwd
825825
826- set fd [open [gitdir packed-refs] w]
826+ set fd [safe_open_file [gitdir packed-refs] w]
827827 fconfigure $fd -translation binary
828828 puts $fd " # pack-refs with: peeled"
829829 while {[gets $fd_in line] >= 0} {
@@ -877,7 +877,7 @@ method _do_clone_full_end {ok} {
877877
878878 set HEAD {}
879879 if {[file exists [gitdir FETCH_HEAD]]} {
880- set fd [open [gitdir FETCH_HEAD] r]
880+ set fd [safe_open_file [gitdir FETCH_HEAD] r]
881881 while {[gets $fd line] >= 0} {
882882 if {[regexp "^(.{40})\t\t " $line line HEAD]} {
883883 break
@@ -953,13 +953,14 @@ method _do_clone_checkout {HEAD} {
953953 [mc " files" ]]
954954
955955 set readtree_err {}
956- set fd [git_read --stderr read-tree \
956+ set fd [git_read [ list read-tree \
957957 -m \
958958 -u \
959959 -v \
960960 HEAD \
961961 HEAD \
962- ]
962+ ] \
963+ [list 2>@1]]
963964 fconfigure $fd -blocking 0 -translation binary
964965 fileevent $fd readable [cb _readtree_wait $fd ]
965966}
0 commit comments