From: Ping Yin Date: Fri, 02 May 2008 14:26:45 GMT Subject: Re: [PATCH] Make boundary characters for --color-words configurable Message-ID: <46dff0320805020726y2592732cj9aef0111e5b2288a@mail.gmail.com> In-Reply-To: <1209736766-8029-1-git-send-email-pkufranky@gmail.com> On Fri, May 2, 2008 at 9:59 PM, Ping Yin wrote: > Previously --color-words only allow spaces as boundary characters. > However, just space is not enough. For example, when i rename a function > from foo to bar, following example doesn't show as expected when using > --color-words. > > ------------------ > - if (foo(arg)) > + if (bar(arg)) > ------------------ > > It shows as "if (foo(arg))(foo(arg))". Actually, it's the > best to show as "if (foobar(arg))". Here "r" and "g" > represent "red" and "green" separately. > > This patch introduces a configuration diff.nonwordchars to make > --color-words treat both spaces and characters in diff.nonwordchars as > boundary characters. > > If we set diff.nonwordchars to "()", the example above will show as > "if (foo(bar(arg))". It's much better, athough not the best, > Oh, there are some problems, assuming "{}" are set as diff.nonwordchars 1. Trailing boundary character lost, for example ---------------------------- $ git diff- - foo{ + foo $ git diff --color-words foo ---------------------------- With --color-words, i can't know the trailing '{' is removed. This problem exists even without my patch. In that case, only trainling spaces are lost. 2. Trailing removed words shows at new line instead of the same line ---------------------------- $ git diff - foo bar + foo (note: no space after foo) $ git diff --color-words foo bar -------------------------------- bar should show in the same line with bar. This is not related to my patch. -- Ping Yin