git-gui: teach fetch/prune menu to do it for all remotes
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>
Heiko Voigt committed
Feb 13, 2011 at 14:57 UTC
69e21b8392ac74338f3378a63f3db6b9df5249d7
2 files changed
+74
lib/remote.tcl
+45
@@ -230,6 +230,45 @@ proc make_sure_remote_submenues_exist {remote_m} {
230
}
231
}
232
233
+proc update_all_remotes_menu_entry {} {
234
+ global all_remotes
235
+
236
+ set have_remote 0
237
+ foreach r $all_remotes {
238
+ set have_remote 1
239
+ }
240
+
241
+ set remote_m .mbar.remote
242
+ set fetch_m $remote_m.fetch
243
+ set prune_m $remote_m.prune
244
+ if {$have_remote} {
245
+ make_sure_remote_submenues_exist $remote_m
246
+ if {[$fetch_m entrycget 0 -label] ne "All"} {
247
+
248
+ $fetch_m insert 0 separator
249
+ $fetch_m insert 0 command \
250
+ -label "All" \
251
+ -command fetch_from_all
252
+
253
+ $prune_m insert 0 separator
254
+ $prune_m insert 0 command \
255
+ -label "All" \
256
+ -command prune_from_all
257
+ }
258
+ } else {
259
+ if {[winfo exists $fetch_m]} {
260
+ if {[$fetch_m type end] eq "separator"} {
261
+
262
+ delete_from_menu $fetch_m 0
263
+ delete_from_menu $fetch_m 0
264
+
265
+ delete_from_menu $prune_m 0
266
+ delete_from_menu $prune_m 0
267
+ }
268
+ }
269
+ }
270
+}
271
+
272
proc populate_remotes_menu {} {
273
global all_remotes
274
@@ -237,6 +276,8 @@ proc populate_remotes_menu {} {
276
add_fetch_entry $r
277
add_push_entry $r
278
}
279
+
280
+ update_all_remotes_menu_entry
281
}
282
283
proc add_single_remote {name location} {
@@ -252,6 +293,8 @@ proc add_single_remote {name location} {
293
294
add_fetch_entry $name
295
add_push_entry $name
296
+
297
+ update_all_remotes_menu_entry
298
}
299
300
proc delete_from_menu {menu name} {
@@ -281,4 +324,6 @@ proc remove_remote {name} {
324
delete_from_menu $remote_m.remove $name
325
# Not all remotes are in the push menu
326
catch { delete_from_menu $remote_m.push $name }
327
+
328
+ update_all_remotes_menu_entry
329
}
lib/transport.tcl
+29
@@ -20,6 +20,35 @@ proc prune_from {remote} {
20
console::exec $w [list git remote prune $remote]
21
}
22
23
+proc fetch_from_all {} {
24
+ set w [console::new \
25
+ [mc "fetch all remotes"] \
26
+ [mc "Fetching new changes from all remotes"]]
27
+
28
+ set cmd [list git fetch --all]
29
+ if {[is_config_true gui.pruneduringfetch]} {
30
+ lappend cmd --prune
31
+ }
32
+
33
+ console::exec $w $cmd
34
+}
35
+
36
+proc prune_from_all {} {
37
+ global all_remotes
38
+
39
+ set w [console::new \
40
+ [mc "remote prune all remotes"] \
41
+ [mc "Pruning tracking branches deleted from all remotes"]]
42
+
43
+ set cmd [list git remote prune]
44
+
45
+ foreach r $all_remotes {
46
+ lappend cmd $r
47
+ }
48
+
49
+ console::exec $w $cmd
50
+}
51
+
52
proc push_to {remote} {
53
set w [console::new \
54
[mc "push %s" $remote] \