I am trying to see the history of a c function using git log, but the function is static and the source code is organized with a block of function prototypes at the top, and their definitions are below in the source code.
Something like this:
/// @file foo.c
static void foo();
static void foo()
{
// function body
}
I am trying to see the history like I would with an external function (the prototype would be in a separate header file):
git log -L :foo:foo.c
However when I do this it only shows me the history for the prototype. I am only interested in the functions implementation. Is there a way I can see the history for the actual definition?
I have already done some searching and attempted to set up a .gitattributes
file in the base directory of my repo with these contents:
*.c diff=cpp
*.h diff=cpp
*.f diff=fortran
Any ideas what else I can try?
Seems the spec for identifying functions in C-family files also matches a declaration. So write your own, you know what you're looking for so you could just give it literally,
git log -L '/^static void foo()$/,/^}/':foo.c
or get cute and say something like (smoketested so at least not completely wrong:)
git log -L '/^\([[:alnum:]_]\+[[:space:]]\)*foo(.*)$/,/^}/':foo.c