git-gui: Include version check and test for tearoff menu entry
The --all option for git fetch was added in v1.6.6 so ensure we have a usable version before adding the menu items. Sometimes people use tearoff menus and these offset the entry indices by one. Acked-by: Heiko Voigt <hvoigt@hvoigt.net> Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
Pat Thoyts committed
Feb 15, 2011 at 00:20 UTC
ba44692a2ecedacfc48c28fba642876d49dec90a
1 file changed
+14
-10
lib/remote.tcl
+14
-10
@@ -233,6 +233,8 @@ proc make_sure_remote_submenues_exist {remote_m} {
233
proc update_all_remotes_menu_entry {} {
234
global all_remotes
235
236
+ if {[git-version < 1.6.6]} { return }
237
+
238
set have_remote 0
239
foreach r $all_remotes {
240
set have_remote 1
@@ -243,27 +245,29 @@ proc update_all_remotes_menu_entry {} {
245
set prune_m $remote_m.prune
246
if {$have_remote} {
247
make_sure_remote_submenues_exist $remote_m
246
- if {[$fetch_m entrycget 0 -label] ne "All"} {
248
+ set index [expr {[$fetch_m type 0] eq "tearoff" ? 1 : 0}]
249
+ if {[$fetch_m entrycget $index -label] ne "All"} {
250
248
- $fetch_m insert 0 separator
249
- $fetch_m insert 0 command \
251
+ $fetch_m insert $index separator
252
+ $fetch_m insert $index command \
253
-label "All" \
254
-command fetch_from_all
255
253
- $prune_m insert 0 separator
254
- $prune_m insert 0 command \
255
- -label "All" \
256
+ $prune_m insert $index separator
257
+ $prune_m insert $index command \
258
+ -label "All" \
259
-command prune_from_all
260
}
261
} else {
262
if {[winfo exists $fetch_m]} {
263
+ set index [expr {[$fetch_m type 0] eq "tearoff" ? 1 : 0}]
264
if {[$fetch_m type end] eq "separator"} {
265
262
- delete_from_menu $fetch_m 0
263
- delete_from_menu $fetch_m 0
266
+ delete_from_menu $fetch_m $index
267
+ delete_from_menu $fetch_m $index
268
265
- delete_from_menu $prune_m 0
266
- delete_from_menu $prune_m 0
269
+ delete_from_menu $prune_m $index
270
+ delete_from_menu $prune_m $index
271
}
272
}
273
}