On 23 February 2010 20:22, Johannes Schindelin <Johannes.Schindelin@xxxxxx> wrote: > Hi, > > On Tue, 23 Feb 2010, Kirill wrote: > >> I believe the fact that pathprefix is set only under several conditions, >> the invocation without arguments is broken. > > You are absolutely correct! > > Will fix and push to work/gitk-dashdash-dot, > Dscho This doesn't seem to work for me. We are trying to have the file tree window display filenames when 'gitk -- .' is used and with your patch this isn't happening when I apply this to gitk. I broke out the path_filter function into a separate test to play with it a bit. It seems this function is trying to match a path prefix to the provided file name so here is a test script with three implementations. The original, dscho's new one (git rev-parse --show-prefix returns an empty string when run in the toplevel directory so I force the 'pathprefix' variable for the tests). With this script I get the following results: C:\src\gitk>tclsh told.tcl original-2 failed . gitk expected 1 got 0 original-3 failed ./ gitk expected 1 got 0 original-5 failed ./po po/de.po expected 1 got 0 dscho-2 failed . gitk expected 1 got 0 dscho-3 failed ./ gitk expected 1 got 0 dscho-5 failed ./po po/de.po expected 1 got 0 So it looks like a simple string match on a normalized path works ok. [file normalize $name] doesn't require the target file to exists btw. --- test script begins --- proc path_filter_orig {filter name} { foreach p $filter { set l [string length $p] if {[string index $p end] eq "/"} { if {[string compare -length $l $p $name] == 0} { return 1 } } else { if {[string compare -length $l $p $name] == 0 && ([string length $name] == $l || [string index $name $l] eq "/")} { return 1 } } } return 0 } proc path_filter_dscho {filter name} { set pathprefix "" foreach p $filter { if {$p == "."} { set p $pathprefix } else { set p $pathprefix$p } set l [string length $p] if {[string index $p end] eq "/"} { if {[string compare -length $l $p $name] == 0} { return 1 } } else { if {[string compare -length $l $p $name] == 0 && ([string length $name] == $l || [string index $name $l] eq "/")} { return 1 } } } return 0 } proc path_filter {filter name} { set name [file normalize $name] foreach p $filter { set p [file normalize $p] if {[string equal $p $name] || [string match $p* $name]} { return 1 } } return 0 } set tests { 1 "" gitk 0 2 . gitk 1 3 ./ gitk 1 4 po po/de.po 1 5 ./po po/de.po 1 6 po gitk 0 7 po a/b 0 8 a a/b/c 1 } foreach {id filter name result} $tests { set testresult [path_filter_orig $filter $name] if {$testresult != $result} { puts "original-$id failed $filter $name expected $result got $testresult" } } foreach {id filter name result} $tests { set testresult [path_filter_dscho $filter $name] if {$testresult != $result} { puts "dscho-$id failed $filter $name expected $result got $testresult" } } foreach {id filter name result} $tests { set testresult [path_filter $filter $name] if {$testresult != $result} { puts "new-$id failed $filter $name expected $result got $testresult" } } -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html