git-gui: Always use lsearch -exact, to prevent globbing.
authorShawn O. Pearce <spearce@spearce.org>
Fri, 26 Jan 2007 03:38:59 +0000 (22:38 -0500)
committerShawn O. Pearce <spearce@spearce.org>
Fri, 26 Jan 2007 05:41:01 +0000 (00:41 -0500)
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>
git-gui.sh
index b0a195ce8a16a4a9868b5f23376af1f44759f7e3..b203c56a98a49c7344a9146e2c76af4e7f2adc27 100755 (executable)
@@ -568,7 +568,7 @@ proc reshow_diff {} {
        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
@@ -608,7 +608,7 @@ proc show_diff {path w {lno {}}} {
 
        clear_diff
        if {$lno == {}} {
-               set lno [lsearch -sorted $file_lists($w) $path]
+               set lno [lsearch -sorted -exact $file_lists($w) $path]
                if {$lno >= 0} {
                        incr lno
                }
@@ -1427,7 +1427,7 @@ proc display_file_helper {w path icon_name old_m new_m} {
        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
@@ -1438,7 +1438,7 @@ proc display_file_helper {w path icon_name old_m new_m} {
        } 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 \
@@ -2142,7 +2142,7 @@ Delete the selected branches?}
                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]
                        }