git-gui: Add a 'recursive' checkbox in the clone menu.

Permit to do a 'git clone --recursive' through git-gui. Add a 'recursive' checkbox in the clone menu which allows users to clone a repository and all its submodules in one go (unless the 'update' flag is set to "none" in the .gitmodules file for a submodule, in that case that specific submodule is not cloned automatically). Enable this new option per default, as most users want to clone all submodules too when cloning the superproject (This is currently not possible without leaving git gui or adding a custom tool entry for that). Signed-off-by: Henri GEIST <geist.henri@laposte.net> Thanks-to: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>

Henri GEIST committed Mar 11, 2014 at 19:21 UTC 2202b8b8bc40ede580490979007329f2d02387a8
1 file changed +32 -2
lib/choose_repository.tcl
+32 -2
@@ -18,6 +18,7 @@ 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)
24
@@ -525,6 +526,11 @@ method _do_clone {} {
526 foreach r $w_types {
527 pack $r -anchor w
528 }
529 + ${NS}::checkbutton $args.type_f.recursive \
530 + -text [mc "Recursively clone submodules too"] \
531 + -variable @recursive \
532 + -onvalue true -offvalue false
533 + pack $args.type_f.recursive
534 grid $args.type_l $args.type_f -sticky new
535
536 grid columnconfigure $args 1 -weight 1
@@ -952,6 +958,30 @@ method _do_clone_checkout {HEAD} {
958 fileevent $fd readable [cb _readtree_wait $fd]
959 }
960
961 +method _do_validate_submodule_cloning {ok} {
962 + if {$ok} {
963 + $o_cons done $ok
964 + set done 1
965 + } else {
966 + _clone_failed $this [mc "Cannot clone submodules."]
967 + }
968 +}
969 +
970 +method _do_clone_submodules {} {
971 + if {$recursive eq {true}} {
972 + destroy $w_body
973 + set o_cons [console::embed \
974 + $w_body \
975 + [mc "Cloning submodules"]]
976 + pack $w_body -fill both -expand 1 -padx 10
977 + $o_cons exec \
978 + [list git submodule update --init --recursive] \
979 + [cb _do_validate_submodule_cloning]
980 + } else {
981 + set done 1
982 + }
983 +}
984 +
985 method _readtree_wait {fd} {
986 set buf [read $fd]
987 $o_cons update_meter $buf
@@ -982,7 +1012,7 @@ method _readtree_wait {fd} {
1012 fconfigure $fd_ph -blocking 0 -translation binary -eofchar {}
1013 fileevent $fd_ph readable [cb _postcheckout_wait $fd_ph]
1014 } else {
985 - set done 1
1015 + _do_clone_submodules $this
1016 }
1017 }
1018
@@ -996,7 +1026,7 @@ method _postcheckout_wait {fd_ph} {
1026 hook_failed_popup post-checkout $pch_error 0
1027 }
1028 unset pch_error
999 - set done 1
1029 + _do_clone_submodules $this
1030 return
1031 }
1032 fconfigure $fd_ph -blocking 0