git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Show selected subdirectory paths in gitk

From
PBPeter Baumann <waste.manager@gmx.de>
Date
May 31, 2009, 08:50 UTC
Message-ID
<20090531085045.GA8129@m62s10.vlinux.de>

Previously, running 'gitk -- file' in a subdirectory of the worktree didn't show the file in the file selection widget. This is especially annoying if multiple files and/or a subdirectory was given as parameter to gitk, because no visual reprasentation on the changed files was given besides the commit diff itself.

By prefixing all file filters with the result of the newly added function get_subdir_prefix which returns the subdirectory relative to the GIT_DIR, we make sure we always use the correct file name.

Signed-off-by: Peter Baumann <waste.manager@gmx.de>
---
The problem this patch fixes could be reproduced in the git repo by
	cd Documentation
	gitk git-add.txt

Running the above commands and you should not see any file listed in the file selection widget in gitk. After applying the patch, the file is listed there (for any non merge commit).

 gitk-git/gitk |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)
 mode change 100644 => 100755 gitk-git/gitk
diff --git a/gitk-git/gitk b/gitk-git/gitk
old mode 100644
new mode 100755
index 1a7887b..2355d82
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -7104,8 +7104,17 @@ proc startdiff {ids} {
     }
 }
 
+# Return the current subdirectory relative to the repository root
+proc get_subdir_prefix {} {
+    return [exec git rev-parse --show-prefix]
+}
+
 proc path_filter {filter name} {
-    foreach p $filter {
+    set prefix [get_subdir_prefix]
+    foreach f $filter {
+	# get full pathname starting from the workdir root
+	set p "$prefix$f"
+
 	set l [string length $p]
 	if {[string index $p end] eq "/"} {
 	    if {[string compare -length $l $p $name] == 0} {
-- 
1.6.3.1.70.ga80aa.dirty
Message 1 of 1 in “Show selected subdirectory paths in gitk”
  1. Show selected subdirectory paths in gitkPeter Baumann, May 31, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.