Code

git-gui: teach fetch/prune menu to do it for all remotes
authorHeiko Voigt <hvoigt@hvoigt.net>
Sun, 13 Feb 2011 13:57:15 +0000 (14:57 +0100)
committerPat Thoyts <patthoyts@users.sourceforge.net>
Mon, 14 Feb 2011 12:15:36 +0000 (12:15 +0000)
The commandline fetch already has this option for some time.  Since this
was not available at the time git gui was written lets implement it now.

Signed-off-by: Heiko Voigt <heiko.voigt@mahr.de>
Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
lib/remote.tcl
lib/transport.tcl

index cf2fc9501df78029977e0c9e360863808a6ee55f..817ca1b6a3b5cb2ee2616d60cbaaa263387c4906 100644 (file)
@@ -230,6 +230,45 @@ proc make_sure_remote_submenues_exist {remote_m} {
        }
 }
 
+proc update_all_remotes_menu_entry {} {
+       global all_remotes
+
+       set have_remote 0
+       foreach r $all_remotes {
+               set have_remote 1
+       }
+
+       set remote_m .mbar.remote
+       set fetch_m $remote_m.fetch
+       set prune_m $remote_m.prune
+       if {$have_remote} {
+               make_sure_remote_submenues_exist $remote_m
+               if {[$fetch_m entrycget 0 -label] ne "All"} {
+
+                       $fetch_m insert 0 separator
+                       $fetch_m insert 0 command \
+                               -label "All" \
+                               -command fetch_from_all
+
+                       $prune_m insert 0 separator
+                       $prune_m insert 0 command \
+                               -label "All" \
+                               -command prune_from_all
+               }
+       } else {
+               if {[winfo exists $fetch_m]} {
+                       if {[$fetch_m type end] eq "separator"} {
+
+                               delete_from_menu $fetch_m 0
+                               delete_from_menu $fetch_m 0
+
+                               delete_from_menu $prune_m 0
+                               delete_from_menu $prune_m 0
+                       }
+               }
+       }
+}
+
 proc populate_remotes_menu {} {
        global all_remotes
 
@@ -237,6 +276,8 @@ proc populate_remotes_menu {} {
                add_fetch_entry $r
                add_push_entry $r
        }
+
+       update_all_remotes_menu_entry
 }
 
 proc add_single_remote {name location} {
@@ -252,6 +293,8 @@ proc add_single_remote {name location} {
 
        add_fetch_entry $name
        add_push_entry $name
+
+       update_all_remotes_menu_entry
 }
 
 proc delete_from_menu {menu name} {
@@ -281,4 +324,6 @@ proc remove_remote {name} {
        delete_from_menu $remote_m.remove $name
        # Not all remotes are in the push menu
        catch { delete_from_menu $remote_m.push $name }
+
+       update_all_remotes_menu_entry
 }
index 3067058857b335c2fdd7ec0bae6f2ea6a737d619..7fad9b7d91a6d6a0671ca7bac714dcc4fd022403 100644 (file)
@@ -20,6 +20,35 @@ proc prune_from {remote} {
        console::exec $w [list git remote prune $remote]
 }
 
+proc fetch_from_all {} {
+       set w [console::new \
+               [mc "fetch all remotes"] \
+               [mc "Fetching new changes from all remotes"]]
+
+       set cmd [list git fetch --all]
+       if {[is_config_true gui.pruneduringfetch]} {
+               lappend cmd --prune
+       }
+
+       console::exec $w $cmd
+}
+
+proc prune_from_all {} {
+       global all_remotes
+
+       set w [console::new \
+               [mc "remote prune all remotes"] \
+               [mc "Pruning tracking branches deleted from all remotes"]]
+
+       set cmd [list git remote prune]
+
+       foreach r $all_remotes {
+               lappend cmd $r
+       }
+
+       console::exec $w $cmd
+}
+
 proc push_to {remote} {
        set w [console::new \
                [mc "push %s" $remote] \