git-gui: Always use lsearch -exact, to prevent globbing.
Anytime we are using lsearch we are doing [lsearch -sorted] and we are applying it to file paths (or file path like things). Its valid for these to contain special glob characters, but when that happens we do not want globbing to occur. Instead we really need exact match semantics. Always supplying -exact to lsearch will ensure that is the case. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce committed
Jan 25, 2007 at 22:38 UTC
156b29211ae4f8143f143fd6cce6e93b60c51f43
1 file changed
+5
-5
git-gui.sh
+5
-5
@@ -568,7 +568,7 @@ proc reshow_diff {} {
568
if {$p eq {}
569
|| $current_diff_side eq {}
570
|| [catch {set s $file_states($p)}]
571
- || [lsearch -sorted $file_lists($current_diff_side) $p] == -1} {
571
+ || [lsearch -sorted -exact $file_lists($current_diff_side) $p] == -1} {
572
clear_diff
573
} else {
574
show_diff $p $current_diff_side
@@ -608,7 +608,7 @@ proc show_diff {path w {lno {}}} {
608
609
clear_diff
610
if {$lno == {}} {
611
- set lno [lsearch -sorted $file_lists($w) $path]
611
+ set lno [lsearch -sorted -exact $file_lists($w) $path]
612
if {$lno >= 0} {
613
incr lno
614
}
@@ -1427,7 +1427,7 @@ proc display_file_helper {w path icon_name old_m new_m} {
1427
global file_lists
1428
1429
if {$new_m eq {_}} {
1430
- set lno [lsearch -sorted $file_lists($w) $path]
1430
+ set lno [lsearch -sorted -exact $file_lists($w) $path]
1431
if {$lno >= 0} {
1432
set file_lists($w) [lreplace $file_lists($w) $lno $lno]
1433
incr lno
@@ -1438,7 +1438,7 @@ proc display_file_helper {w path icon_name old_m new_m} {
1438
} elseif {$old_m eq {_} && $new_m ne {_}} {
1439
lappend file_lists($w) $path
1440
set file_lists($w) [lsort -unique $file_lists($w)]
1441
- set lno [lsearch -sorted $file_lists($w) $path]
1441
+ set lno [lsearch -sorted -exact $file_lists($w) $path]
1442
incr lno
1443
$w conf -state normal
1444
$w image create $lno.0 \
@@ -2142,7 +2142,7 @@ Delete the selected branches?}
2142
if {[catch {exec git update-ref -d "refs/heads/$b" $o} err]} {
2143
append failed " - $b: $err\n"
2144
} else {
2145
- set x [lsearch -sorted $all_heads $b]
2145
+ set x [lsearch -sorted -exact $all_heads $b]
2146
if {$x >= 0} {
2147
set all_heads [lreplace $all_heads $x $x]
2148
}