1 # git-gui Git repository chooser
2 # Copyright (C) 2007 Shawn Pearce
4 class choose_repository
{
8 field w_body
; # Widget holding the center content
9 field w_next
; # Next button
10 field w_quit
; # Quit button
11 field o_cons
; # Console object (if active)
13 # Status mega-widget instance during _do_clone2 (used by _copy_files and
14 # _link_files). Widget is destroyed before _do_clone2 calls
18 # Operation displayed by status mega-widget during _do_clone_checkout =>
19 # _readtree_wait => _postcheckout_wait => _do_clone_submodules =>
20 # _do_validate_submodule_cloning. The status mega-widget is a different
21 # instance than that stored in $o_status in earlier operations.
24 field w_types
; # List of type buttons in clone
25 field w_recentlist
; # Listbox containing recent repositories
26 field w_localpath
; # Entry widget bound to local_path
28 field done
0 ; # Finished picking the repository?
29 field local_path
{} ; # Where this repository is locally
30 field origin_url
{} ; # Where we are cloning from
31 field origin_name origin
; # What we shall call 'origin'
32 field clone_type hardlink
; # Type of clone to construct
33 field recursive true
; # Recursive cloning flag
34 field readtree_err
; # Error output from read-tree (if any)
35 field sorted_recent
; # recent repositories (sorted)
38 global M1T M1B use_ttk NS
40 if {[set maxrecent
[get_config gui.maxrecentrepo
]] eq
{}} {
45 wm title
$top [mc
"Git Gui"]
48 menu $w.mbar
-tearoff 0
49 $top configure
-menu $w.mbar
51 set m_repo
$w.mbar.repository
53 -label [mc Repository
] \
58 $w.mbar add cascade
-label Apple
-menu .mbar.apple
60 $w.mbar.apple add command
\
61 -label [mc
"About %s" [appname
]] \
63 $w.mbar.apple add command
\
64 -label [mc
"Show SSH Key"] \
67 $w.mbar add cascade
-label [mc Help
] -menu $w.mbar.help
69 $w.mbar.help add command
\
70 -label [mc
"About %s" [appname
]] \
72 $w.mbar.help add command
\
73 -label [mc
"Show SSH Key"] \
77 wm protocol
$top WM_DELETE_WINDOW
exit
78 bind $top <$M1B-q
> exit
79 bind $top <$M1B-Q
> exit
80 bind $top <Key-Escape
> exit
82 wm geometry
$top "+[winfo rootx .]+[winfo rooty .]"
83 bind $top <Key-Escape
> [list destroy $top]
87 pack [git_logo
$w.git_logo
] -side left
-fill y
-padx 10 -pady 10
90 set opts
$w_body.
options
93 -cursor $::cursor_ptr \
95 -background [get_bg_color
$w_body] \
100 pack $opts -anchor w
-fill x
102 $opts tag conf link_new
-foreground blue
-underline 1
103 $opts tag
bind link_new
<1> [cb _next new
]
104 $opts insert end
[mc
"Create New Repository"] link_new
105 $opts insert end
"\n"
107 $m_repo add command
\
108 -command [cb _next new
] \
109 -accelerator $M1T-N
\
111 bind $top <$M1B-n
> [cb _next new
]
112 bind $top <$M1B-N
> [cb _next new
]
115 $opts tag conf link_clone
-foreground blue
-underline 1
116 $opts tag
bind link_clone
<1> [cb _next clone
]
117 $opts insert end
[mc
"Clone Existing Repository"] link_clone
118 $opts insert end
"\n"
120 if {[tk windowingsystem
] eq
"win32"} {
125 $m_repo add command
\
126 -command [cb _next clone
] \
127 -accelerator $M1T-$key \
128 -label [mc
"Clone..."]
129 bind $top <$M1B-[string tolower
$key]> [cb _next clone
]
130 bind $top <$M1B-[string toupper
$key]> [cb _next clone
]
133 $opts tag conf link_open
-foreground blue
-underline 1
134 $opts tag
bind link_open
<1> [cb _next
open]
135 $opts insert end
[mc
"Open Existing Repository"] link_open
136 $opts insert end
"\n"
138 $m_repo add command
\
139 -command [cb _next
open] \
140 -accelerator $M1T-O
\
141 -label [mc
"Open..."]
142 bind $top <$M1B-o
> [cb _next
open]
143 bind $top <$M1B-O
> [cb _next
open]
146 $opts conf
-state disabled
148 set sorted_recent
[_get_recentrepos
]
149 if {[llength $sorted_recent] > 0} {
151 $m_repo add separator
152 $m_repo add command
\
154 -label [mc
"Recent Repositories"]
157 if {[set lenrecent
[llength $sorted_recent]] < $maxrecent} {
158 set lenrecent
$maxrecent
161 ${NS
}::label $w_body.space
162 ${NS
}::label $w_body.recentlabel
\
164 -text [mc
"Open Recent Repository:"]
165 set w_recentlist
$w_body.recentlist
167 -cursor $::cursor_ptr \
169 -background [get_bg_color
$w_body.recentlabel
] \
173 $w_recentlist tag conf link
\
176 set home
$::env(HOME
)
178 set home
[exec cygpath
--windows --absolute $home]
180 set home
"[file normalize $home]/"
181 set hlen
[string length
$home]
182 foreach p
$sorted_recent {
184 if {[string equal
-length $hlen $home $p]} {
185 set p
"~/[string range $p $hlen end]"
187 regsub -all "\n" $p "\\n" p
188 $w_recentlist insert end
$p link
189 $w_recentlist insert end
"\n"
192 $m_repo add command
\
193 -command [cb _open_recent_path
$path] \
197 $w_recentlist conf
-state disabled
198 $w_recentlist tag
bind link
<1> [cb _open_recent
%x
,%y
]
199 pack $w_body.space
-anchor w
-fill x
200 pack $w_body.recentlabel
-anchor w
-fill x
201 pack $w_recentlist -anchor w
-fill x
203 pack $w_body -fill x
-padx 10 -pady 10
205 ${NS
}::frame $w.buttons
206 set w_next
$w.buttons.next
207 set w_quit
$w.buttons.quit
208 ${NS
}::button $w_quit \
211 pack $w_quit -side right
-padx 5
212 pack $w.buttons
-side bottom
-fill x
-padx 10 -pady 10
215 $m_repo add separator
216 $m_repo add command
\
222 bind $top <Return
> [cb _invoke_next
]
223 bind $top <Visibility
> "
227 bind $top <Visibility> {}
230 tkwait variable @done
234 eval destroy [winfo children
$top]
239 set nx
[winfo reqwidth
$top]
240 set ny
[winfo reqheight
$top]
241 set rx
[expr {([winfo screenwidth
$top] - $nx) / 3}]
242 set ry
[expr {([winfo screenheight
$top] - $ny) / 3}]
243 wm geometry
$top [format {+%d
+%d
} $rx $ry]
246 method _invoke_next
{} {
247 if {[winfo exists
$w_next]} {
248 uplevel #0 [$w_next cget -command]
252 proc _get_recentrepos
{} {
254 foreach p
[lsort -unique [get_config gui.recentrepo
]] {
255 if {[_is_git
[file join $p .git
]]} {
264 proc _unset_recentrepo
{p
} {
265 regsub -all -- {([()\[\]{}\.^
$+*?
\\])} $p {\\\1} p
266 catch {git config
--global --unset-all gui.recentrepo
"^$p\$"}
270 proc _append_recentrepos
{path
} {
271 set path
[file normalize
$path]
272 set recent
[get_config gui.recentrepo
]
274 if {[lindex $recent end
] eq
$path} {
278 set i
[lsearch $recent $path]
280 _unset_recentrepo
$path
283 git config
--global --add gui.recentrepo
$path
285 set recent
[get_config gui.recentrepo
]
287 if {[set maxrecent
[get_config gui.maxrecentrepo
]] eq
{}} {
291 while {[llength $recent] > $maxrecent} {
292 _unset_recentrepo
[lindex $recent 0]
293 set recent
[get_config gui.recentrepo
]
297 method _open_recent
{xy
} {
298 set id
[lindex [split [$w_recentlist index
@$xy] .
] 0]
299 set local_path
[lindex $sorted_recent [expr {$id - 1}]]
303 method _open_recent_path
{p
} {
308 method _next
{action
} {
311 if {![winfo exists
$w_next]} {
312 ${NS
}::button $w_next -default active
314 if {[tk windowingsystem
] eq
"win32"} { set pos
-after }
315 pack $w_next -side right
-padx 5 $pos $w_quit
320 method _write_local_path
{args
} {
321 if {$local_path eq
{}} {
322 $w_next conf
-state disabled
324 $w_next conf
-state normal
328 method _git_init
{} {
329 if {[catch {file mkdir
$local_path} err
]} {
330 error_popup
[strcat
\
331 [mc
"Failed to create repository %s:" $local_path] \
336 if {[catch {cd $local_path} err
]} {
337 error_popup
[strcat
\
338 [mc
"Failed to create repository %s:" $local_path] \
343 if {[catch {git init
} err
]} {
344 error_popup
[strcat
\
345 [mc
"Failed to create repository %s:" $local_path] \
350 _append_recentrepos
[pwd]
356 proc _is_git
{path
{outdir_var
""}} {
357 if {$outdir_var ne
""} {
358 upvar 1 $outdir_var outdir
360 if {[file isfile
$path]} {
361 set fp
[open $path r
]
364 if {[regexp "^gitdir: (.+)$" $line line link_target
]} {
365 set path
[file join [file dirname
$path] $link_target]
366 set path
[file normalize
$path]
370 if {[file exists
[file join $path HEAD
]]
371 && [file exists
[file join $path objects
]]
372 && [file exists
[file join $path config
]]} {
377 if {[file exists
[file join $path HEAD
]]
378 && [file exists
[file join $path objects.lnk
]]
379 && [file exists
[file join $path config.lnk
]]} {
387 proc _objdir
{path
} {
388 set objdir
[file join $path .git objects
]
389 if {[file isdirectory
$objdir]} {
393 set objdir
[file join $path objects
]
394 if {[file isdirectory
$objdir]} {
399 set objdir
[file join $path .git objects.lnk
]
400 if {[file isfile
$objdir]} {
401 return [win32_read_lnk
$objdir]
404 set objdir
[file join $path objects.lnk
]
405 if {[file isfile
$objdir]} {
406 return [win32_read_lnk
$objdir]
413 ######################################################################
415 ## Create New Repository
421 -command [cb _do_new2
] \
425 ${NS
}::label $w_body.h
\
426 -font font_uibold
-anchor center
\
427 -text [mc
"Create New Repository"]
428 pack $w_body.h
-side top
-fill x
-pady 10
429 pack $w_body -fill x
-padx 10
431 ${NS
}::frame $w_body.where
432 ${NS
}::label $w_body.where.l
-text [mc
"Directory:"]
433 ${NS
}::entry $w_body.where.t
\
434 -textvariable @local_path
\
436 ${NS
}::button $w_body.where.b
\
437 -text [mc
"Browse"] \
438 -command [cb _new_local_path
]
439 set w_localpath
$w_body.where.t
441 grid $w_body.where.l
$w_body.where.t
$w_body.where.b
-sticky ew
442 pack $w_body.where
-fill x
444 grid columnconfigure
$w_body.where
1 -weight 1
446 trace add
variable @local_path write
[cb _write_local_path
]
447 bind $w_body.h
<Destroy
> [list trace remove
variable @local_path write
[cb _write_local_path
]]
449 focus $w_body.where.t
452 method _new_local_path
{} {
453 if {$local_path ne
{}} {
454 set p
[file dirname
$local_path]
459 set p
[tk_chooseDirectory \
462 -title [mc
"Git Repository"] \
466 set p
[file normalize
$p]
471 $w_localpath icursor end
475 if {![_new_ok
$local_path]} {
478 if {![_git_init
$this]} {
485 if {[file isdirectory
$p]} {
486 if {[_is_git
[file join $p .git
]]} {
487 error_popup
[mc
"Directory %s already exists." $p]
490 } elseif
{[file exists
$p]} {
491 error_popup
[mc
"File %s already exists." $p]
497 ######################################################################
499 ## Clone Existing Repository
501 method _do_clone
{} {
505 -command [cb _do_clone2
] \
509 ${NS
}::label $w_body.h
\
510 -font font_uibold
-anchor center
\
511 -text [mc
"Clone Existing Repository"]
512 pack $w_body.h
-side top
-fill x
-pady 10
513 pack $w_body -fill x
-padx 10
515 set args
$w_body.args
516 ${NS
}::frame $w_body.args
517 pack $args -fill both
519 ${NS
}::label $args.origin_l
-text [mc
"Source Location:"]
520 ${NS
}::entry $args.origin_t
\
521 -textvariable @origin_url
\
523 ${NS
}::button $args.origin_b
\
524 -text [mc
"Browse"] \
525 -command [cb _open_origin
]
526 grid $args.origin_l
$args.origin_t
$args.origin_b
-sticky ew
528 ${NS
}::label $args.where_l
-text [mc
"Target Directory:"]
529 ${NS
}::entry $args.where_t
\
530 -textvariable @local_path
\
532 ${NS
}::button $args.where_b
\
533 -text [mc
"Browse"] \
534 -command [cb _new_local_path
]
535 grid $args.where_l
$args.where_t
$args.where_b
-sticky ew
536 set w_localpath
$args.where_t
538 ${NS
}::label $args.type_l
-text [mc
"Clone Type:"]
539 ${NS
}::frame $args.type_f
541 lappend w_types
[${NS
}::radiobutton $args.type_f.hardlink
\
543 -text [mc
"Standard (Fast, Semi-Redundant, Hardlinks)"] \
544 -variable @clone_type
\
546 lappend w_types
[${NS
}::radiobutton $args.type_f.full
\
548 -text [mc
"Full Copy (Slower, Redundant Backup)"] \
549 -variable @clone_type
\
551 lappend w_types
[${NS
}::radiobutton $args.type_f.shared
\
553 -text [mc
"Shared (Fastest, Not Recommended, No Backup)"] \
554 -variable @clone_type
\
559 ${NS
}::checkbutton $args.type_f.recursive
\
560 -text [mc
"Recursively clone submodules too"] \
561 -variable @recursive
\
562 -onvalue true
-offvalue false
563 pack $args.type_f.recursive
-anchor w
564 grid $args.type_l
$args.type_f
-sticky new
566 grid columnconfigure
$args 1 -weight 1
568 trace add
variable @local_path write
[cb _update_clone
]
569 trace add
variable @origin_url write
[cb _update_clone
]
570 bind $w_body.h
<Destroy
> "
571 [list trace remove variable @local_path write [cb _update_clone]]
572 [list trace remove variable @origin_url write [cb _update_clone]]
578 method _open_origin
{} {
579 if {$origin_url ne
{} && [file isdirectory
$origin_url]} {
585 set p
[tk_chooseDirectory \
588 -title [mc
"Git Repository"] \
592 set p
[file normalize
$p]
593 if {![_is_git
[file join $p .git
]] && ![_is_git
$p]} {
594 error_popup
[mc
"Not a Git repository: %s" [file tail
$p]]
600 method _update_clone
{args
} {
601 if {$local_path ne
{} && $origin_url ne
{}} {
602 $w_next conf
-state normal
604 $w_next conf
-state disabled
607 if {$origin_url ne
{} &&
608 ( [_is_git
[file join $origin_url .git
]]
609 ||
[_is_git
$origin_url])} {
611 if {[[lindex $w_types 0] cget
-state] eq
{disabled
}} {
612 set clone_type hardlink
624 method _do_clone2
{} {
625 if {[file isdirectory
$origin_url]} {
626 set origin_url
[file normalize
$origin_url]
629 if {$clone_type eq
{hardlink
} && ![file isdirectory
$origin_url]} {
630 error_popup
[mc
"Standard only available for local repository."]
633 if {$clone_type eq
{shared
} && ![file isdirectory
$origin_url]} {
634 error_popup
[mc
"Shared only available for local repository."]
638 if {$clone_type eq
{hardlink
} ||
$clone_type eq
{shared
}} {
639 set objdir
[_objdir
$origin_url]
641 error_popup
[mc
"Not a Git repository: %s" [file tail
$origin_url]]
646 set giturl
$origin_url
647 if {[is_Cygwin
] && [file isdirectory
$giturl]} {
648 set giturl
[exec cygpath
--unix --absolute $giturl]
649 if {$clone_type eq
{shared
}} {
650 set objdir
[exec cygpath
--unix --absolute $objdir]
654 if {[file exists
$local_path]} {
655 error_popup
[mc
"Location %s already exists." $local_path]
659 if {![_git_init
$this]} return
663 git config remote.
$origin_name.url
$giturl
664 git config remote.
$origin_name.fetch
+refs
/heads
/*:refs
/remotes
/$origin_name/*
666 error_popup
[strcat
[mc
"Failed to configure origin"] "\n\n$err"]
670 destroy $w_body $w_next
672 switch -exact -- $clone_type {
674 set o_status
[status_bar
::two_line $w_body]
675 pack $w_body -fill x
-padx 10 -pady 10
677 set status_op
[$o_status start
\
678 [mc
"Counting objects"] \
682 if {[file exists
[file join $objdir info alternates
]]} {
685 file mkdir
[gitdir objects
info]
686 set f_in
[open [file join $objdir info alternates
] r
]
687 set f_cp
[open [gitdir objects
info alternates
] w
]
688 fconfigure $f_in -translation binary -encoding binary
689 fconfigure $f_cp -translation binary -encoding binary
691 while {[gets $f_in line
] >= 0} {
693 puts $f_cp [exec cygpath
--unix --absolute $line]
695 puts $f_cp [file normalize
$line]
703 _clone_failed
$this [mc
"Unable to copy objects/info/alternates: %s" $err]
713 -directory [file join $objdir] ??
]
714 set bcnt
[expr {[llength $buckets] + 2}]
716 $status_op update $bcur $bcnt
719 file mkdir
[file join .git objects
pack]
720 foreach i
[glob -tails -nocomplain \
721 -directory [file join $objdir pack] *] {
722 lappend tolink
[file join pack $i]
724 $status_op update [incr bcur
] $bcnt
728 file mkdir
[file join .git objects
$i]
729 foreach j
[glob -tails -nocomplain \
730 -directory [file join $objdir $i] *] {
731 lappend tolink
[file join $i $j]
733 $status_op update [incr bcur
] $bcnt
740 [mc
"Nothing to clone from %s." $origin_url] \
742 [mc
"The 'master' branch has not been initialized."] \
749 set i
[lindex $tolink 0]
752 [file join .git objects
$i] \
753 [file join $objdir $i]
755 info_popup
[mc
"Hardlinks are unavailable. Falling back to copying."]
756 set i
[_copy_files
$this $objdir $tolink]
758 set i
[_link_files
$this $objdir [lrange $tolink 1 end
]]
767 set o_cons
[console::embed \
769 [mc
"Cloning from %s" $origin_url]]
770 pack $w_body -fill both
-expand 1 -padx 10
772 [list git fetch
--no-tags
-k $origin_name] \
776 set fd
[open [gitdir objects
info alternates
] w
]
777 fconfigure $fd -translation binary
783 if {$clone_type eq
{hardlink
} ||
$clone_type eq
{shared
}} {
784 if {![_clone_refs
$this]} return
788 set HEAD
[git rev-parse
--verify HEAD^
0]
790 _clone_failed
$this [mc
"Not a Git repository: %s" [file tail
$origin_url]]
794 _do_clone_checkout
$this $HEAD
798 method _copy_files
{objdir tocopy
} {
799 set status_op
[$o_status start
\
800 [mc
"Copying objects"] \
805 incr tot
[file size
[file join $objdir $p]]
809 set f_in
[open [file join $objdir $p] r
]
810 set f_cp
[open [file join .git objects
$p] w
]
811 fconfigure $f_in -translation binary -encoding binary
812 fconfigure $f_cp -translation binary -encoding binary
814 while {![eof $f_in]} {
815 incr cmp
[fcopy $f_in $f_cp -size 16384]
817 [expr {$cmp / 1024}] \
825 _clone_failed
$this [mc
"Unable to copy object: %s" $err]
834 method _link_files
{objdir tolink
} {
835 set total
[llength $tolink]
836 set status_op
[$o_status start
\
837 [mc
"Linking objects"] \
839 for {set i
0} {$i < $total} {} {
840 set p
[lindex $tolink $i]
843 [file join .git objects
$p] \
844 [file join $objdir $p]
846 _clone_failed
$this [mc
"Unable to hardlink object: %s" $err]
853 $status_op update $i $total
861 method _clone_refs
{} {
863 if {[catch {cd $origin_url} err
]} {
864 error_popup
[mc
"Not a Git repository: %s" [file tail
$origin_url]]
867 set fd_in
[git_read for-each-ref
\
869 {--format=list %(refname
) %(objectname
) %(*objectname
)}]
872 set fd
[open [gitdir packed-refs
] w
]
873 fconfigure $fd -translation binary
874 puts $fd "# pack-refs with: peeled"
875 while {[gets $fd_in line
] >= 0} {
876 set line
[eval $line]
877 set refn
[lindex $line 0]
878 set robj
[lindex $line 1]
879 set tobj
[lindex $line 2]
881 if {[regsub ^refs
/heads
/ $refn \
882 "refs/remotes/$origin_name/" refn
]} {
883 puts $fd "$robj $refn"
884 } elseif
{[string match refs
/tags
/* $refn]} {
885 puts $fd "$robj $refn"
896 method _do_clone_tags
{ok
} {
899 [list git fetch
--tags -k $origin_name] \
903 _clone_failed
$this [mc
"Cannot fetch branches and objects. See console output for details."]
907 method _do_clone_HEAD
{ok
} {
910 [list git fetch
$origin_name HEAD
] \
911 [cb _do_clone_full_end
]
914 _clone_failed
$this [mc
"Cannot fetch tags. See console output for details."]
918 method _do_clone_full_end
{ok
} {
925 if {[file exists
[gitdir FETCH_HEAD
]]} {
926 set fd
[open [gitdir FETCH_HEAD
] r
]
927 while {[gets $fd line
] >= 0} {
928 if {[regexp "^(.{40})\t\t" $line line HEAD
]} {
935 catch {git pack-refs
}
936 _do_clone_checkout
$this $HEAD
938 _clone_failed
$this [mc
"Cannot determine HEAD. See console output for details."]
942 method _clone_failed
{{why
{}}} {
943 if {[catch {file delete
-force $local_path} err
]} {
947 [mc
"Unable to cleanup %s" $local_path] \
953 error_popup
[strcat
[mc
"Clone failed."] "\n" $why]
957 method _do_clone_checkout
{HEAD
} {
960 [mc
"No default branch obtained."] \
962 [mc
"The 'master' branch has not been initialized."] \
968 git update-ref HEAD
$HEAD^
0
971 [mc
"Cannot resolve %s as a commit." $HEAD^
0] \
974 [mc
"The 'master' branch has not been initialized."] \
980 set status
[status_bar
::two_line $w_body]
981 pack $w_body -fill x
-padx 10 -pady 10
983 # We start the status operation here.
985 # This function calls _readtree_wait as a callback.
987 # _readtree_wait in turn either calls _do_clone_submodules directly,
988 # or calls _postcheckout_wait as a callback which then calls
989 # _do_clone_submodules.
991 # _do_clone_submodules calls _do_validate_submodule_cloning.
993 # _do_validate_submodule_cloning stops the status operation.
995 # There are no other calls into this chain from other code.
997 set o_status_op
[$status start
\
998 [mc
"Creating working directory"] \
1002 set fd
[git_read
--stderr read-tree
\
1009 fconfigure $fd -blocking 0 -translation binary
1010 fileevent $fd readable
[cb _readtree_wait
$fd]
1013 method _readtree_wait
{fd
} {
1015 $o_status_op update_meter
$buf
1016 append readtree_err
$buf
1018 fconfigure $fd -blocking 1
1020 fconfigure $fd -blocking 0
1024 if {[catch {close $fd}]} {
1025 set err
$readtree_err
1026 regsub {^fatal
: } $err {} err
1027 error_popup
[strcat
\
1028 [mc
"Initial file checkout failed."] \
1033 # -- Run the post-checkout hook.
1035 set fd_ph
[githook_read post-checkout
[string repeat
0 40] \
1036 [git rev-parse HEAD
] 1]
1040 fconfigure $fd_ph -blocking 0 -translation binary -eofchar {}
1041 fileevent $fd_ph readable
[cb _postcheckout_wait
$fd_ph]
1043 _do_clone_submodules
$this
1047 method _postcheckout_wait
{fd_ph
} {
1050 append pch_error
[read $fd_ph]
1051 fconfigure $fd_ph -blocking 1
1053 if {[catch {close $fd_ph}]} {
1054 hook_failed_popup post-checkout
$pch_error 0
1057 _do_clone_submodules
$this
1060 fconfigure $fd_ph -blocking 0
1063 method _do_clone_submodules
{} {
1064 if {$recursive eq
{true
}} {
1070 set o_cons
[console::embed \
1072 [mc
"Cloning submodules"]]
1073 pack $w_body -fill both
-expand 1 -padx 10
1075 [list git submodule
update --init --recursive] \
1076 [cb _do_validate_submodule_cloning
]
1082 method _do_validate_submodule_cloning
{ok
} {
1087 _clone_failed
$this [mc
"Cannot clone submodules."]
1091 ######################################################################
1093 ## Open Existing Repository
1095 method _do_open
{} {
1099 -command [cb _do_open2
] \
1102 ${NS
}::frame $w_body
1103 ${NS
}::label $w_body.h
\
1104 -font font_uibold
-anchor center
\
1105 -text [mc
"Open Existing Repository"]
1106 pack $w_body.h
-side top
-fill x
-pady 10
1107 pack $w_body -fill x
-padx 10
1109 ${NS
}::frame $w_body.where
1110 ${NS
}::label $w_body.where.l
-text [mc
"Repository:"]
1111 ${NS
}::entry $w_body.where.t
\
1112 -textvariable @local_path
\
1114 ${NS
}::button $w_body.where.b
\
1115 -text [mc
"Browse"] \
1116 -command [cb _open_local_path
]
1118 grid $w_body.where.l
$w_body.where.t
$w_body.where.b
-sticky ew
1119 pack $w_body.where
-fill x
1121 grid columnconfigure
$w_body.where
1 -weight 1
1123 trace add
variable @local_path write
[cb _write_local_path
]
1124 bind $w_body.h
<Destroy
> [list trace remove
variable @local_path write
[cb _write_local_path
]]
1126 focus $w_body.where.t
1129 method _open_local_path
{} {
1130 if {$local_path ne
{}} {
1136 set p
[tk_chooseDirectory \
1139 -title [mc
"Git Repository"] \
1141 if {$p eq
{}} return
1143 set p
[file normalize
$p]
1144 if {![_is_git
[file join $p .git
]]} {
1145 error_popup
[mc
"Not a Git repository: %s" [file tail
$p]]
1151 method _do_open2
{} {
1152 if {![_is_git
[file join $local_path .git
] actualgit
]} {
1153 error_popup
[mc
"Not a Git repository: %s" [file tail
$local_path]]
1157 if {[catch {cd $local_path} err
]} {
1158 error_popup
[strcat
\
1159 [mc
"Failed to open repository %s:" $local_path] \
1164 _append_recentrepos
[pwd]
1165 set ::_gitdir $actualgit