{"thread":{"id":"36123","subject":"[PATCH v2] git-gui: Add a 'recursive' checkbox in the clone menu.","startedAt":"2014-03-11T18:21:01Z","lastAt":"2014-03-11T18:21:01Z","messageCount":1,"participants":["Henri GEIST"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"236516","messageId":"1394562061.7891.64.camel@Naugrim","threadId":"36123","inReplyTo":null,"subject":"[PATCH v2] git-gui: Add a 'recursive' checkbox in the clone menu.","fromName":"Henri GEIST","fromEmail":"geist.henri@laposte.net","sentAt":"2014-03-11T18:21:01Z","receivedAt":"2014-03-11T18:21:01Z","isPatch":true,"sender":{"key":"geist.henri@laposte.net","avatar":"https://avatars.githubusercontent.com/u/42912271?v=4"},"body":"Permit to do a 'git clone --recursive' through git-gui.\nAdd a 'recursive' checkbox in the clone menu which allows\nusers to clone a repository and all its submodules in one\ngo (unless the 'update' flag is set to \"none\" in the\n.gitmodules file for a submodule, in that case that\nspecific submodule is not cloned automatically).\n\nEnable this new option per default, as most users want to\nclone all submodules too when cloning the superproject\n(This is currently not possible without leaving git gui\nor adding a custom tool entry for that).\n\nSigned-off-by: Henri GEIST <geist.henri@laposte.net>\nThanks-to: Jens Lehmann <Jens.Lehmann@web.de>\n---\n lib/choose_repository.tcl |   34 ++++++++++++++++++++++++++++++++--\n 1 file changed, 32 insertions(+), 2 deletions(-)\n\ndiff --git a/lib/choose_repository.tcl b/lib/choose_repository.tcl\nindex 3c10bc6..1209fa6 100644\n--- a/lib/choose_repository.tcl\n+++ b/lib/choose_repository.tcl\n@@ -18,6 +18,7 @@ field local_path       {} ; # Where this repository is locally\n field origin_url       {} ; # Where we are cloning from\n field origin_name  origin ; # What we shall call 'origin'\n field clone_type hardlink ; # Type of clone to construct\n+field recursive      true ; # Recursive cloning flag\n field readtree_err        ; # Error output from read-tree (if any)\n field sorted_recent       ; # recent repositories (sorted)\n \n@@ -525,6 +526,11 @@ method _do_clone {} {\n \tforeach r $w_types {\n \t\tpack $r -anchor w\n \t}\n+\t${NS}::checkbutton $args.type_f.recursive \\\n+\t\t-text [mc \"Recursively clone submodules too\"] \\\n+\t\t-variable @recursive \\\n+\t\t-onvalue true -offvalue false\n+\tpack $args.type_f.recursive\n \tgrid $args.type_l $args.type_f -sticky new\n \n \tgrid columnconfigure $args 1 -weight 1\n@@ -952,6 +958,30 @@ method _do_clone_checkout {HEAD} {\n \tfileevent $fd readable [cb _readtree_wait $fd]\n }\n \n+method _do_validate_submodule_cloning {ok} {\n+\tif {$ok} {\n+\t\t$o_cons done $ok\n+\t\tset done 1\n+\t} else {\n+\t\t_clone_failed $this [mc \"Cannot clone submodules.\"]\n+\t}\n+}\n+\n+method _do_clone_submodules {} {\n+\tif {$recursive eq {true}} {\n+\t\tdestroy $w_body\n+\t\tset o_cons [console::embed \\\n+\t\t\t$w_body \\\n+\t\t\t[mc \"Cloning submodules\"]]\n+\t\tpack $w_body -fill both -expand 1 -padx 10\n+\t\t$o_cons exec \\\n+\t\t\t[list git submodule update --init --recursive] \\\n+\t\t\t[cb _do_validate_submodule_cloning]\n+\t} else {\n+\t\tset done 1\n+\t}\n+}\n+\n method _readtree_wait {fd} {\n \tset buf [read $fd]\n \t$o_cons update_meter $buf\n@@ -982,7 +1012,7 @@ method _readtree_wait {fd} {\n \t\tfconfigure $fd_ph -blocking 0 -translation binary -eofchar {}\n \t\tfileevent $fd_ph readable [cb _postcheckout_wait $fd_ph]\n \t} else {\n-\t\tset done 1\n+\t\t_do_clone_submodules $this\n \t}\n }\n \n@@ -996,7 +1026,7 @@ method _postcheckout_wait {fd_ph} {\n \t\t\thook_failed_popup post-checkout $pch_error 0\n \t\t}\n \t\tunset pch_error\n-\t\tset done 1\n+\t\t_do_clone_submodules $this\n \t\treturn\n \t}\n \tfconfigure $fd_ph -blocking 0\n-- \n1.7.9.3.369.gd715.dirty\n"}]}