* [GITK PATCH] gitk: support "gitk <tracheophyte> -- ." [not found] ` <alpine.DEB.1.00.1002201920350.20986@pacific.mpi-cbg.de> @ 2010-02-23 16:51 ` Johannes Schindelin 2010-02-23 17:10 ` [GITK PATCH 2/3] gitk: support path filters even in subdirectories Johannes Schindelin 0 siblings, 1 reply; 10+ messages in thread From: Johannes Schindelin @ 2010-02-23 16:51 UTC (permalink / raw) To: Pat Thoyts, Paul Mackerras; +Cc: Kirill, msysgit, git It might be unintuitive to a user when "gitk HEAD -- ." does not show any files in the lower right pane. This patch fixes that. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> --- My initial analysis was all wrong. Pat: does this look correct to you? Kirill: does this fix the issue on your side, too? Paul: since we need this for Git Cheetah, and you are probably too busy to apply/review in the next few weeks, I took the liberty of keeping it as a git.git patch. Let me know if I you want it in a different form that does not require git-am's -p2 option. gitk-git/gitk | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/gitk-git/gitk b/gitk-git/gitk index cdedaa7..553922f 100644 --- a/gitk-git/gitk +++ b/gitk-git/gitk @@ -7341,6 +7341,9 @@ proc startdiff {ids} { proc path_filter {filter name} { foreach p $filter { + if {$p == "."} { + return 1 + } set l [string length $p] if {[string index $p end] eq "/"} { if {[string compare -length $l $p $name] == 0} { -- 1.6.4.297.gcb4cc ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [GITK PATCH 2/3] gitk: support path filters even in subdirectories 2010-02-23 16:51 ` [GITK PATCH] gitk: support "gitk <tracheophyte> -- ." Johannes Schindelin @ 2010-02-23 17:10 ` Johannes Schindelin 2010-02-23 17:12 ` [GITK PATCH 3/3] gitk: strip prefix from filenames " Johannes Schindelin 2010-02-23 19:37 ` [GITK PATCH 2/3] gitk: support path filters even " Kirill 0 siblings, 2 replies; 10+ messages in thread From: Johannes Schindelin @ 2010-02-23 17:10 UTC (permalink / raw) To: Pat Thoyts, Paul Mackerras; +Cc: Kirill, msysgit, git Even when running inside a subdirectory, "gitk HEAD -- ." should work. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> --- gitk-git/gitk | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/gitk-git/gitk b/gitk-git/gitk index 553922f..bad9ebc 100644 --- a/gitk-git/gitk +++ b/gitk-git/gitk @@ -7340,9 +7340,12 @@ proc startdiff {ids} { } proc path_filter {filter name} { + global pathprefix foreach p $filter { if {$p == "."} { - return 1 + set p $pathprefix + } else { + set p $pathprefix$p } set l [string length $p] if {[string index $p end] eq "/"} { @@ -11585,6 +11588,7 @@ readrefs if {$cmdline_files ne {} || $revtreeargs ne {} || $revtreeargscmd ne {}} { # create a view for the files/dirs specified on the command line + set pathprefix [exec git rev-parse --show-prefix] set curview 1 set selectedview 1 set nextviewnum 2 -- 1.6.4.297.gcb4cc ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [GITK PATCH 3/3] gitk: strip prefix from filenames in subdirectories 2010-02-23 17:10 ` [GITK PATCH 2/3] gitk: support path filters even in subdirectories Johannes Schindelin @ 2010-02-23 17:12 ` Johannes Schindelin 2010-02-23 19:42 ` Kirill 2010-02-23 19:37 ` [GITK PATCH 2/3] gitk: support path filters even " Kirill 1 sibling, 1 reply; 10+ messages in thread From: Johannes Schindelin @ 2010-02-23 17:12 UTC (permalink / raw) To: Pat Thoyts, Paul Mackerras; +Cc: Kirill, msysgit, git Again in the lower right panel, where the file names of the files touched by the current commit are clickable: let's not show the prefix when we are in a subdirectory, as it wastes precious screen estate conveying information the user already knows. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> --- Sorry, I tested 1/3 only in the gitk-git/ subdirectory. And of course, I was bitten by the fact that this subdirectory is pulled using the subtree strategy, so there are files in the history which lack the prefix. Therefore, I saw the files even if the fix was incomplete. gitk-git/gitk | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/gitk-git/gitk b/gitk-git/gitk index bad9ebc..0b2c351 100644 --- a/gitk-git/gitk +++ b/gitk-git/gitk @@ -3203,10 +3203,14 @@ proc unhighlight_filelist {} { } proc add_flist {fl} { - global cflist + global cflist pathprefix $cflist conf -state normal + set l [string length $pathprefix] foreach f $fl { + if {$l > 0 && [string compare -length $l $pathprefix $f] == 0} { + set f [string range $f $l end] + } $cflist insert end "\n" $cflist insert end $f [highlight_tag $f] } -- 1.6.4.297.gcb4cc ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [GITK PATCH 3/3] gitk: strip prefix from filenames in subdirectories 2010-02-23 17:12 ` [GITK PATCH 3/3] gitk: strip prefix from filenames " Johannes Schindelin @ 2010-02-23 19:42 ` Kirill 2010-02-23 20:50 ` Johannes Schindelin 0 siblings, 1 reply; 10+ messages in thread From: Kirill @ 2010-02-23 19:42 UTC (permalink / raw) To: Johannes Schindelin; +Cc: Pat Thoyts, Paul Mackerras, msysgit, git Hi, On Tue, Feb 23, 2010 at 12:12 PM, Johannes Schindelin wrote: > > Again in the lower right panel, where the file names of the files touched > by the current commit are clickable: let's not show the prefix when we > are in a subdirectory, as it wastes precious screen estate conveying > information the user already knows. Unfortunately, it seems to be too aggressive, leading to a misleading display. When gitk is invoked from a subdirectory but without the filter, the lower right panel displays some paths, relative to the root of the work tree, and some, relative to the wd: $ # fresh netinstall with checked out devel's $ cd / $ gitk --all & # 1 $ cd /bin $ gitk --all & # 2 1. bin/move-wiki.sh when devel is selected; share/WinGit/install.iss - when installer-improvements is selected (that's correct) 2. move-wiki.sh on devel; share/WinGit/install.iss on installer-improvements That's misleading. And honestly, I'm not that advanced in gitk use, so somebody will probably have to do some more testing. Thanks! -- Kirill. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [GITK PATCH 3/3] gitk: strip prefix from filenames in subdirectories 2010-02-23 19:42 ` Kirill @ 2010-02-23 20:50 ` Johannes Schindelin 2010-02-23 22:20 ` Kirill 0 siblings, 1 reply; 10+ messages in thread From: Johannes Schindelin @ 2010-02-23 20:50 UTC (permalink / raw) To: Kirill; +Cc: Pat Thoyts, Paul Mackerras, msysgit, git Hi, On Tue, 23 Feb 2010, Kirill wrote: > Unfortunately, it seems to be too aggressive, leading to a misleading > display. When gitk is invoked from a subdirectory but without the > filter, the lower right panel displays some paths, relative to the root > of the work tree, and some, relative to the wd: Right. I fixed it in 2/3: pathprefix is set to "" when no cmdline_files were specified (i.e. when there is no filter). An when pathprefix is "", nothing changes to the situation before. Good? Ciao, Dscho ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [GITK PATCH 3/3] gitk: strip prefix from filenames in subdirectories 2010-02-23 20:50 ` Johannes Schindelin @ 2010-02-23 22:20 ` Kirill 0 siblings, 0 replies; 10+ messages in thread From: Kirill @ 2010-02-23 22:20 UTC (permalink / raw) To: Johannes Schindelin; +Cc: Pat Thoyts, Paul Mackerras, msysgit, git Hi Dscho, On Tue, Feb 23, 2010 at 3:50 PM, Johannes Schindelin wrote: > On Tue, 23 Feb 2010, Kirill wrote: > >> Unfortunately, it seems to be too aggressive, leading to a misleading >> display. When gitk is invoked from a subdirectory but without the >> filter, the lower right panel displays some paths, relative to the root >> of the work tree, and some, relative to the wd: > > Right. I fixed it in 2/3: pathprefix is set to "" when no cmdline_files > were specified (i.e. when there is no filter). An when pathprefix is "", > nothing changes to the situation before. > > Good? Seems to work for me. Thank you! Pat, Paul, like I said, you would not want to take my testing seriously. -- Kirill. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [GITK PATCH 2/3] gitk: support path filters even in subdirectories 2010-02-23 17:10 ` [GITK PATCH 2/3] gitk: support path filters even in subdirectories Johannes Schindelin 2010-02-23 17:12 ` [GITK PATCH 3/3] gitk: strip prefix from filenames " Johannes Schindelin @ 2010-02-23 19:37 ` Kirill 2010-02-23 20:22 ` Johannes Schindelin 1 sibling, 1 reply; 10+ messages in thread From: Kirill @ 2010-02-23 19:37 UTC (permalink / raw) To: Johannes Schindelin; +Cc: Pat Thoyts, Paul Mackerras, msysgit, git Hi, Dscho, at first, thank you so much for working on the issue! In general the series work. At least, it passes my limited testing from the original message. However... On Tue, Feb 23, 2010 at 12:10 PM, Johannes Schindelin wrote: > > Even when running inside a subdirectory, "gitk HEAD -- ." should work. > > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> > --- > gitk-git/gitk | 6 +++++- > 1 files changed, 5 insertions(+), 1 deletions(-) > > diff --git a/gitk-git/gitk b/gitk-git/gitk > index 553922f..bad9ebc 100644 > --- a/gitk-git/gitk > +++ b/gitk-git/gitk > @@ -7340,9 +7340,12 @@ proc startdiff {ids} { > } > > proc path_filter {filter name} { > + global pathprefix > foreach p $filter { > if {$p == "."} { > - return 1 > + set p $pathprefix > + } else { > + set p $pathprefix$p > } > set l [string length $p] > if {[string index $p end] eq "/"} { > @@ -11585,6 +11588,7 @@ readrefs > > if {$cmdline_files ne {} || $revtreeargs ne {} || $revtreeargscmd ne {}} { > # create a view for the files/dirs specified on the command line > + set pathprefix [exec git rev-parse --show-prefix] I believe the fact that pathprefix is set only under several conditions, the invocation without arguments is broken. My .02 -- Kirill. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [GITK PATCH 2/3] gitk: support path filters even in subdirectories 2010-02-23 19:37 ` [GITK PATCH 2/3] gitk: support path filters even " Kirill @ 2010-02-23 20:22 ` Johannes Schindelin 2010-02-25 1:51 ` Pat Thoyts 0 siblings, 1 reply; 10+ messages in thread From: Johannes Schindelin @ 2010-02-23 20:22 UTC (permalink / raw) To: Kirill; +Cc: Pat Thoyts, Paul Mackerras, msysgit, git 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 ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [GITK PATCH 2/3] gitk: support path filters even in subdirectories 2010-02-23 20:22 ` Johannes Schindelin @ 2010-02-25 1:51 ` Pat Thoyts 2010-02-25 14:22 ` Johannes Schindelin 0 siblings, 1 reply; 10+ messages in thread From: Pat Thoyts @ 2010-02-25 1:51 UTC (permalink / raw) To: Johannes Schindelin; +Cc: Kirill, Paul Mackerras, msysgit, git On 23 February 2010 20:22, Johannes Schindelin <Johannes.Schindelin@gmx.de> 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" } } ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [GITK PATCH 2/3] gitk: support path filters even in subdirectories 2010-02-25 1:51 ` Pat Thoyts @ 2010-02-25 14:22 ` Johannes Schindelin 0 siblings, 0 replies; 10+ messages in thread From: Johannes Schindelin @ 2010-02-25 14:22 UTC (permalink / raw) To: Pat Thoyts; +Cc: Kirill, Paul Mackerras, msysgit, git Hi, On Thu, 25 Feb 2010, Pat Thoyts wrote: > proc path_filter {filter name} { > set name [file normalize $name] I am unconvinced that [file normalize] is what we want. It expands to an absolute path, which is almost certainly unnecessary code churn. I will have a look at your test cases and try to fix later. Ciao, Johannes ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2010-02-25 14:22 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <f579dd581002200847o340a3eb9l50d0f1329d4e2c23@mail.gmail.com> [not found] ` <alpine.DEB.1.00.1002201847290.20986@pacific.mpi-cbg.de> [not found] ` <a5b261831002200948v3c01708dv3e42d08d42e3119@mail.gmail.com> [not found] ` <alpine.DEB.1.00.1002201920350.20986@pacific.mpi-cbg.de> 2010-02-23 16:51 ` [GITK PATCH] gitk: support "gitk <tracheophyte> -- ." Johannes Schindelin 2010-02-23 17:10 ` [GITK PATCH 2/3] gitk: support path filters even in subdirectories Johannes Schindelin 2010-02-23 17:12 ` [GITK PATCH 3/3] gitk: strip prefix from filenames " Johannes Schindelin 2010-02-23 19:42 ` Kirill 2010-02-23 20:50 ` Johannes Schindelin 2010-02-23 22:20 ` Kirill 2010-02-23 19:37 ` [GITK PATCH 2/3] gitk: support path filters even " Kirill 2010-02-23 20:22 ` Johannes Schindelin 2010-02-25 1:51 ` Pat Thoyts 2010-02-25 14:22 ` Johannes Schindelin
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).