if {$p eq {}
|| $current_diff_side eq {}
|| [catch {set s $file_states($p)}]
- || [lsearch -sorted $file_lists($current_diff_side) $p] == -1} {
+ || [lsearch -sorted -exact $file_lists($current_diff_side) $p] == -1} {
clear_diff
} else {
show_diff $p $current_diff_side
if {$diff_active || ![lock_index read]} return
clear_diff
- if {$w eq {} || $lno == {}} {
- foreach w [array names file_lists] {
- set lno [lsearch -sorted $file_lists($w) $path]
- if {$lno >= 0} {
- incr lno
- break
- }
+ if {$lno == {}} {
+ set lno [lsearch -sorted -exact $file_lists($w) $path]
+ if {$lno >= 0} {
+ incr lno
}
}
- if {$w ne {} && $lno >= 1} {
+ if {$lno >= 1} {
$w tag add in_diff $lno.0 [expr {$lno + 1}].0
}
global file_lists
if {$new_m eq {_}} {
- set lno [lsearch -sorted $file_lists($w) $path]
+ set lno [lsearch -sorted -exact $file_lists($w) $path]
if {$lno >= 0} {
set file_lists($w) [lreplace $file_lists($w) $lno $lno]
incr lno
} elseif {$old_m eq {_} && $new_m ne {_}} {
lappend file_lists($w) $path
set file_lists($w) [lsort -unique $file_lists($w)]
- set lno [lsearch -sorted $file_lists($w) $path]
+ set lno [lsearch -sorted -exact $file_lists($w) $path]
incr lno
$w conf -state normal
$w image create $lno.0 \
}
}
- $m add separator
+ if {$all_heads ne {}} {
+ $m add separator
+ }
foreach b $all_heads {
$m add radiobutton \
-label $b \
if {[catch {exec git update-ref -d "refs/heads/$b" $o} err]} {
append failed " - $b: $err\n"
} else {
- set x [lsearch -sorted $all_heads $b]
+ set x [lsearch -sorted -exact $all_heads $b]
if {$x >= 0} {
set all_heads [lreplace $all_heads $x $x]
}
return
}
+ # -- Don't do a pointless switch.
+ #
+ if {$current_branch eq $new_branch} {
+ unlock_index
+ return
+ }
+
if {$repo_config(gui.trustmtime) eq {true}} {
switch_branch_stage2 {} $new_branch
} else {
set all_remotes [lsort -unique $all_remotes]
}
-proc populate_fetch_menu {m} {
+proc populate_fetch_menu {} {
global all_remotes repo_config
+ set m .mbar.fetch
foreach r $all_remotes {
set enable 0
if {![catch {set a $repo_config(remote.$r.url)}]} {
}
}
-proc populate_push_menu {m} {
+proc populate_push_menu {} {
global all_remotes repo_config
+ set m .mbar.push
foreach r $all_remotes {
set enable 0
if {![catch {set a $repo_config(remote.$r.url)}]} {
}
}
-proc populate_pull_menu {m} {
- global repo_config all_remotes disable_on_lock
-
- foreach remote $all_remotes {
- set rb_list [list]
- if {[array get repo_config remote.$remote.url] ne {}} {
- if {[array get repo_config remote.$remote.fetch] ne {}} {
- foreach line $repo_config(remote.$remote.fetch) {
- if {[regexp {^([^:]+):} $line line rb]} {
- lappend rb_list $rb
- }
- }
- }
- } else {
- catch {
- set fd [open [gitdir remotes $remote] r]
- while {[gets $fd line] >= 0} {
- if {[regexp {^Pull:[ \t]*([^:]+):} $line line rb]} {
- lappend rb_list $rb
- }
- }
- close $fd
- }
- }
-
- foreach rb $rb_list {
- regsub ^refs/heads/ $rb {} rb_short
- $m add command \
- -label "Branch $rb_short from $remote..." \
- -command [list pull_remote $remote $rb] \
- -font font_ui
- lappend disable_on_lock \
- [list $m entryconf [$m index last] -state]
- }
- }
-}
-
######################################################################
##
## icons
.mbar add cascade -label Commit -menu .mbar.commit
if {!$single_commit} {
.mbar add cascade -label Fetch -menu .mbar.fetch
- .mbar add cascade -label Pull -menu .mbar.pull
.mbar add cascade -label Push -menu .mbar.push
}
. configure -menu .mbar
#
if {!$single_commit} {
menu .mbar.fetch
- menu .mbar.pull
menu .mbar.push
}
load_all_heads
populate_branch_menu
- populate_fetch_menu .mbar.fetch
- populate_pull_menu .mbar.pull
- populate_push_menu .mbar.push
+ populate_fetch_menu
+ populate_push_menu
}
# -- Only suggest a gc run if we are going to stay running.