gitk: Improve handling of whitespace and special chars in filenames
commit9396cd385ad47f9ecb440221bbff4514f4378f7f
authorPaul Mackerras <paulus@samba.org>
Sat, 23 Jun 2007 10:28:15 +0000 (23 20:28 +1000)
committerPaul Mackerras <paulus@samba.org>
Sat, 23 Jun 2007 10:58:12 +0000 (23 20:58 +1000)
treecb5499a962cb2d48f18cd81f3155768a5a259cd7
parentf3326b66bf8d77c19b5ca7ad70e536251c81cccb
gitk: Improve handling of whitespace and special chars in filenames

The main thing here is better parsing of the diff --git lines in the
output of git diff-tree -p.  We now cope with filenames in quotes with
special chars escaped.  If the filenames contain spaces they aren't
quoted, however, which can create difficulties in parsing.  We get
around the difficulties by detecting the case when the filename hasn't
changed (chop the part after "diff --git " in two and see if the halves
match apart from a/ in one and b/ in the other), and if it hasn't
changed, we just use one half.  If the filename has changed we wait
for the "rename from" and "rename to" lines, which give the old and
new filenames unambiguously.

This also improves the parsing of the output of git diff-tree.
Instead of using lindex to extract the filename, we take the part from
the first tab on, and if it starts with a quote, we use [lindex $str 0]
to remove the quotes and convert the escapes.

This also gets rid of some unused tagging of the diff text, uses
[string compare] instead of [regexp] in some places, and fixes the
regexp for detecting the @@ hunk-separator lines (the regexp wasn't
accepting a single number, as in "-0,0 +1" for example).

Signed-off-by: Paul Mackerras <paulus@samba.org>
gitk