{"thread":{"id":"55740","subject":"[Bug Report] git log -L:<funcname>:<file>","startedAt":"2021-05-20T00:12:01Z","lastAt":"2021-05-20T07:05:55Z","messageCount":4,"participants":["Weishi Zeng","Bagas Sanjaya","Atharva Raykar"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"425005","messageId":"CAH6yD_bkY+_7XrzHdOqnnE=qvnnvxAWEQPtOyVh=BwvbcheTCA@mail.gmail.com","threadId":"55740","inReplyTo":null,"subject":"[Bug Report] git log -L:<funcname>:<file>","fromName":"Weishi Zeng","fromEmail":"amwish.zeng@gmail.com","sentAt":"2021-05-20T00:11:48Z","receivedAt":"2021-05-20T00:12:01Z","isPatch":false,"sender":{"key":"amwish.zeng@gmail.com","avatar":null},"body":"Summary:\ngit log -L:<funcname>:<file>\nwould fail if there's any java-style comment that appears before the\n<funcname> string in the file.\n\n\nDetails:\nThank you for filling out a Git bug report!\nPlease answer the following questions to help us understand your issue.\n\nWhat did you do before the bug happened? (Steps to reproduce your issue)\ngit log -L:'myFunction':~/a.java\nThe file is a java file that contains comment before the function name.\nE.g.\n/**\n* comments will interrupt the regex match\n*/\nprivate static void myFunction() {}\n\nWhat did you expect to happen? (Expected behavior)\nAs described, it should return me the commit history that touched this function\n\nWhat happened instead? (Actual behavior)\nIt returns error:\nfatal: -L parameter 'myFunction' starting at line 1: no match\n\nAnything else you want to add:\nIf the function name string to search for appears before any\njava-style comment, it returns a valid response.\n\nPlease review the rest of the bug report below.\nYou can delete any lines you don't wish to share.\n\n\n[System Info]\ngit version:\ngit version 2.30.1 (Apple Git-130)\ncpu: x86_64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nuname: Darwin 20.4.0 Darwin Kernel Version 20.4.0: Thu Apr 22 21:46:47\nPDT 2021; root:xnu-7195.101.2~1/RELEASE_X86_64 x86_64\ncompiler info: clang: 12.0.5 (clang-1205.0.22.6)\nlibc info: no libc information available\n$SHELL (typically, interactive shell): /bin/zsh\n\n\n[Enabled Hooks]\npost-commit\npost-rewrite\n"},{"id":"425024","messageId":"83740d18-e0ba-e6b5-0356-144373708d4e@gmail.com","threadId":"55740","inReplyTo":"CAH6yD_bkY+_7XrzHdOqnnE=qvnnvxAWEQPtOyVh=BwvbcheTCA@mail.gmail.com","subject":"Re: [Bug Report] git log -L:<funcname>:<file>","fromName":"Bagas Sanjaya","fromEmail":"bagasdotme@gmail.com","sentAt":"2021-05-20T03:18:18Z","receivedAt":"2021-05-20T03:18:23Z","isPatch":false,"sender":{"key":"bagasdotme@gmail.com","avatar":"https://avatars.githubusercontent.com/u/40219486?v=4"},"body":"Hi Weishi,\n\nOn 20/05/21 07.11, Weishi Zeng wrote:\n> Summary:\n> git log -L:<funcname>:<file>\n> would fail if there's any java-style comment that appears before the\n> <funcname> string in the file.\n> \n> \n> Details:\n> Thank you for filling out a Git bug report!\n> Please answer the following questions to help us understand your issue.\n> \n> What did you do before the bug happened? (Steps to reproduce your issue)\n> git log -L:'myFunction':~/a.java\n> The file is a java file that contains comment before the function name.\n> E.g.\n> /**\n> * comments will interrupt the regex match\n> */\n> private static void myFunction() {}\n> \n> What did you expect to happen? (Expected behavior)\n> As described, it should return me the commit history that touched this function\n> \n> What happened instead? (Actual behavior)\n> It returns error:\n> fatal: -L parameter 'myFunction' starting at line 1: no match\n> \n> Anything else you want to add:\n> If the function name string to search for appears before any\n> java-style comment, it returns a valid response.\n> \n\nI can't reproduce this issue on my system (Ubuntu 20.04) using latest Git\n(2.32.0-rc0), compiled with gcc 9.3.0.\n\nPlease compile latest Git on your system, repeat and report.\n\n-- \nAn old man doll... just what I always wanted! - Clara\n"},{"id":"425052","messageId":"CAH6yD_a+OtAbGcJbvTTY1Sx3uHk9e9v4LE2zA1POO8YXiq+qZA@mail.gmail.com","threadId":"55740","inReplyTo":"83740d18-e0ba-e6b5-0356-144373708d4e@gmail.com","subject":"Re: [Bug Report] git log -L:<funcname>:<file>","fromName":"Weishi Zeng","fromEmail":"amwish.zeng@gmail.com","sentAt":"2021-05-20T06:45:01Z","receivedAt":"2021-05-20T06:45:16Z","isPatch":false,"sender":{"key":"amwish.zeng@gmail.com","avatar":null},"body":"Thanks Bagas.\nLooking at it further the problem seems to be with the leading space/tab.\nHere's a single line I can reproduce in the latest version.\n===\n    private static Optional<String> myFunction(String a) {}\n===\nIt works if you delete the 2 leading tab. (same for 4 leading space)\nCommand executed:\ngit log -L:'myFunction':~/a.java\n\nOn Wed, May 19, 2021 at 8:18 PM Bagas Sanjaya <bagasdotme@gmail.com> wrote:\n>\n> Hi Weishi,\n>\n> On 20/05/21 07.11, Weishi Zeng wrote:\n> > Summary:\n> > git log -L:<funcname>:<file>\n> > would fail if there's any java-style comment that appears before the\n> > <funcname> string in the file.\n> >\n> >\n> > Details:\n> > Thank you for filling out a Git bug report!\n> > Please answer the following questions to help us understand your issue.\n> >\n> > What did you do before the bug happened? (Steps to reproduce your issue)\n> > git log -L:'myFunction':~/a.java\n> > The file is a java file that contains comment before the function name.\n> > E.g.\n> > /**\n> > * comments will interrupt the regex match\n> > */\n> > private static void myFunction() {}\n> >\n> > What did you expect to happen? (Expected behavior)\n> > As described, it should return me the commit history that touched this function\n> >\n> > What happened instead? (Actual behavior)\n> > It returns error:\n> > fatal: -L parameter 'myFunction' starting at line 1: no match\n> >\n> > Anything else you want to add:\n> > If the function name string to search for appears before any\n> > java-style comment, it returns a valid response.\n> >\n>\n> I can't reproduce this issue on my system (Ubuntu 20.04) using latest Git\n> (2.32.0-rc0), compiled with gcc 9.3.0.\n>\n> Please compile latest Git on your system, repeat and report.\n>\n> --\n> An old man doll... just what I always wanted! - Clara\n"},{"id":"425053","messageId":"415E9638-B035-49A2-B2AF-1CBD988421D4@gmail.com","threadId":"55740","inReplyTo":"CAH6yD_bkY+_7XrzHdOqnnE=qvnnvxAWEQPtOyVh=BwvbcheTCA@mail.gmail.com","subject":"Re: [Bug Report] git log -L:<funcname>:<file>","fromName":"Atharva Raykar","fromEmail":"raykar.ath@gmail.com","sentAt":"2021-05-20T07:05:48Z","receivedAt":"2021-05-20T07:05:55Z","isPatch":false,"sender":{"key":"raykar.ath@gmail.com","avatar":"https://avatars.githubusercontent.com/u/24277692?v=4"},"body":"On 20-May-2021, at 05:41, Weishi Zeng <amwish.zeng@gmail.com> wrote:\n> \n> Summary:\n> git log -L:<funcname>:<file>\n> would fail if there's any java-style comment that appears before the\n> <funcname> string in the file.\n> \n> \n> Details:\n> Thank you for filling out a Git bug report!\n> Please answer the following questions to help us understand your issue.\n> \n> What did you do before the bug happened? (Steps to reproduce your issue)\n> git log -L:'myFunction':~/a.java\n> The file is a java file that contains comment before the function name.\n> E.g.\n> /**\n> * comments will interrupt the regex match\n> */\n> private static void myFunction() {}\n\nI was able to reproduce a similar problem, but it was not the comments\nthat were causing it. It was happening to methods that were indented\n(ie, defined within a class, as is always the case in Java).\n\n> What did you expect to happen? (Expected behavior)\n> As described, it should return me the commit history that touched this function\n> \n> What happened instead? (Actual behavior)\n> It returns error:\n> fatal: -L parameter 'myFunction' starting at line 1: no match\n\nCan you try adding a .gitattributes file at the root of your repository,\nwith the following contents:\n\n*.java diff=java\n\nAfter that, try running the command again, and see if that helps.\n\nI suspect the default regex that tries to locate your function might not\nbe matching as well as it should, and does not handle indented function\ndefinitions properly.\n\n(More on what the .gitattributes file does:\nhttps://git-scm.com/docs/gitattributes#_defining_a_custom_hunk_header)\n\n> Anything else you want to add:\n> If the function name string to search for appears before any\n> java-style comment, it returns a valid response.\n> \n> Please review the rest of the bug report below.\n> You can delete any lines you don't wish to share.\n> \n> \n> [System Info]\n> git version:\n> git version 2.30.1 (Apple Git-130)\n> cpu: x86_64\n> no commit associated with this build\n> sizeof-long: 8\n> sizeof-size_t: 8\n> shell-path: /bin/sh\n> uname: Darwin 20.4.0 Darwin Kernel Version 20.4.0: Thu Apr 22 21:46:47\n> PDT 2021; root:xnu-7195.101.2~1/RELEASE_X86_64 x86_64\n> compiler info: clang: 12.0.5 (clang-1205.0.22.6)\n> libc info: no libc information available\n> $SHELL (typically, interactive shell): /bin/zsh\n> \n> \n> [Enabled Hooks]\n> post-commit\n> post-rewrite\n\n--\nAtharva Raykar"}]}