gitk: make "touching paths" search support backslashes

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

 



>From bf31f7cf6faa7b786e231345b69826cc114001e0 Mon Sep 17 00:00:00 2001
From: Yggy King <yggy@xxxxxxxxxxxxx>
Date: Wed, 13 Jul 2011 01:15:51 -0700
Subject: [PATCH] gitk: make "touching paths" search support backslashes

Gitk can search for commits touching a specified path. The search text is
always treated as a regular expression, regardless of the matching option
selected (Exact, IgnCase, or Regexp). In particular, backslashes escape
the next character. This is inconvenient on Windows systems, where backslashes
are then norm for path specifiers, for example when copy/pasting from
Windows Explorer or a cmd shell -- these copy-pasted paths must be manually
modified in the gitk search text edit box before they will work.

This change uses the match option "Exact" to mean that a slash is a slash,
not part of a regular expression. Backslashes are converted to frontslashes
before searching, thus allowing easy copy/pasting of paths on Windows
systems. If the previous behaviour of "touching paths" search is desired,
simply select the "Regexp" search mode.

One potential drawback is that the default setting for the match option
($findtype in the code) is "Exact", and so this change alters the default
behaviour, which may confuse users and lead to bug reports.

(This is my first submission to the list -- please be gentle if I've
violated protocol. :-)

Signed-off-by: Yggy King <yggy@xxxxxxxxxxxxx>
---
 gitk-git/gitk |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/gitk-git/gitk b/gitk-git/gitk
index 4cde0c4..d5f604e 100755
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -4528,9 +4528,14 @@ proc makepatterns {l} {
 }

 proc do_file_hl {serial} {
-    global highlight_files filehighlight highlight_paths gdttype fhl_list
+    global highlight_files filehighlight highlight_paths gdttype
findtype fhl_list

     if {$gdttype eq [mc "touching paths:"]} {
+    # If "exact" match then convert backslashes to frontslashes. Most useful
+    # to support Windows-flavoured file paths.
+    if {$findtype eq [mc "Exact"]} {
+        set highlight_files [string map {"\\" "/"} $highlight_files]
+    }
 	if {[catch {set paths [shellsplit $highlight_files]}]} return
 	set highlight_paths [makepatterns $paths]
 	highlight_filelist
-- 
1.7.6.msysgit.0
--
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]