{"thread":{"id":"38272","subject":"xfuncname problems with C++","startedAt":"2015-01-02T16:49:12Z","lastAt":"2015-01-02T22:05:56Z","messageCount":7,"participants":["Robert Dailey","Jonathan Nieder","Johannes Sixt"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"254249","messageId":"CAHd499Cn8C51i_+Dm4h_U4X_Jc-nhNMjoufiZRdn5LGxFqD_HA@mail.gmail.com","threadId":"38272","inReplyTo":null,"subject":"xfuncname problems with C++","fromName":"Robert Dailey","fromEmail":"rcdailey.lists@gmail.com","sentAt":"2015-01-02T16:49:12Z","receivedAt":"2015-01-02T16:49:12Z","isPatch":false,"sender":{"key":"rcdailey.lists@gmail.com","avatar":null},"body":"I have a function like so:\n\nvoid MyClass::SomeFunction(int someParameter)\n{\n    // Stuff changed in here\n}\n\nWhen I do `git diff` on the file containing this function, I get a\nchunk showing some changed code in this function somewhere in the\nmiddle of the body. However, the chunk header shows my root namespace\nname in the file instead of the function header:\n\n@@ -144,15 +149,22 @@ namespace Utils\n\nWhat I expect to see:\n\n@@ -144,15 +149,22 @@ void MyClass::SomeFunction(int someParameter)\n\nI've tried various regular expressions that work in regex testers I\nuse against this function signature, however they do not work when I\napply them to my config:\n\n[diff \"cpp\"]\n    xfuncname =\n\"^\\\\s*[\\\\w_][\\\\w\\\\d_]*\\\\s*.*\\\\s*[\\\\w_][\\\\w\\\\d_]*\\\\s*\\\\(.*\\\\)\\\\s*$\"\n\nFile name is \"foo.cpp\", I even added it to my git attributes file:\n\n*.cpp diff=cpp\n\nUsing the regex above, my chunk headers come back blank. Why is it\nshowing namespace? How do I make this match the nearest function\nheader?\n"},{"id":"254250","messageId":"CAHd499C_Z_npG3ibv_gJSU7kqrT6=DRCV8TU9_sjz9zzQ7vC-Q@mail.gmail.com","threadId":"38272","inReplyTo":"CAHd499Cn8C51i_+Dm4h_U4X_Jc-nhNMjoufiZRdn5LGxFqD_HA@mail.gmail.com","subject":"Re: xfuncname problems with C++","fromName":"Robert Dailey","fromEmail":"rcdailey.lists@gmail.com","sentAt":"2015-01-02T17:03:34Z","receivedAt":"2015-01-02T17:03:34Z","isPatch":false,"sender":{"key":"rcdailey.lists@gmail.com","avatar":null},"body":"On Fri, Jan 2, 2015 at 10:49 AM, Robert Dailey <rcdailey.lists@gmail.com> wrote:\n> I have a function like so:\n>\n> void MyClass::SomeFunction(int someParameter)\n> {\n>     // Stuff changed in here\n> }\n>\n> When I do `git diff` on the file containing this function, I get a\n> chunk showing some changed code in this function somewhere in the\n> middle of the body. However, the chunk header shows my root namespace\n> name in the file instead of the function header:\n>\n> @@ -144,15 +149,22 @@ namespace Utils\n>\n> What I expect to see:\n>\n> @@ -144,15 +149,22 @@ void MyClass::SomeFunction(int someParameter)\n>\n> I've tried various regular expressions that work in regex testers I\n> use against this function signature, however they do not work when I\n> apply them to my config:\n>\n> [diff \"cpp\"]\n>     xfuncname =\n> \"^\\\\s*[\\\\w_][\\\\w\\\\d_]*\\\\s*.*\\\\s*[\\\\w_][\\\\w\\\\d_]*\\\\s*\\\\(.*\\\\)\\\\s*$\"\n>\n> File name is \"foo.cpp\", I even added it to my git attributes file:\n>\n> *.cpp diff=cpp\n>\n> Using the regex above, my chunk headers come back blank. Why is it\n> showing namespace? How do I make this match the nearest function\n> header?\n\nOopsie, I didn't realize the regex must be POSIX compatible. I've\nupdated the regex to this:\nhttps://www.regex101.com/r/kP3dM6\n\nThe test seems to work; however git gives me an error with the regex\nwhen I do a diff:\n\n$ git diff Core\nfatal: Invalid regexp to look for hunk header:\n^[[:space:]]*[[:word:]_][[:word:][:digit:]_]*[[:space:]]*.*[[:space:]]*[[:word:]_][[:word:][:digit:]_]*[[:space:]]*\\(.*\\)[[:space:]]*$\n\nHere is how it is stored in my .gitconfig:\n\n[diff \"cpp\"]\n    xfuncname =\n\"^[[:space:]]*[[:word:]_][[:word:][:digit:]_]*[[:space:]]*.*[[:space:]]*[[:word:]_][[:word:][:digit:]_]*[[:space:]]*\\\\(.*\\\\)[[:space:]]*$\"\n"},{"id":"254252","messageId":"20150102201959.GG29365@google.com","threadId":"38272","inReplyTo":"CAHd499Cn8C51i_+Dm4h_U4X_Jc-nhNMjoufiZRdn5LGxFqD_HA@mail.gmail.com","subject":"Re: xfuncname problems with C++","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2015-01-02T20:19:59Z","receivedAt":"2015-01-02T20:19:59Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi,\n\nRobert Dailey wrote:\n\n> I have a function like so:\n>\n> void MyClass::SomeFunction(int someParameter)\n> {\n>     // Stuff changed in here\n> }\n>\n> When I do `git diff` on the file containing this function, I get a\n> chunk showing some changed code in this function somewhere in the\n> middle of the body. However, the chunk header shows my root namespace\n> name in the file instead of the function header:\n>\n> @@ -144,15 +149,22 @@ namespace Utils\n>\n> What I expect to see:\n>\n> @@ -144,15 +149,22 @@ void MyClass::SomeFunction(int someParameter)\n\nWhat version of git are you using?  Could you give a full copy of the\ndiff so we can have more context (feeling free to mark parts of it as\nCENSORED where appropriate, but keeping leading whitespace and the\nfirst +/- column)?\n\nThanks,\nJonathan\n"},{"id":"254253","messageId":"54A6FEB6.40305@kdbg.org","threadId":"38272","inReplyTo":"CAHd499Cn8C51i_+Dm4h_U4X_Jc-nhNMjoufiZRdn5LGxFqD_HA@mail.gmail.com","subject":"Re: xfuncname problems with C++","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2015-01-02T20:25:26Z","receivedAt":"2015-01-02T20:25:26Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 02.01.2015 um 17:49 schrieb Robert Dailey:\n> I have a function like so:\n> \n> void MyClass::SomeFunction(int someParameter)\n> {\n>     // Stuff changed in here\n> }\n> \n> When I do `git diff` on the file containing this function, I get a\n> chunk showing some changed code in this function somewhere in the\n> middle of the body. However, the chunk header shows my root namespace\n> name in the file instead of the function header:\n> \n> @@ -144,15 +149,22 @@ namespace Utils\n> \n> What I expect to see:\n> \n> @@ -144,15 +149,22 @@ void MyClass::SomeFunction(int someParameter)\n> \n> I've tried various regular expressions that work in regex testers I\n> use against this function signature, however they do not work when I\n> apply them to my config:\n> \n> [diff \"cpp\"]\n>     xfuncname =\n> \"^\\\\s*[\\\\w_][\\\\w\\\\d_]*\\\\s*.*\\\\s*[\\\\w_][\\\\w\\\\d_]*\\\\s*\\\\(.*\\\\)\\\\s*$\"\n> \n> File name is \"foo.cpp\", I even added it to my git attributes file:\n> \n> *.cpp diff=cpp\n> \n> Using the regex above, my chunk headers come back blank. Why is it\n> showing namespace? How do I make this match the nearest function\n> header?\n> \n\nIs the line that contains 'void MyClass::...' before line 149? Does the\nword 'void' begin at the left-most column?\n\n-- Hannes\n"},{"id":"254255","messageId":"54A7000A.3050605@kdbg.org","threadId":"38272","inReplyTo":"CAHd499C_Z_npG3ibv_gJSU7kqrT6=DRCV8TU9_sjz9zzQ7vC-Q@mail.gmail.com","subject":"Re: xfuncname problems with C++","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2015-01-02T20:31:06Z","receivedAt":"2015-01-02T20:31:06Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 02.01.2015 um 18:03 schrieb Robert Dailey:\n> On Fri, Jan 2, 2015 at 10:49 AM, Robert Dailey <rcdailey.lists@gmail.com> wrote:\n>> I have a function like so:\n>>\n>> void MyClass::SomeFunction(int someParameter)\n>> {\n>>     // Stuff changed in here\n>> }\n>>\n>> When I do `git diff` on the file containing this function, I get a\n>> chunk showing some changed code in this function somewhere in the\n>> middle of the body. However, the chunk header shows my root namespace\n>> name in the file instead of the function header:\n>>\n>> @@ -144,15 +149,22 @@ namespace Utils\n>>\n>> What I expect to see:\n>>\n>> @@ -144,15 +149,22 @@ void MyClass::SomeFunction(int someParameter)\n>>\n>> I've tried various regular expressions that work in regex testers I\n>> use against this function signature, however they do not work when I\n>> apply them to my config:\n>>\n>> [diff \"cpp\"]\n>>     xfuncname =\n>> \"^\\\\s*[\\\\w_][\\\\w\\\\d_]*\\\\s*.*\\\\s*[\\\\w_][\\\\w\\\\d_]*\\\\s*\\\\(.*\\\\)\\\\s*$\"\n>>\n>> File name is \"foo.cpp\", I even added it to my git attributes file:\n>>\n>> *.cpp diff=cpp\n>>\n>> Using the regex above, my chunk headers come back blank. Why is it\n>> showing namespace? How do I make this match the nearest function\n>> header?\n> \n> Oopsie, I didn't realize the regex must be POSIX compatible. I've\n> updated the regex to this:\n> https://www.regex101.com/r/kP3dM6\n> \n> The test seems to work; however git gives me an error with the regex\n> when I do a diff:\n> \n> $ git diff Core\n> fatal: Invalid regexp to look for hunk header:\n> ^[[:space:]]*[[:word:]_][[:word:][:digit:]_]*[[:space:]]*.*[[:space:]]*[[:word:]_][[:word:][:digit:]_]*[[:space:]]*\\(.*\\)[[:space:]]*$\n> \n> Here is how it is stored in my .gitconfig:\n> \n> [diff \"cpp\"]\n>     xfuncname =\n> \"^[[:space:]]*[[:word:]_][[:word:][:digit:]_]*[[:space:]]*.*[[:space:]]*[[:word:]_][[:word:][:digit:]_]*[[:space:]]*\\\\(.*\\\\)[[:space:]]*$\"\n> \n\nPerhaps there is a pair of parentheses missing that capture text for the\nhunk header? I you intended that to be the part inside \\(...\\), then\nthat is wrong. Use unescapted parentheses.\n\nThere are two catch-all .* in your pattern. That is very suspicious,\nparticularly since the first one is outside the meant-to-be capturing\nparentheses.\n\n-- Hannes\n"},{"id":"254259","messageId":"CAHd499DpyO6Csji8gp1E6HsrvtBa7QMKBah2xOewrWAfNgQUHg@mail.gmail.com","threadId":"38272","inReplyTo":"54A7000A.3050605@kdbg.org","subject":"Re: xfuncname problems with C++","fromName":"Robert Dailey","fromEmail":"rcdailey.lists@gmail.com","sentAt":"2015-01-02T21:27:56Z","receivedAt":"2015-01-02T21:27:56Z","isPatch":false,"sender":{"key":"rcdailey.lists@gmail.com","avatar":null},"body":"On Fri, Jan 2, 2015 at 2:31 PM, Johannes Sixt <j6t@kdbg.org> wrote:\n> Am 02.01.2015 um 18:03 schrieb Robert Dailey:\n>> On Fri, Jan 2, 2015 at 10:49 AM, Robert Dailey <rcdailey.lists@gmail.com> wrote:\n>>> I have a function like so:\n>>>\n>>> void MyClass::SomeFunction(int someParameter)\n>>> {\n>>>     // Stuff changed in here\n>>> }\n>>>\n>>> When I do `git diff` on the file containing this function, I get a\n>>> chunk showing some changed code in this function somewhere in the\n>>> middle of the body. However, the chunk header shows my root namespace\n>>> name in the file instead of the function header:\n>>>\n>>> @@ -144,15 +149,22 @@ namespace Utils\n>>>\n>>> What I expect to see:\n>>>\n>>> @@ -144,15 +149,22 @@ void MyClass::SomeFunction(int someParameter)\n>>>\n>>> I've tried various regular expressions that work in regex testers I\n>>> use against this function signature, however they do not work when I\n>>> apply them to my config:\n>>>\n>>> [diff \"cpp\"]\n>>>     xfuncname =\n>>> \"^\\\\s*[\\\\w_][\\\\w\\\\d_]*\\\\s*.*\\\\s*[\\\\w_][\\\\w\\\\d_]*\\\\s*\\\\(.*\\\\)\\\\s*$\"\n>>>\n>>> File name is \"foo.cpp\", I even added it to my git attributes file:\n>>>\n>>> *.cpp diff=cpp\n>>>\n>>> Using the regex above, my chunk headers come back blank. Why is it\n>>> showing namespace? How do I make this match the nearest function\n>>> header?\n>>\n>> Oopsie, I didn't realize the regex must be POSIX compatible. I've\n>> updated the regex to this:\n>> https://www.regex101.com/r/kP3dM6\n>>\n>> The test seems to work; however git gives me an error with the regex\n>> when I do a diff:\n>>\n>> $ git diff Core\n>> fatal: Invalid regexp to look for hunk header:\n>> ^[[:space:]]*[[:word:]_][[:word:][:digit:]_]*[[:space:]]*.*[[:space:]]*[[:word:]_][[:word:][:digit:]_]*[[:space:]]*\\(.*\\)[[:space:]]*$\n>>\n>> Here is how it is stored in my .gitconfig:\n>>\n>> [diff \"cpp\"]\n>>     xfuncname =\n>> \"^[[:space:]]*[[:word:]_][[:word:][:digit:]_]*[[:space:]]*.*[[:space:]]*[[:word:]_][[:word:][:digit:]_]*[[:space:]]*\\\\(.*\\\\)[[:space:]]*$\"\n>>\n>\n> Perhaps there is a pair of parentheses missing that capture text for the\n> hunk header? I you intended that to be the part inside \\(...\\), then\n> that is wrong. Use unescapted parentheses.\n>\n> There are two catch-all .* in your pattern. That is very suspicious,\n> particularly since the first one is outside the meant-to-be capturing\n> parentheses.\n\nMy regex actually is intended to not have any capture groups. Is that\nrequired? The documentation I read didn't mention any requirements, so\nI am not sure.\n\nThe 'void' does not start on the leftmost column, due to tabbing there\ncan be any number of whitespace (the regex should account for this).\n"},{"id":"254260","messageId":"20150102220556.GH29365@google.com","threadId":"38272","inReplyTo":"CAHd499DpyO6Csji8gp1E6HsrvtBa7QMKBah2xOewrWAfNgQUHg@mail.gmail.com","subject":"Re: xfuncname problems with C++","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2015-01-02T22:05:56Z","receivedAt":"2015-01-02T22:05:56Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Robert Dailey wrote:\n\n> The 'void' does not start on the leftmost column, due to tabbing there\n> can be any number of whitespace (the regex should account for this).\n\nAh, that explains it.  The default C++ pattern assumes the 'void'\nstarts at the leftmost column, so that the funcname header represents\nwhatever top-level construct forms the context (e.g., \"class foo {\").\n\n(Jump targets or access declarations)\n!^[ \\t]*[A-Za-z_][A-Za-z_0-9]*:[[:space:]]*($|/[/*])\n\n(functions/methods, variables, and compounds at top level)\n^((::[[:space:]]*)?[A-Za-z_].*)$\n\nThanks,\nJonathan\n"}]}