summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin von Zweigbergk <martin.von.zweigbergk@gmail.com>2011-04-04 22:14:12 -0400
committerPaul Mackerras <paulus@samba.org>2011-07-24 15:34:54 +1000
commitc332f44514375fd8e70da2c347b7bb8f2bd240f4 (patch)
tree1df8c7d9814eabbd91d914ba8e6ff3db449dca92
parentbb3e86a11946fdd1262e1be7c71065ba6d79d85a (diff)
downloadgit-c332f44514375fd8e70da2c347b7bb8f2bd240f4.tar.gz
gitk: Fix file highlight when run in subdirectory
The "highlight this only" and "highlight this too" commands in gitk add the path relative to $GIT_WORK_TREE to the "Find" input box. When the search (using git-diff-tree) is run, the paths are used unmodified, except for some shell escaping. Since the search is run from gitk's working directory, no commits matching the paths will be found if gitk was started in a subdirectory. Make the paths passed to git-diff-tree relative to gitk's working directory instead of being relative to $GIT_WORK_TREE. If, however, gitk is run outside of the working directory (e.g. with $GIT_WORK_TREE set), we still need to use the path relative to $GIT_WORK_TREE. Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com> Signed-off-by: Paul Mackerras <paulus@samba.org>
-rwxr-xr-xgitk11
1 files changed, 10 insertions, 1 deletions
diff --git a/gitk b/gitk
index 530b4c20fc..a1aec6202f 100755
--- a/gitk
+++ b/gitk
@@ -4527,12 +4527,17 @@ proc makepatterns {l} {
proc do_file_hl {serial} {
global highlight_files filehighlight highlight_paths gdttype fhl_list
+ global cdup
if {$gdttype eq [mc "touching paths:"]} {
if {[catch {set paths [shellsplit $highlight_files]}]} return
set highlight_paths [makepatterns $paths]
highlight_filelist
- set gdtargs [concat -- $paths]
+ set relative_paths {}
+ foreach path $paths {
+ lappend relative_paths [file join $cdup $path]
+ }
+ set gdtargs [concat -- $relative_paths]
} elseif {$gdttype eq [mc "adding/removing string:"]} {
set gdtargs [list "-S$highlight_files"]
} else {
@@ -11641,6 +11646,10 @@ set stuffsaved 0
set patchnum 0
set lserial 0
set isworktree [expr {[exec git rev-parse --is-inside-work-tree] == "true"}]
+set cdup {}
+if {$isworktree} {
+ set cdup [exec git rev-parse --show-cdup]
+}
setcoords
makewindow
catch {