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 \
global all_heads null_sha1 repo_config
global create_branch_checkout create_branch_revtype
global create_branch_head create_branch_trackinghead
+ global create_branch_name create_branch_revexp
- set newbranch [string trim [$w.desc.name_t get 0.0 end]]
+ set newbranch $create_branch_name
if {$newbranch eq {}
|| $newbranch eq $repo_config(gui.newbranchtemplate)} {
tk_messageBox \
switch -- $create_branch_revtype {
head {set rev $create_branch_head}
tracking {set rev $create_branch_trackinghead}
- expression {set rev [string trim [$w.from.exp_t get 0.0 end]]}
+ expression {set rev $create_branch_revexp}
}
if {[catch {set cmt [exec git rev-parse --verify "${rev}^0"]}]} {
tk_messageBox \
global all_heads current_branch repo_config
global create_branch_checkout create_branch_revtype
global create_branch_head create_branch_trackinghead
+ global create_branch_name create_branch_revexp
set w .branch_editor
toplevel $w
-text {Branch Description} \
-font font_ui
label $w.desc.name_l -text {Name:} -font font_ui
- text $w.desc.name_t \
+ entry $w.desc.name_t \
-borderwidth 1 \
-relief sunken \
- -height 1 \
-width 40 \
- -font font_ui
- $w.desc.name_t insert 0.0 $repo_config(gui.newbranchtemplate)
- grid $w.desc.name_l $w.desc.name_t -sticky we -padx {0 5}
- bind $w.desc.name_t <Shift-Key-Tab> {focus [tk_focusPrev %W];break}
- bind $w.desc.name_t <Key-Tab> {focus [tk_focusNext %W];break}
- bind $w.desc.name_t <Key-Return> "do_create_branch_action $w;break"
- bind $w.desc.name_t <Key> {
- if {{%K} ne {BackSpace}
- && {%K} ne {Tab}
- && {%K} ne {Escape}
- && {%K} ne {Return}} {
- if {%k <= 32} break
- if {[string first %A {~^:?*[}] >= 0} break
+ -textvariable create_branch_name \
+ -font font_ui \
+ -validate key \
+ -validatecommand {
+ if {%d == 1 && [regexp {[~^:?*\[\0- ]} %S]} {return 0}
+ return 1
}
- }
+ grid $w.desc.name_l $w.desc.name_t -sticky we -padx {0 5}
grid columnconfigure $w.desc 1 -weight 1
pack $w.desc -anchor nw -fill x -pady 5 -padx 5
-value expression \
-variable create_branch_revtype \
-font font_ui
- text $w.from.exp_t \
+ entry $w.from.exp_t \
-borderwidth 1 \
-relief sunken \
- -height 1 \
-width 50 \
- -font font_ui
+ -textvariable create_branch_revexp \
+ -font font_ui \
+ -validate key \
+ -validatecommand {
+ if {%d == 1 && [regexp {\s} %S]} {return 0}
+ if {%d == 1 && [string length %S] > 0} {
+ set create_branch_revtype expression
+ }
+ return 1
+ }
grid $w.from.exp_r $w.from.exp_t -sticky we -padx {0 5}
- bind $w.from.exp_t <Shift-Key-Tab> {focus [tk_focusPrev %W];break}
- bind $w.from.exp_t <Key-Tab> {focus [tk_focusNext %W];break}
- bind $w.from.exp_t <Key-Return> "do_create_branch_action $w;break"
- bind $w.from.exp_t <Key-space> break
- bind $w.from.exp_t <Key> {set create_branch_revtype expression}
grid columnconfigure $w.from 1 -weight 1
pack $w.from -anchor nw -fill x -pady 5 -padx 5
set create_branch_checkout 1
set create_branch_head $current_branch
set create_branch_revtype head
+ set create_branch_name $repo_config(gui.newbranchtemplate)
+ set create_branch_revexp {}
- bind $w <Visibility> "grab $w; focus $w.desc.name_t"
+ bind $w <Visibility> "
+ grab $w
+ $w.desc.name_t icursor end
+ focus $w.desc.name_t
+ "
bind $w <Key-Escape> "destroy $w"
bind $w <Key-Return> "do_create_branch_action $w;break"
wm title $w "[appname] ([reponame]): Create Branch"
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
label $w.stat.v_$name -text $value -anchor w -font font_ui
grid $w.stat.l_$name $w.stat.v_$name -sticky we -padx {0 5}
}
- pack $w.stat
+ pack $w.stat -pady 10 -padx 10
bind $w <Visibility> "grab $w; focus $w"
bind $w <Key-Escape> [list destroy $w]
pack $w.buttons.restore -side left
button $w.buttons.save -text Save \
-font font_ui \
- -command "
- catch {eval \[bind \[focus -displayof $w\] <FocusOut>\]}
- do_save_config $w
- "
+ -command [list do_save_config $w]
pack $w.buttons.save -side right
button $w.buttons.cancel -text {Cancel} \
-font font_ui \
t {
frame $w.$f.$name
label $w.$f.$name.l -text "$text:" -font font_ui
- text $w.$f.$name.v \
+ entry $w.$f.$name.v \
-borderwidth 1 \
-relief sunken \
- -height 1 \
-width 20 \
+ -textvariable ${f}_config_new(gui.$name) \
-font font_ui
- $w.$f.$name.v insert 0.0 [set ${f}_config_new(gui.$name)]
- bind $w.$f.$name.v <Shift-Key-Tab> {focus [tk_focusPrev %W];break}
- bind $w.$f.$name.v <Key-Tab> {focus [tk_focusNext %W];break}
- bind $w.$f.$name.v <Key-Return> break
- bind $w.$f.$name.v <FocusIn> "$w.$f.$name.v tag add sel 0.0 end"
- bind $w.$f.$name.v <FocusOut> "
- set ${f}_config_new(gui.$name) \
- \[string trim \[$w.$f.$name.v get 0.0 end\]\]
- "
pack $w.$f.$name.l -side left -anchor w
pack $w.$f.$name.v -side left -anchor w \
-fill x -expand 1 \
.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
-label {Visualize Current Branch} \
-command {do_gitk {}} \
-font font_ui
-if {![is_MacOSX]} {
- .mbar.repository add command \
- -label {Visualize All Branches} \
- -command {do_gitk {--all}} \
- -font font_ui
-}
+.mbar.repository add command \
+ -label {Visualize All Branches} \
+ -command {do_gitk {--all}} \
+ -font font_ui
.mbar.repository add separator
if {!$single_commit} {
#
if {!$single_commit} {
menu .mbar.fetch
- menu .mbar.pull
menu .mbar.push
}
bind $ui_diff <Key-Down> {catch {%W yview scroll 1 units};break}
bind $ui_diff <Key-Left> {catch {%W xview scroll -1 units};break}
bind $ui_diff <Key-Right> {catch {%W xview scroll 1 units};break}
+bind $ui_diff <Button-1> {focus %W}
if {!$single_commit} {
bind . <$M1B-Key-n> do_create_branch
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.