{"thread":{"id":"19614","subject":"[PATCH] Show selected subdirectory paths in gitk","startedAt":"2009-05-31T08:50:45Z","lastAt":"2009-05-31T08:50:45Z","messageCount":1,"participants":["Peter Baumann"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"115124","messageId":"20090531085045.GA8129@m62s10.vlinux.de","threadId":"19614","inReplyTo":null,"subject":"[PATCH] Show selected subdirectory paths in gitk","fromName":"Peter Baumann","fromEmail":"waste.manager@gmx.de","sentAt":"2009-05-31T08:50:45Z","receivedAt":"2009-05-31T08:50:45Z","isPatch":true,"sender":{"key":"waste.manager@gmx.de","avatar":null},"body":"Previously, running 'gitk -- file' in a subdirectory of the worktree didn't\nshow the file in the file selection widget. This is especially annoying if\nmultiple files and/or a subdirectory was given as parameter to gitk, because\nno visual reprasentation on the changed files was given besides the commit\ndiff itself.\n\nBy prefixing all file filters with the result of the newly added function\nget_subdir_prefix which returns the subdirectory relative to the GIT_DIR,\nwe make sure we always use the correct file name.\n\nSigned-off-by: Peter Baumann <waste.manager@gmx.de>\n---\n\nThe problem this patch fixes could be reproduced in the git repo by\n\n\tcd Documentation\n\tgitk git-add.txt\n\nRunning the above commands and you should not see any file listed in the\nfile selection widget in gitk. After applying the patch, the file is listed\nthere (for any non merge commit).\n\n\n gitk-git/gitk |   11 ++++++++++-\n 1 files changed, 10 insertions(+), 1 deletions(-)\n mode change 100644 => 100755 gitk-git/gitk\n\ndiff --git a/gitk-git/gitk b/gitk-git/gitk\nold mode 100644\nnew mode 100755\nindex 1a7887b..2355d82\n--- a/gitk-git/gitk\n+++ b/gitk-git/gitk\n@@ -7104,8 +7104,17 @@ proc startdiff {ids} {\n     }\n }\n \n+# Return the current subdirectory relative to the repository root\n+proc get_subdir_prefix {} {\n+    return [exec git rev-parse --show-prefix]\n+}\n+\n proc path_filter {filter name} {\n-    foreach p $filter {\n+    set prefix [get_subdir_prefix]\n+    foreach f $filter {\n+\t# get full pathname starting from the workdir root\n+\tset p \"$prefix$f\"\n+\n \tset l [string length $p]\n \tif {[string index $p end] eq \"/\"} {\n \t    if {[string compare -length $l $p $name] == 0} {\n-- \n1.6.3.1.70.ga80aa.dirty\n"}]}