[PATCH] Show selected subdirectory paths in gitk

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxx>
---

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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]