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
)
177 set home
"[file normalize $home]/"
178 set hlen
[string length
$home]
179 foreach p
$sorted_recent {
181 if {[string equal
-length $hlen $home $p]} {
182 set p
"~/[string range $p $hlen end]"
184 regsub -all "\n" $p "\\n" p
185 $w_recentlist insert end
$p link
186 $w_recentlist insert end
"\n"
189 $m_repo add command
\
190 -command [cb _open_recent_path
$path] \
194 $w_recentlist conf
-state disabled
195 $w_recentlist tag
bind link
<1> [cb _open_recent
%x
,%y
]
196 pack $w_body.space
-anchor w
-fill x
197 pack $w_body.recentlabel
-anchor w
-fill x
198 pack $w_recentlist -anchor w
-fill x
200 pack $w_body -fill x
-padx 10 -pady 10
202 ${NS
}::frame $w.buttons
203 set w_next
$w.buttons.next
204 set w_quit
$w.buttons.quit
205 ${NS
}::button $w_quit \
208 pack $w_quit -side right
-padx 5
209 pack $w.buttons
-side bottom
-fill x
-padx 10 -pady 10
212 $m_repo add separator
213 $m_repo add command
\
219 bind $top <Return
> [cb _invoke_next
]
220 bind $top <Visibility
> "
224 bind $top <Visibility> {}
227 tkwait variable @done
231 eval destroy [winfo children
$top]
236 set nx
[winfo reqwidth
$top]
237 set ny
[winfo reqheight
$top]
238 set rx
[expr {([winfo screenwidth
$top] - $nx) / 3}]
239 set ry
[expr {([winfo screenheight
$top] - $ny) / 3}]
240 wm geometry
$top [format {+%d
+%d
} $rx $ry]
243 method _invoke_next
{} {
244 if {[winfo exists
$w_next]} {
245 uplevel #0 [$w_next cget -command]
249 proc _get_recentrepos
{} {
251 foreach p
[lsort -unique [get_config gui.recentrepo
]] {
252 if {[_is_git
[file join $p .git
]]} {
261 proc _unset_recentrepo
{p
} {
262 regsub -all -- {([()\[\]{}\.^
$+*?
\\])} $p {\\\1} p
263 catch {git config
--global --unset-all gui.recentrepo
"^$p\$"}
267 proc _append_recentrepos
{path
} {
268 set path
[file normalize
$path]
269 set recent
[get_config gui.recentrepo
]
271 if {[lindex $recent end
] eq
$path} {
275 set i
[lsearch $recent $path]
277 _unset_recentrepo
$path
280 git config
--global --add gui.recentrepo
$path
282 set recent
[get_config gui.recentrepo
]
284 if {[set maxrecent
[get_config gui.maxrecentrepo
]] eq
{}} {
288 while {[llength $recent] > $maxrecent} {
289 _unset_recentrepo
[lindex $recent 0]
290 set recent
[get_config gui.recentrepo
]
294 method _open_recent
{xy
} {
295 set id
[lindex [split [$w_recentlist index
@$xy] .
] 0]
296 set local_path
[lindex $sorted_recent [expr {$id - 1}]]
300 method _open_recent_path
{p
} {
305 method _next
{action
} {
308 if {![winfo exists
$w_next]} {
309 ${NS
}::button $w_next -default active
311 if {[tk windowingsystem
] eq
"win32"} { set pos
-after }
312 pack $w_next -side right
-padx 5 $pos $w_quit
317 method _write_local_path
{args
} {
318 if {$local_path eq
{}} {
319 $w_next conf
-state disabled
321 $w_next conf
-state normal
325 method _git_init
{} {
326 if {[catch {file mkdir
$local_path} err
]} {
327 error_popup
[strcat
\
328 [mc
"Failed to create repository %s:" $local_path] \
333 if {[catch {cd $local_path} err
]} {
334 error_popup
[strcat
\
335 [mc
"Failed to create repository %s:" $local_path] \
340 if {[catch {git init
} err
]} {
341 error_popup
[strcat
\
342 [mc
"Failed to create repository %s:" $local_path] \
347 _append_recentrepos
[pwd]
353 proc _is_git
{path
{outdir_var
""}} {
354 if {$outdir_var ne
""} {
355 upvar 1 $outdir_var outdir
357 if {[catch {set outdir
[git rev-parse
--resolve-git
-dir
$path]}]} {
363 proc _objdir
{path
} {
364 set objdir
[file join $path .git objects
]
365 if {[file isdirectory
$objdir]} {
369 set objdir
[file join $path objects
]
370 if {[file isdirectory
$objdir]} {
377 ######################################################################
379 ## Create New Repository
385 -command [cb _do_new2
] \
389 ${NS
}::label $w_body.h
\
390 -font font_uibold
-anchor center
\
391 -text [mc
"Create New Repository"]
392 pack $w_body.h
-side top
-fill x
-pady 10
393 pack $w_body -fill x
-padx 10
395 ${NS
}::frame $w_body.where
396 ${NS
}::label $w_body.where.l
-text [mc
"Directory:"]
397 ${NS
}::entry $w_body.where.t
\
398 -textvariable @local_path
\
400 ${NS
}::button $w_body.where.b
\
401 -text [mc
"Browse"] \
402 -command [cb _new_local_path
]
403 set w_localpath
$w_body.where.t
405 grid $w_body.where.l
$w_body.where.t
$w_body.where.b
-sticky ew
406 pack $w_body.where
-fill x
408 grid columnconfigure
$w_body.where
1 -weight 1
410 trace add
variable @local_path write
[cb _write_local_path
]
411 bind $w_body.h
<Destroy
> [list trace remove
variable @local_path write
[cb _write_local_path
]]
413 focus $w_body.where.t
416 method _new_local_path
{} {
417 if {$local_path ne
{}} {
418 set p
[file dirname
$local_path]
423 set p
[tk_chooseDirectory \
426 -title [mc
"Git Repository"] \
430 set p
[file normalize
$p]
435 $w_localpath icursor end
439 if {![_new_ok
$local_path]} {
442 if {![_git_init
$this]} {
449 if {[file isdirectory
$p]} {
450 if {[_is_git
[file join $p .git
]]} {
451 error_popup
[mc
"Directory %s already exists." $p]
454 } elseif
{[file exists
$p]} {
455 error_popup
[mc
"File %s already exists." $p]
461 ######################################################################
463 ## Clone Existing Repository
465 method _do_clone
{} {
469 -command [cb _do_clone2
] \
473 ${NS
}::label $w_body.h
\
474 -font font_uibold
-anchor center
\
475 -text [mc
"Clone Existing Repository"]
476 pack $w_body.h
-side top
-fill x
-pady 10
477 pack $w_body -fill x
-padx 10
479 set args
$w_body.args
480 ${NS
}::frame $w_body.args
481 pack $args -fill both
483 ${NS
}::label $args.origin_l
-text [mc
"Source Location:"]
484 ${NS
}::entry $args.origin_t
\
485 -textvariable @origin_url
\
487 ${NS
}::button $args.origin_b
\
488 -text [mc
"Browse"] \
489 -command [cb _open_origin
]
490 grid $args.origin_l
$args.origin_t
$args.origin_b
-sticky ew
492 ${NS
}::label $args.where_l
-text [mc
"Target Directory:"]
493 ${NS
}::entry $args.where_t
\
494 -textvariable @local_path
\
496 ${NS
}::button $args.where_b
\
497 -text [mc
"Browse"] \
498 -command [cb _new_local_path
]
499 grid $args.where_l
$args.where_t
$args.where_b
-sticky ew
500 set w_localpath
$args.where_t
502 ${NS
}::label $args.type_l
-text [mc
"Clone Type:"]
503 ${NS
}::frame $args.type_f
505 lappend w_types
[${NS
}::radiobutton $args.type_f.hardlink
\
507 -text [mc
"Standard (Fast, Semi-Redundant, Hardlinks)"] \
508 -variable @clone_type
\
510 lappend w_types
[${NS
}::radiobutton $args.type_f.full
\
512 -text [mc
"Full Copy (Slower, Redundant Backup)"] \
513 -variable @clone_type
\
515 lappend w_types
[${NS
}::radiobutton $args.type_f.shared
\
517 -text [mc
"Shared (Fastest, Not Recommended, No Backup)"] \
518 -variable @clone_type
\
523 ${NS
}::checkbutton $args.type_f.recursive
\
524 -text [mc
"Recursively clone submodules too"] \
525 -variable @recursive
\
526 -onvalue true
-offvalue false
527 pack $args.type_f.recursive
-anchor w
528 grid $args.type_l
$args.type_f
-sticky new
530 grid columnconfigure
$args 1 -weight 1
532 trace add
variable @local_path write
[cb _update_clone
]
533 trace add
variable @origin_url write
[cb _update_clone
]
534 bind $w_body.h
<Destroy
> "
535 [list trace remove variable @local_path write [cb _update_clone]]
536 [list trace remove variable @origin_url write [cb _update_clone]]
542 method _open_origin
{} {
543 if {$origin_url ne
{} && [file isdirectory
$origin_url]} {
549 set p
[tk_chooseDirectory \
552 -title [mc
"Git Repository"] \
556 set p
[file normalize
$p]
557 if {![_is_git
[file join $p .git
]] && ![_is_git
$p]} {
558 error_popup
[mc
"Not a Git repository: %s" [file tail
$p]]
564 method _update_clone
{args
} {
565 if {$local_path ne
{} && $origin_url ne
{}} {
566 $w_next conf
-state normal
568 $w_next conf
-state disabled
571 if {$origin_url ne
{} &&
572 ( [_is_git
[file join $origin_url .git
]]
573 ||
[_is_git
$origin_url])} {
575 if {[[lindex $w_types 0] cget
-state] eq
{disabled
}} {
576 set clone_type hardlink
588 method _do_clone2
{} {
589 if {[file isdirectory
$origin_url]} {
590 set origin_url
[file normalize
$origin_url]
593 if {$clone_type eq
{hardlink
} && ![file isdirectory
$origin_url]} {
594 error_popup
[mc
"Standard only available for local repository."]
597 if {$clone_type eq
{shared
} && ![file isdirectory
$origin_url]} {
598 error_popup
[mc
"Shared only available for local repository."]
602 if {$clone_type eq
{hardlink
} ||
$clone_type eq
{shared
}} {
603 set objdir
[_objdir
$origin_url]
605 error_popup
[mc
"Not a Git repository: %s" [file tail
$origin_url]]
610 set giturl
$origin_url
612 if {[file exists
$local_path]} {
613 error_popup
[mc
"Location %s already exists." $local_path]
617 if {![_git_init
$this]} return
621 git config remote.
$origin_name.url
$giturl
622 git config remote.
$origin_name.fetch
+refs
/heads
/*:refs
/remotes
/$origin_name/*
624 error_popup
[strcat
[mc
"Failed to configure origin"] "\n\n$err"]
628 destroy $w_body $w_next
630 switch -exact -- $clone_type {
632 set o_status
[status_bar
::two_line $w_body]
633 pack $w_body -fill x
-padx 10 -pady 10
635 set status_op
[$o_status start
\
636 [mc
"Counting objects"] \
640 if {[file exists
[file join $objdir info alternates
]]} {
643 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
]
646 fconfigure $f_in -translation binary -encoding binary
647 fconfigure $f_cp -translation binary -encoding binary
649 while {[gets $f_in line
] >= 0} {
650 puts $f_cp [file normalize
$line]
657 _clone_failed
$this [mc
"Unable to copy objects/info/alternates: %s" $err]
667 -directory [file join $objdir] ??
]
668 set bcnt
[expr {[llength $buckets] + 2}]
670 $status_op update $bcur $bcnt
673 file mkdir
[file join .git objects
pack]
674 foreach i
[glob -tails -nocomplain \
675 -directory [file join $objdir pack] *] {
676 lappend tolink
[file join pack $i]
678 $status_op update [incr bcur
] $bcnt
682 file mkdir
[file join .git objects
$i]
683 foreach j
[glob -tails -nocomplain \
684 -directory [file join $objdir $i] *] {
685 lappend tolink
[file join $i $j]
687 $status_op update [incr bcur
] $bcnt
694 [mc
"Nothing to clone from %s." $origin_url] \
696 [mc
"The 'master' branch has not been initialized."] \
703 set i
[lindex $tolink 0]
706 [file join .git objects
$i] \
707 [file join $objdir $i]
709 info_popup
[mc
"Hardlinks are unavailable. Falling back to copying."]
710 set i
[_copy_files
$this $objdir $tolink]
712 set i
[_link_files
$this $objdir [lrange $tolink 1 end
]]
721 set o_cons
[console::embed \
723 [mc
"Cloning from %s" $origin_url]]
724 pack $w_body -fill both
-expand 1 -padx 10
726 [list git fetch
--no-tags
-k $origin_name] \
730 set fd
[open [gitdir objects
info alternates
] w
]
731 fconfigure $fd -translation binary
737 if {$clone_type eq
{hardlink
} ||
$clone_type eq
{shared
}} {
738 if {![_clone_refs
$this]} return
742 set HEAD
[git rev-parse
--verify HEAD^
0]
744 _clone_failed
$this [mc
"Not a Git repository: %s" [file tail
$origin_url]]
748 _do_clone_checkout
$this $HEAD
752 method _copy_files
{objdir tocopy
} {
753 set status_op
[$o_status start
\
754 [mc
"Copying objects"] \
759 incr tot
[file size
[file join $objdir $p]]
763 set f_in
[open [file join $objdir $p] r
]
764 set f_cp
[open [file join .git objects
$p] w
]
765 fconfigure $f_in -translation binary -encoding binary
766 fconfigure $f_cp -translation binary -encoding binary
768 while {![eof $f_in]} {
769 incr cmp
[fcopy $f_in $f_cp -size 16384]
771 [expr {$cmp / 1024}] \
779 _clone_failed
$this [mc
"Unable to copy object: %s" $err]
788 method _link_files
{objdir tolink
} {
789 set total
[llength $tolink]
790 set status_op
[$o_status start
\
791 [mc
"Linking objects"] \
793 for {set i
0} {$i < $total} {} {
794 set p
[lindex $tolink $i]
797 [file join .git objects
$p] \
798 [file join $objdir $p]
800 _clone_failed
$this [mc
"Unable to hardlink object: %s" $err]
807 $status_op update $i $total
815 method _clone_refs
{} {
817 if {[catch {cd $origin_url} err
]} {
818 error_popup
[mc
"Not a Git repository: %s" [file tail
$origin_url]]
821 set fd_in
[git_read for-each-ref
\
823 {--format=list %(refname
) %(objectname
) %(*objectname
)}]
826 set fd
[open [gitdir packed-refs
] w
]
827 fconfigure $fd -translation binary
828 puts $fd "# pack-refs with: peeled"
829 while {[gets $fd_in line
] >= 0} {
830 set line
[eval $line]
831 set refn
[lindex $line 0]
832 set robj
[lindex $line 1]
833 set tobj
[lindex $line 2]
835 if {[regsub ^refs
/heads
/ $refn \
836 "refs/remotes/$origin_name/" refn
]} {
837 puts $fd "$robj $refn"
838 } elseif
{[string match refs
/tags
/* $refn]} {
839 puts $fd "$robj $refn"
850 method _do_clone_tags
{ok
} {
853 [list git fetch
--tags -k $origin_name] \
857 _clone_failed
$this [mc
"Cannot fetch branches and objects. See console output for details."]
861 method _do_clone_HEAD
{ok
} {
864 [list git fetch
$origin_name HEAD
] \
865 [cb _do_clone_full_end
]
868 _clone_failed
$this [mc
"Cannot fetch tags. See console output for details."]
872 method _do_clone_full_end
{ok
} {
879 if {[file exists
[gitdir FETCH_HEAD
]]} {
880 set fd
[open [gitdir FETCH_HEAD
] r
]
881 while {[gets $fd line
] >= 0} {
882 if {[regexp "^(.{40})\t\t" $line line HEAD
]} {
889 catch {git pack-refs
}
890 _do_clone_checkout
$this $HEAD
892 _clone_failed
$this [mc
"Cannot determine HEAD. See console output for details."]
896 method _clone_failed
{{why
{}}} {
897 if {[catch {file delete
-force $local_path} err
]} {
901 [mc
"Unable to cleanup %s" $local_path] \
907 error_popup
[strcat
[mc
"Clone failed."] "\n" $why]
911 method _do_clone_checkout
{HEAD
} {
914 [mc
"No default branch obtained."] \
916 [mc
"The 'master' branch has not been initialized."] \
922 git update-ref HEAD
$HEAD^
0
925 [mc
"Cannot resolve %s as a commit." $HEAD^
0] \
928 [mc
"The 'master' branch has not been initialized."] \
934 set status
[status_bar
::two_line $w_body]
935 pack $w_body -fill x
-padx 10 -pady 10
937 # We start the status operation here.
939 # This function calls _readtree_wait as a callback.
941 # _readtree_wait in turn either calls _do_clone_submodules directly,
942 # or calls _postcheckout_wait as a callback which then calls
943 # _do_clone_submodules.
945 # _do_clone_submodules calls _do_validate_submodule_cloning.
947 # _do_validate_submodule_cloning stops the status operation.
949 # There are no other calls into this chain from other code.
951 set o_status_op
[$status start
\
952 [mc
"Creating working directory"] \
956 set fd
[git_read
--stderr read-tree
\
963 fconfigure $fd -blocking 0 -translation binary
964 fileevent $fd readable
[cb _readtree_wait
$fd]
967 method _readtree_wait
{fd
} {
969 $o_status_op update_meter
$buf
970 append readtree_err
$buf
972 fconfigure $fd -blocking 1
974 fconfigure $fd -blocking 0
978 if {[catch {close $fd}]} {
979 set err
$readtree_err
980 regsub {^fatal
: } $err {} err
981 error_popup
[strcat
\
982 [mc
"Initial file checkout failed."] \
987 # -- Run the post-checkout hook.
989 set fd_ph
[githook_read post-checkout
[string repeat
0 40] \
990 [git rev-parse HEAD
] 1]
994 fconfigure $fd_ph -blocking 0 -translation binary -eofchar {}
995 fileevent $fd_ph readable
[cb _postcheckout_wait
$fd_ph]
997 _do_clone_submodules
$this
1001 method _postcheckout_wait
{fd_ph
} {
1004 append pch_error
[read $fd_ph]
1005 fconfigure $fd_ph -blocking 1
1007 if {[catch {close $fd_ph}]} {
1008 hook_failed_popup post-checkout
$pch_error 0
1011 _do_clone_submodules
$this
1014 fconfigure $fd_ph -blocking 0
1017 method _do_clone_submodules
{} {
1018 if {$recursive eq
{true
}} {
1024 set o_cons
[console::embed \
1026 [mc
"Cloning submodules"]]
1027 pack $w_body -fill both
-expand 1 -padx 10
1029 [list git submodule
update --init --recursive] \
1030 [cb _do_validate_submodule_cloning
]
1036 method _do_validate_submodule_cloning
{ok
} {
1041 _clone_failed
$this [mc
"Cannot clone submodules."]
1045 ######################################################################
1047 ## Open Existing Repository
1049 method _do_open
{} {
1053 -command [cb _do_open2
] \
1056 ${NS
}::frame $w_body
1057 ${NS
}::label $w_body.h
\
1058 -font font_uibold
-anchor center
\
1059 -text [mc
"Open Existing Repository"]
1060 pack $w_body.h
-side top
-fill x
-pady 10
1061 pack $w_body -fill x
-padx 10
1063 ${NS
}::frame $w_body.where
1064 ${NS
}::label $w_body.where.l
-text [mc
"Repository:"]
1065 ${NS
}::entry $w_body.where.t
\
1066 -textvariable @local_path
\
1068 ${NS
}::button $w_body.where.b
\
1069 -text [mc
"Browse"] \
1070 -command [cb _open_local_path
]
1072 grid $w_body.where.l
$w_body.where.t
$w_body.where.b
-sticky ew
1073 pack $w_body.where
-fill x
1075 grid columnconfigure
$w_body.where
1 -weight 1
1077 trace add
variable @local_path write
[cb _write_local_path
]
1078 bind $w_body.h
<Destroy
> [list trace remove
variable @local_path write
[cb _write_local_path
]]
1080 focus $w_body.where.t
1083 method _open_local_path
{} {
1084 if {$local_path ne
{}} {
1090 set p
[tk_chooseDirectory \
1093 -title [mc
"Git Repository"] \
1095 if {$p eq
{}} return
1097 set p
[file normalize
$p]
1098 if {![_is_git
[file join $p .git
]]} {
1099 error_popup
[mc
"Not a Git repository: %s" [file tail
$p]]
1105 method _do_open2
{} {
1106 if {![_is_git
[file join $local_path .git
] actualgit
]} {
1107 error_popup
[mc
"Not a Git repository: %s" [file tail
$local_path]]
1111 if {[catch {cd $local_path} err
]} {
1112 error_popup
[strcat
\
1113 [mc
"Failed to open repository %s:" $local_path] \
1118 _append_recentrepos
[pwd]
1119 set ::_gitdir $actualgit