Summary: git log -L:<funcname>:<file> would fail if there's any java-style comment that appears before the <funcname> string in the file. Details: Thank you for filling out a Git bug report! Please answer the following questions to help us understand your issue. What did you do before the bug happened? (Steps to reproduce your issue) git log -L:'myFunction':~/a.java The file is a java file that contains comment before the function name. E.g. /** * comments will interrupt the regex match */ private static void myFunction() {} What did you expect to happen? (Expected behavior) As described, it should return me the commit history that touched this function What happened instead? (Actual behavior) It returns error: fatal: -L parameter 'myFunction' starting at line 1: no match Anything else you want to add: If the function name string to search for appears before any java-style comment, it returns a valid response. Please review the rest of the bug report below. You can delete any lines you don't wish to share. [System Info] git version: git version 2.30.1 (Apple Git-130) cpu: x86_64 no commit associated with this build sizeof-long: 8 sizeof-size_t: 8 shell-path: /bin/sh uname: Darwin 20.4.0 Darwin Kernel Version 20.4.0: Thu Apr 22 21:46:47 PDT 2021; root:xnu-7195.101.2~1/RELEASE_X86_64 x86_64 compiler info: clang: 12.0.5 (clang-1205.0.22.6) libc info: no libc information available $SHELL (typically, interactive shell): /bin/zsh [Enabled Hooks] post-commit post-rewrite