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)
12 field w_types
; # List of type buttons in clone
13 field w_recentlist
; # Listbox containing recent repositories
14 field w_localpath
; # Entry widget bound to local_path
16 field done
0 ; # Finished picking the repository?
17 field local_path
{} ; # Where this repository is locally
18 field origin_url
{} ; # Where we are cloning from
19 field origin_name origin
; # What we shall call 'origin'
20 field clone_type hardlink
; # Type of clone to construct
21 field recursive true
; # Recursive cloning flag
22 field readtree_err
; # Error output from read-tree (if any)
23 field sorted_recent
; # recent repositories (sorted)
26 global M1T M1B use_ttk NS
28 if {[set maxrecent
[get_config gui.maxrecentrepo
]] eq
{}} {
33 wm title
$top [mc
"Git Gui"]
36 menu $w.mbar
-tearoff 0
37 $top configure
-menu $w.mbar
39 set m_repo
$w.mbar.repository
41 -label [mc Repository
] \
46 $w.mbar add cascade
-label Apple
-menu .mbar.apple
48 $w.mbar.apple add command
\
49 -label [mc
"About %s" [appname
]] \
51 $w.mbar.apple add command
\
52 -label [mc
"Show SSH Key"] \
55 $w.mbar add cascade
-label [mc Help
] -menu $w.mbar.help
57 $w.mbar.help add command
\
58 -label [mc
"About %s" [appname
]] \
60 $w.mbar.help add command
\
61 -label [mc
"Show SSH Key"] \
65 wm protocol
$top WM_DELETE_WINDOW
exit
66 bind $top <$M1B-q
> exit
67 bind $top <$M1B-Q
> exit
68 bind $top <Key-Escape
> exit
70 wm geometry
$top "+[winfo rootx .]+[winfo rooty .]"
71 bind $top <Key-Escape
> [list destroy $top]
75 pack [git_logo
$w.git_logo
] -side left
-fill y
-padx 10 -pady 10
78 set opts
$w_body.
options
81 -cursor $::cursor_ptr \
83 -background [get_bg_color
$w_body] \
88 pack $opts -anchor w
-fill x
90 $opts tag conf link_new
-foreground blue
-underline 1
91 $opts tag
bind link_new
<1> [cb _next new
]
92 $opts insert end
[mc
"Create New Repository"] link_new
96 -command [cb _next new
] \
99 bind $top <$M1B-n
> [cb _next new
]
100 bind $top <$M1B-N
> [cb _next new
]
103 $opts tag conf link_clone
-foreground blue
-underline 1
104 $opts tag
bind link_clone
<1> [cb _next clone
]
105 $opts insert end
[mc
"Clone Existing Repository"] link_clone
106 $opts insert end
"\n"
108 if {[tk windowingsystem
] eq
"win32"} {
113 $m_repo add command
\
114 -command [cb _next clone
] \
115 -accelerator $M1T-$key \
116 -label [mc
"Clone..."]
117 bind $top <$M1B-[string tolower
$key]> [cb _next clone
]
118 bind $top <$M1B-[string toupper
$key]> [cb _next clone
]
121 $opts tag conf link_open
-foreground blue
-underline 1
122 $opts tag
bind link_open
<1> [cb _next
open]
123 $opts insert end
[mc
"Open Existing Repository"] link_open
124 $opts insert end
"\n"
126 $m_repo add command
\
127 -command [cb _next
open] \
128 -accelerator $M1T-O
\
129 -label [mc
"Open..."]
130 bind $top <$M1B-o
> [cb _next
open]
131 bind $top <$M1B-O
> [cb _next
open]
134 $opts conf
-state disabled
136 set sorted_recent
[_get_recentrepos
]
137 if {[llength $sorted_recent] > 0} {
139 $m_repo add separator
140 $m_repo add command
\
142 -label [mc
"Recent Repositories"]
145 ${NS
}::label $w_body.space
146 ${NS
}::label $w_body.recentlabel
\
148 -text [mc
"Open Recent Repository:"]
149 set w_recentlist
$w_body.recentlist
151 -cursor $::cursor_ptr \
153 -background [get_bg_color
$w_body.recentlabel
] \
157 $w_recentlist tag conf link
\
160 set home
$::env(HOME
)
162 set home
[exec cygpath
--windows --absolute $home]
164 set home
"[file normalize $home]/"
165 set hlen
[string length
$home]
166 foreach p
$sorted_recent {
168 if {[string equal
-length $hlen $home $p]} {
169 set p
"~/[string range $p $hlen end]"
171 regsub -all "\n" $p "\\n" p
172 $w_recentlist insert end
$p link
173 $w_recentlist insert end
"\n"
176 $m_repo add command
\
177 -command [cb _open_recent_path
$path] \
181 $w_recentlist conf
-state disabled
182 $w_recentlist tag
bind link
<1> [cb _open_recent
%x
,%y
]
183 pack $w_body.space
-anchor w
-fill x
184 pack $w_body.recentlabel
-anchor w
-fill x
185 pack $w_recentlist -anchor w
-fill x
187 pack $w_body -fill x
-padx 10 -pady 10
189 ${NS
}::frame $w.buttons
190 set w_next
$w.buttons.next
191 set w_quit
$w.buttons.quit
192 ${NS
}::button $w_quit \
195 pack $w_quit -side right
-padx 5
196 pack $w.buttons
-side bottom
-fill x
-padx 10 -pady 10
199 $m_repo add separator
200 $m_repo add command
\
206 bind $top <Return
> [cb _invoke_next
]
207 bind $top <Visibility
> "
211 bind $top <Visibility> {}
214 tkwait variable @done
218 eval destroy [winfo children
$top]
223 set nx
[winfo reqwidth
$top]
224 set ny
[winfo reqheight
$top]
225 set rx
[expr {([winfo screenwidth
$top] - $nx) / 3}]
226 set ry
[expr {([winfo screenheight
$top] - $ny) / 3}]
227 wm geometry
$top [format {+%d
+%d
} $rx $ry]
230 method _invoke_next
{} {
231 if {[winfo exists
$w_next]} {
232 uplevel #0 [$w_next cget -command]
236 proc _get_recentrepos
{} {
238 foreach p
[get_config gui.recentrepo
] {
239 if {[_is_git
[file join $p .git
]]} {
245 return [lsort $recent]
248 proc _unset_recentrepo
{p
} {
249 regsub -all -- {([()\[\]{}\.^
$+*?
\\])} $p {\\\1} p
250 git config
--global --unset gui.recentrepo
"^$p\$"
254 proc _append_recentrepos
{path
} {
255 set path
[file normalize
$path]
256 set recent
[get_config gui.recentrepo
]
258 if {[lindex $recent end
] eq
$path} {
262 set i
[lsearch $recent $path]
264 _unset_recentrepo
$path
265 set recent
[lreplace $recent $i $i]
269 git config
--global --add gui.recentrepo
$path
272 if {[set maxrecent
[get_config gui.maxrecentrepo
]] eq
{}} {
276 while {[llength $recent] > $maxrecent} {
277 _unset_recentrepo
[lindex $recent 0]
278 set recent
[lrange $recent 1 end
]
282 method _open_recent
{xy
} {
283 set id
[lindex [split [$w_recentlist index
@$xy] .
] 0]
284 set local_path
[lindex $sorted_recent [expr {$id - 1}]]
288 method _open_recent_path
{p
} {
293 method _next
{action
} {
296 if {![winfo exists
$w_next]} {
297 ${NS
}::button $w_next -default active
299 if {[tk windowingsystem
] eq
"win32"} { set pos
-after }
300 pack $w_next -side right
-padx 5 $pos $w_quit
305 method _write_local_path
{args
} {
306 if {$local_path eq
{}} {
307 $w_next conf
-state disabled
309 $w_next conf
-state normal
313 method _git_init
{} {
314 if {[catch {file mkdir
$local_path} err
]} {
315 error_popup
[strcat
\
316 [mc
"Failed to create repository %s:" $local_path] \
321 if {[catch {cd $local_path} err
]} {
322 error_popup
[strcat
\
323 [mc
"Failed to create repository %s:" $local_path] \
328 if {[catch {git init
} err
]} {
329 error_popup
[strcat
\
330 [mc
"Failed to create repository %s:" $local_path] \
335 _append_recentrepos
[pwd]
341 proc _is_git
{path
} {
342 if {[file isfile
$path]} {
343 set fp
[open $path r
]
346 if {[regexp "^gitdir: (.+)$" $line line link_target
]} {
347 set path
[file join [file dirname
$path] $link_target]
348 set path
[file normalize
$path]
352 if {[file exists
[file join $path HEAD
]]
353 && [file exists
[file join $path objects
]]
354 && [file exists
[file join $path config
]]} {
358 if {[file exists
[file join $path HEAD
]]
359 && [file exists
[file join $path objects.lnk
]]
360 && [file exists
[file join $path config.lnk
]]} {
367 proc _objdir
{path
} {
368 set objdir
[file join $path .git objects
]
369 if {[file isdirectory
$objdir]} {
373 set objdir
[file join $path objects
]
374 if {[file isdirectory
$objdir]} {
379 set objdir
[file join $path .git objects.lnk
]
380 if {[file isfile
$objdir]} {
381 return [win32_read_lnk
$objdir]
384 set objdir
[file join $path objects.lnk
]
385 if {[file isfile
$objdir]} {
386 return [win32_read_lnk
$objdir]
393 ######################################################################
395 ## Create New Repository
401 -command [cb _do_new2
] \
405 ${NS
}::label $w_body.h
\
406 -font font_uibold
-anchor center
\
407 -text [mc
"Create New Repository"]
408 pack $w_body.h
-side top
-fill x
-pady 10
409 pack $w_body -fill x
-padx 10
411 ${NS
}::frame $w_body.where
412 ${NS
}::label $w_body.where.l
-text [mc
"Directory:"]
413 ${NS
}::entry $w_body.where.t
\
414 -textvariable @local_path
\
416 ${NS
}::button $w_body.where.b
\
417 -text [mc
"Browse"] \
418 -command [cb _new_local_path
]
419 set w_localpath
$w_body.where.t
421 grid $w_body.where.l
$w_body.where.t
$w_body.where.b
-sticky ew
422 pack $w_body.where
-fill x
424 grid columnconfigure
$w_body.where
1 -weight 1
426 trace add
variable @local_path write
[cb _write_local_path
]
427 bind $w_body.h
<Destroy
> [list trace remove
variable @local_path write
[cb _write_local_path
]]
429 focus $w_body.where.t
432 method _new_local_path
{} {
433 if {$local_path ne
{}} {
434 set p
[file dirname
$local_path]
439 set p
[tk_chooseDirectory \
442 -title [mc
"Git Repository"] \
446 set p
[file normalize
$p]
451 $w_localpath icursor end
455 if {![_new_ok
$local_path]} {
458 if {![_git_init
$this]} {
465 if {[file isdirectory
$p]} {
466 if {[_is_git
[file join $p .git
]]} {
467 error_popup
[mc
"Directory %s already exists." $p]
470 } elseif
{[file exists
$p]} {
471 error_popup
[mc
"File %s already exists." $p]
477 ######################################################################
479 ## Clone Existing Repository
481 method _do_clone
{} {
485 -command [cb _do_clone2
] \
489 ${NS
}::label $w_body.h
\
490 -font font_uibold
-anchor center
\
491 -text [mc
"Clone Existing Repository"]
492 pack $w_body.h
-side top
-fill x
-pady 10
493 pack $w_body -fill x
-padx 10
495 set args
$w_body.args
496 ${NS
}::frame $w_body.args
497 pack $args -fill both
499 ${NS
}::label $args.origin_l
-text [mc
"Source Location:"]
500 ${NS
}::entry $args.origin_t
\
501 -textvariable @origin_url
\
503 ${NS
}::button $args.origin_b
\
504 -text [mc
"Browse"] \
505 -command [cb _open_origin
]
506 grid $args.origin_l
$args.origin_t
$args.origin_b
-sticky ew
508 ${NS
}::label $args.where_l
-text [mc
"Target Directory:"]
509 ${NS
}::entry $args.where_t
\
510 -textvariable @local_path
\
512 ${NS
}::button $args.where_b
\
513 -text [mc
"Browse"] \
514 -command [cb _new_local_path
]
515 grid $args.where_l
$args.where_t
$args.where_b
-sticky ew
516 set w_localpath
$args.where_t
518 ${NS
}::label $args.type_l
-text [mc
"Clone Type:"]
519 ${NS
}::frame $args.type_f
521 lappend w_types
[${NS
}::radiobutton $args.type_f.hardlink
\
523 -text [mc
"Standard (Fast, Semi-Redundant, Hardlinks)"] \
524 -variable @clone_type
\
526 lappend w_types
[${NS
}::radiobutton $args.type_f.full
\
528 -text [mc
"Full Copy (Slower, Redundant Backup)"] \
529 -variable @clone_type
\
531 lappend w_types
[${NS
}::radiobutton $args.type_f.shared
\
533 -text [mc
"Shared (Fastest, Not Recommended, No Backup)"] \
534 -variable @clone_type
\
539 ${NS
}::checkbutton $args.type_f.recursive
\
540 -text [mc
"Recursively clone submodules too"] \
541 -variable @recursive
\
542 -onvalue true
-offvalue false
543 pack $args.type_f.recursive
-anchor w
544 grid $args.type_l
$args.type_f
-sticky new
546 grid columnconfigure
$args 1 -weight 1
548 trace add
variable @local_path write
[cb _update_clone
]
549 trace add
variable @origin_url write
[cb _update_clone
]
550 bind $w_body.h
<Destroy
> "
551 [list trace remove variable @local_path write [cb _update_clone]]
552 [list trace remove variable @origin_url write [cb _update_clone]]
558 method _open_origin
{} {
559 if {$origin_url ne
{} && [file isdirectory
$origin_url]} {
565 set p
[tk_chooseDirectory \
568 -title [mc
"Git Repository"] \
572 set p
[file normalize
$p]
573 if {![_is_git
[file join $p .git
]] && ![_is_git
$p]} {
574 error_popup
[mc
"Not a Git repository: %s" [file tail
$p]]
580 method _update_clone
{args
} {
581 if {$local_path ne
{} && $origin_url ne
{}} {
582 $w_next conf
-state normal
584 $w_next conf
-state disabled
587 if {$origin_url ne
{} &&
588 ( [_is_git
[file join $origin_url .git
]]
589 ||
[_is_git
$origin_url])} {
591 if {[[lindex $w_types 0] cget
-state] eq
{disabled
}} {
592 set clone_type hardlink
604 method _do_clone2
{} {
605 if {[file isdirectory
$origin_url]} {
606 set origin_url
[file normalize
$origin_url]
609 if {$clone_type eq
{hardlink
} && ![file isdirectory
$origin_url]} {
610 error_popup
[mc
"Standard only available for local repository."]
613 if {$clone_type eq
{shared
} && ![file isdirectory
$origin_url]} {
614 error_popup
[mc
"Shared only available for local repository."]
618 if {$clone_type eq
{hardlink
} ||
$clone_type eq
{shared
}} {
619 set objdir
[_objdir
$origin_url]
621 error_popup
[mc
"Not a Git repository: %s" [file tail
$origin_url]]
626 set giturl
$origin_url
627 if {[is_Cygwin
] && [file isdirectory
$giturl]} {
628 set giturl
[exec cygpath
--unix --absolute $giturl]
629 if {$clone_type eq
{shared
}} {
630 set objdir
[exec cygpath
--unix --absolute $objdir]
634 if {[file exists
$local_path]} {
635 error_popup
[mc
"Location %s already exists." $local_path]
639 if {![_git_init
$this]} return
643 git config remote.
$origin_name.url
$giturl
644 git config remote.
$origin_name.fetch
+refs
/heads
/*:refs
/remotes
/$origin_name/*
646 error_popup
[strcat
[mc
"Failed to configure origin"] "\n\n$err"]
650 destroy $w_body $w_next
652 switch -exact -- $clone_type {
654 set o_cons
[status_bar
::two_line $w_body]
655 pack $w_body -fill x
-padx 10 -pady 10
658 [mc
"Counting objects"] \
662 if {[file exists
[file join $objdir info alternates
]]} {
665 file mkdir
[gitdir objects
info]
666 set f_in
[open [file join $objdir info alternates
] r
]
667 set f_cp
[open [gitdir objects
info alternates
] w
]
668 fconfigure $f_in -translation binary -encoding binary
669 fconfigure $f_cp -translation binary -encoding binary
671 while {[gets $f_in line
] >= 0} {
673 puts $f_cp [exec cygpath
--unix --absolute $line]
675 puts $f_cp [file normalize
$line]
683 _clone_failed
$this [mc
"Unable to copy objects/info/alternates: %s" $err]
692 -directory [file join $objdir] ??
]
693 set bcnt
[expr {[llength $buckets] + 2}]
695 $o_cons update $bcur $bcnt
698 file mkdir
[file join .git objects
pack]
699 foreach i
[glob -tails -nocomplain \
700 -directory [file join $objdir pack] *] {
701 lappend tolink
[file join pack $i]
703 $o_cons update [incr bcur
] $bcnt
707 file mkdir
[file join .git objects
$i]
708 foreach j
[glob -tails -nocomplain \
709 -directory [file join $objdir $i] *] {
710 lappend tolink
[file join $i $j]
712 $o_cons update [incr bcur
] $bcnt
719 [mc
"Nothing to clone from %s." $origin_url] \
721 [mc
"The 'master' branch has not been initialized."] \
728 set i
[lindex $tolink 0]
731 [file join .git objects
$i] \
732 [file join $objdir $i]
734 info_popup
[mc
"Hardlinks are unavailable. Falling back to copying."]
735 set i
[_copy_files
$this $objdir $tolink]
737 set i
[_link_files
$this $objdir [lrange $tolink 1 end
]]
744 set o_cons
[console::embed \
746 [mc
"Cloning from %s" $origin_url]]
747 pack $w_body -fill both
-expand 1 -padx 10
749 [list git fetch
--no-tags
-k $origin_name] \
753 set fd
[open [gitdir objects
info alternates
] w
]
754 fconfigure $fd -translation binary
760 if {$clone_type eq
{hardlink
} ||
$clone_type eq
{shared
}} {
761 if {![_clone_refs
$this]} return
765 set HEAD
[git rev-parse
--verify HEAD^
0]
767 _clone_failed
$this [mc
"Not a Git repository: %s" [file tail
$origin_url]]
771 _do_clone_checkout
$this $HEAD
775 method _copy_files
{objdir tocopy
} {
777 [mc
"Copying objects"] \
782 incr tot
[file size
[file join $objdir $p]]
786 set f_in
[open [file join $objdir $p] r
]
787 set f_cp
[open [file join .git objects
$p] w
]
788 fconfigure $f_in -translation binary -encoding binary
789 fconfigure $f_cp -translation binary -encoding binary
791 while {![eof $f_in]} {
792 incr cmp
[fcopy $f_in $f_cp -size 16384]
794 [expr {$cmp / 1024}] \
802 _clone_failed
$this [mc
"Unable to copy object: %s" $err]
809 method _link_files
{objdir tolink
} {
810 set total
[llength $tolink]
812 [mc
"Linking objects"] \
814 for {set i
0} {$i < $total} {} {
815 set p
[lindex $tolink $i]
818 [file join .git objects
$p] \
819 [file join $objdir $p]
821 _clone_failed
$this [mc
"Unable to hardlink object: %s" $err]
827 $o_cons update $i $total
834 method _clone_refs
{} {
836 if {[catch {cd $origin_url} err
]} {
837 error_popup
[mc
"Not a Git repository: %s" [file tail
$origin_url]]
840 set fd_in
[git_read for-each-ref
\
842 {--format=list %(refname
) %(objectname
) %(*objectname
)}]
845 set fd
[open [gitdir packed-refs
] w
]
846 fconfigure $fd -translation binary
847 puts $fd "# pack-refs with: peeled"
848 while {[gets $fd_in line
] >= 0} {
849 set line
[eval $line]
850 set refn
[lindex $line 0]
851 set robj
[lindex $line 1]
852 set tobj
[lindex $line 2]
854 if {[regsub ^refs
/heads
/ $refn \
855 "refs/remotes/$origin_name/" refn
]} {
856 puts $fd "$robj $refn"
857 } elseif
{[string match refs
/tags
/* $refn]} {
858 puts $fd "$robj $refn"
869 method _do_clone_tags
{ok
} {
872 [list git fetch
--tags -k $origin_name] \
876 _clone_failed
$this [mc
"Cannot fetch branches and objects. See console output for details."]
880 method _do_clone_HEAD
{ok
} {
883 [list git fetch
$origin_name HEAD
] \
884 [cb _do_clone_full_end
]
887 _clone_failed
$this [mc
"Cannot fetch tags. See console output for details."]
891 method _do_clone_full_end
{ok
} {
898 if {[file exists
[gitdir FETCH_HEAD
]]} {
899 set fd
[open [gitdir FETCH_HEAD
] r
]
900 while {[gets $fd line
] >= 0} {
901 if {[regexp "^(.{40})\t\t" $line line HEAD
]} {
908 catch {git pack-refs
}
909 _do_clone_checkout
$this $HEAD
911 _clone_failed
$this [mc
"Cannot determine HEAD. See console output for details."]
915 method _clone_failed
{{why
{}}} {
916 if {[catch {file delete
-force $local_path} err
]} {
920 [mc
"Unable to cleanup %s" $local_path] \
926 error_popup
[strcat
[mc
"Clone failed."] "\n" $why]
930 method _do_clone_checkout
{HEAD
} {
933 [mc
"No default branch obtained."] \
935 [mc
"The 'master' branch has not been initialized."] \
941 git update-ref HEAD
$HEAD^
0
944 [mc
"Cannot resolve %s as a commit." $HEAD^
0] \
947 [mc
"The 'master' branch has not been initialized."] \
953 set o_cons
[status_bar
::two_line $w_body]
954 pack $w_body -fill x
-padx 10 -pady 10
956 [mc
"Creating working directory"] \
960 set fd
[git_read
--stderr read-tree
\
967 fconfigure $fd -blocking 0 -translation binary
968 fileevent $fd readable
[cb _readtree_wait
$fd]
971 method _do_validate_submodule_cloning
{ok
} {
976 _clone_failed
$this [mc
"Cannot clone submodules."]
980 method _do_clone_submodules
{} {
981 if {$recursive eq
{true
}} {
983 set o_cons
[console::embed \
985 [mc
"Cloning submodules"]]
986 pack $w_body -fill both
-expand 1 -padx 10
988 [list git submodule
update --init --recursive] \
989 [cb _do_validate_submodule_cloning
]
995 method _readtree_wait
{fd
} {
997 $o_cons update_meter
$buf
998 append readtree_err
$buf
1000 fconfigure $fd -blocking 1
1002 fconfigure $fd -blocking 0
1006 if {[catch {close $fd}]} {
1007 set err
$readtree_err
1008 regsub {^fatal
: } $err {} err
1009 error_popup
[strcat
\
1010 [mc
"Initial file checkout failed."] \
1015 # -- Run the post-checkout hook.
1017 set fd_ph
[githook_read post-checkout
[string repeat
0 40] \
1018 [git rev-parse HEAD
] 1]
1022 fconfigure $fd_ph -blocking 0 -translation binary -eofchar {}
1023 fileevent $fd_ph readable
[cb _postcheckout_wait
$fd_ph]
1025 _do_clone_submodules
$this
1029 method _postcheckout_wait
{fd_ph
} {
1032 append pch_error
[read $fd_ph]
1033 fconfigure $fd_ph -blocking 1
1035 if {[catch {close $fd_ph}]} {
1036 hook_failed_popup post-checkout
$pch_error 0
1039 _do_clone_submodules
$this
1042 fconfigure $fd_ph -blocking 0
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
]]} {
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]