mirror of
https://github.com/git/git.git
synced 2026-02-22 07:44:55 +00:00
gitk: fix the display of files when filtered by path
Launching 'gitk -- .' or 'gitk -- ..\t' restricts the display to files under the given directory but the file list is left empty. This is because the path_filter function fails to match the filenames which are relative to the working tree to the filter which is filessytem relative. This solves the problem by making both names fully qualified filesystem paths before performing the comparison. Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net> Tested-by: David Aguilar <davvid@gmail.com> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
committed by
Johannes Schindelin
parent
b46eeaf0a7
commit
e5ee6d6b34
@@ -14,6 +14,26 @@ proc hasworktree {} {
|
||||
[exec git rev-parse --is-inside-git-dir] == "false"}]
|
||||
}
|
||||
|
||||
proc gitworktree {} {
|
||||
variable _gitworktree
|
||||
if {[info exists _gitworktree]} {
|
||||
return $_gitworktree
|
||||
}
|
||||
# v1.7.0 introduced --show-toplevel to return the canonical work-tree
|
||||
if {[catch {set _gitworktree [exec git rev-parse --show-toplevel]}]} {
|
||||
# try to set work tree from environment, core.worktree or use
|
||||
# cdup to obtain a relative path to the top of the worktree. If
|
||||
# run from the top, the ./ prefix ensures normalize expands pwd.
|
||||
if {[catch { set _gitworktree $env(GIT_WORK_TREE) }]} {
|
||||
catch {set _gitworktree [exec git config --get core.worktree]}
|
||||
if {$_gitworktree eq ""} {
|
||||
set _gitworktree [file normalize ./[exec git rev-parse --show-cdup]]
|
||||
}
|
||||
}
|
||||
}
|
||||
return $_gitworktree
|
||||
}
|
||||
|
||||
# A simple scheduler for compute-intensive stuff.
|
||||
# The aim is to make sure that event handlers for GUI actions can
|
||||
# run at least every 50-100 ms. Unfortunately fileevent handlers are
|
||||
@@ -7393,19 +7413,15 @@ proc startdiff {ids} {
|
||||
}
|
||||
}
|
||||
|
||||
# If the filename (name) is under any of the passed filter paths
|
||||
# then return true to include the file in the listing.
|
||||
proc path_filter {filter name} {
|
||||
set worktree [gitworktree]
|
||||
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
|
||||
}
|
||||
set fq_p [file normalize $p]
|
||||
set fq_n [file normalize [file join $worktree $name]]
|
||||
if {[string match [file normalize $fq_p]* $fq_n]} {
|
||||
return 1
|
||||
}
|
||||
}
|
||||
return 0
|
||||
|
||||
Reference in New Issue
Block a user