0

I maintain some c source code files. I get a task to find out what function is unstable. Unstable means functions be modified frequently. Actually I want get the statistic data to point out which function was modified how much times and each time by who. First I try to use git blame to get the information, but i am failed. Then I read many answer here, still can not find the best way. So i want ask you is there any tool or method can help me to do the job? Thanks very much!

2 Answers2

0

I done the job with following script.

#!/bin/bash
cat [function_list_file] | while read line
do
    echo $line
    git log -L :$line:path/subpath/file.c | grep commit -c # Get numbers of commit
    git log -L :$line:path/subpath/file.c | grep commit -2 # Get commit information
done

[function_list_file] is a file contain function name list, as:

funciton_1
funciton_2
funciton_3
funciton_4
funciton_5
funciton_6
funciton_7
funciton_8
0

If a function be moved from file a.c to file b.c at commit_x, we can use

git log -L :function:path/subpath/b.c

to get commits at HEAD of the latest commit. But we can not use

git log -L :function:path/subpath/a.c

to get commit at HEAD of the latest commit.

After resetting HEAD before commit_x,

git log -L :function:path/subpath/a.c

works.

Now I solved this problem by the following steps. I can find commits related to a function in all files.

git log -p | grep function -3 > run.log
cat run.log | grep "void function(" > run2.log
cat run2.log | grep @@ -c