git log -L :<funcname>:<file>

The documentation for git log -L :<funcname>:<file>states


-L <start>,<end>:<file>
-L :<funcname>:<file>
Trace the evolution of the line range given by "<start>,<end>" (or the
function name regex <funcname>) within the <file>.


But the <funcname> version of this option does not work for Swift.


From http://stackoverflow.com/a/34340515/575530I realise that the reason for this failure is the lack of an entry for Swift in git's built in language regexes: http://git.kernel.org/cgit/git/git.git/tree/userdiff.c?id=f3adf457e046f92f039353762a78dcb3afb2cb13


I do not know enough about git, Swift, nor regular expresions to add an entry for Swift. But someone here might

Replies

Hey dumbledad,

As mentioned in the Stackoverflow post you should be able to use the <funcname> form if you add the following to your Git config file (~/.gitconfig):

Code Block
[diff "swift"]
xfuncname = ^[ \t]*((class|func)[ \t].*)$


Git doesn't automatically use the language matching patterns, even when they are defined in Git, hence why they need to be manually specified. If you want to learn more about the ins and outs of how this works and see how to configure other language matchers see https://gist.github.com/tekin/12500956bd56784728e490d8cef9cb81