]> granicus.if.org Git - git/commitdiff
git-gui: Add a 'recursive' checkbox in the clone menu.
authorHenri GEIST <geist.henri@laposte.net>
Tue, 11 Mar 2014 18:21:01 +0000 (19:21 +0100)
committerPat Thoyts <patthoyts@users.sourceforge.net>
Fri, 13 Jun 2014 18:12:52 +0000 (19:12 +0100)
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>
lib/choose_repository.tcl

index 3c10bc656d207553c8c093abcca275dd253a57fb..1209fa63e1cd72e5c1353edaa72c58cc38a020d6 100644 (file)
@@ -18,6 +18,7 @@ field local_path       {} ; # Where this repository is locally
 field origin_url       {} ; # Where we are cloning from
 field origin_name  origin ; # What we shall call 'origin'
 field clone_type hardlink ; # Type of clone to construct
+field recursive      true ; # Recursive cloning flag
 field readtree_err        ; # Error output from read-tree (if any)
 field sorted_recent       ; # recent repositories (sorted)
 
@@ -525,6 +526,11 @@ method _do_clone {} {
        foreach r $w_types {
                pack $r -anchor w
        }
+       ${NS}::checkbutton $args.type_f.recursive \
+               -text [mc "Recursively clone submodules too"] \
+               -variable @recursive \
+               -onvalue true -offvalue false
+       pack $args.type_f.recursive
        grid $args.type_l $args.type_f -sticky new
 
        grid columnconfigure $args 1 -weight 1
@@ -952,6 +958,30 @@ method _do_clone_checkout {HEAD} {
        fileevent $fd readable [cb _readtree_wait $fd]
 }
 
+method _do_validate_submodule_cloning {ok} {
+       if {$ok} {
+               $o_cons done $ok
+               set done 1
+       } else {
+               _clone_failed $this [mc "Cannot clone submodules."]
+       }
+}
+
+method _do_clone_submodules {} {
+       if {$recursive eq {true}} {
+               destroy $w_body
+               set o_cons [console::embed \
+                       $w_body \
+                       [mc "Cloning submodules"]]
+               pack $w_body -fill both -expand 1 -padx 10
+               $o_cons exec \
+                       [list git submodule update --init --recursive] \
+                       [cb _do_validate_submodule_cloning]
+       } else {
+               set done 1
+       }
+}
+
 method _readtree_wait {fd} {
        set buf [read $fd]
        $o_cons update_meter $buf
@@ -982,7 +1012,7 @@ method _readtree_wait {fd} {
                fconfigure $fd_ph -blocking 0 -translation binary -eofchar {}
                fileevent $fd_ph readable [cb _postcheckout_wait $fd_ph]
        } else {
-               set done 1
+               _do_clone_submodules $this
        }
 }
 
@@ -996,7 +1026,7 @@ method _postcheckout_wait {fd_ph} {
                        hook_failed_popup post-checkout $pch_error 0
                }
                unset pch_error
-               set done 1
+               _do_clone_submodules $this
                return
        }
        fconfigure $fd_ph -blocking 0