From: Johannes Sixt <j6t@kdbg•org>
To: Robert Dailey <rcdailey.lists@gmail•com>, Git <git@vger•kernel.org>
Subject: Re: xfuncname problems with C++
Date: Fri, 02 Jan 2015 21:31:06 +0100 [thread overview]
Message-ID: <54A7000A.3050605@kdbg.org> (raw)
In-Reply-To: <CAHd499C_Z_npG3ibv_gJSU7kqrT6=DRCV8TU9_sjz9zzQ7vC-Q@mail.gmail.com>
Am 02.01.2015 um 18:03 schrieb Robert Dailey:
> On Fri, Jan 2, 2015 at 10:49 AM, Robert Dailey <rcdailey.lists@gmail•com> wrote:
>> I have a function like so:
>>
>> void MyClass::SomeFunction(int someParameter)
>> {
>> // Stuff changed in here
>> }
>>
>> When I do `git diff` on the file containing this function, I get a
>> chunk showing some changed code in this function somewhere in the
>> middle of the body. However, the chunk header shows my root namespace
>> name in the file instead of the function header:
>>
>> @@ -144,15 +149,22 @@ namespace Utils
>>
>> What I expect to see:
>>
>> @@ -144,15 +149,22 @@ void MyClass::SomeFunction(int someParameter)
>>
>> I've tried various regular expressions that work in regex testers I
>> use against this function signature, however they do not work when I
>> apply them to my config:
>>
>> [diff "cpp"]
>> xfuncname =
>> "^\\s*[\\w_][\\w\\d_]*\\s*.*\\s*[\\w_][\\w\\d_]*\\s*\\(.*\\)\\s*$"
>>
>> File name is "foo.cpp", I even added it to my git attributes file:
>>
>> *.cpp diff=cpp
>>
>> Using the regex above, my chunk headers come back blank. Why is it
>> showing namespace? How do I make this match the nearest function
>> header?
>
> Oopsie, I didn't realize the regex must be POSIX compatible. I've
> updated the regex to this:
> https://www.regex101.com/r/kP3dM6
>
> The test seems to work; however git gives me an error with the regex
> when I do a diff:
>
> $ git diff Core
> fatal: Invalid regexp to look for hunk header:
> ^[[:space:]]*[[:word:]_][[:word:][:digit:]_]*[[:space:]]*.*[[:space:]]*[[:word:]_][[:word:][:digit:]_]*[[:space:]]*\(.*\)[[:space:]]*$
>
> Here is how it is stored in my .gitconfig:
>
> [diff "cpp"]
> xfuncname =
> "^[[:space:]]*[[:word:]_][[:word:][:digit:]_]*[[:space:]]*.*[[:space:]]*[[:word:]_][[:word:][:digit:]_]*[[:space:]]*\\(.*\\)[[:space:]]*$"
>
Perhaps there is a pair of parentheses missing that capture text for the
hunk header? I you intended that to be the part inside \(...\), then
that is wrong. Use unescapted parentheses.
There are two catch-all .* in your pattern. That is very suspicious,
particularly since the first one is outside the meant-to-be capturing
parentheses.
-- Hannes
next prev parent reply other threads:[~2015-01-02 20:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-02 16:49 xfuncname problems with C++ Robert Dailey
2015-01-02 17:03 ` Robert Dailey
2015-01-02 20:31 ` Johannes Sixt [this message]
2015-01-02 21:27 ` Robert Dailey
2015-01-02 22:05 ` Jonathan Nieder
2015-01-02 20:19 ` Jonathan Nieder
2015-01-02 20:25 ` Johannes Sixt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54A7000A.3050605@kdbg.org \
--to=j6t@kdbg$(echo .)org \
--cc=git@vger$(echo .)kernel.org \
--cc=rcdailey.lists@gmail$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox