使用git来识别修订中的所有修改函数 [英] Using git to identify all modified functions in a revision
问题描述
是否有一种使用git来识别历史中每个修订版本中所有修改函数的好方法?我试过使用-p开关,但它看起来不像svn的show-c-function参数那样工作。
我的假设是我想要使用git diff HEAD〜i HEAD〜i-1 -p来增加i的值。我是否缺少一些参数,这些参数有助于确定差异对已修改函数的最佳猜测?解析方案
下面是一个快速和肮脏的尝试在我认为你要去的地方。它执行 git log
显示所有修订, -p
将diff包含在日志中,a grep
只包含包含提交ID和hunk标题的行,并使用 sed
来过滤行号,只保留猜测Git在Hunk头之后写入的函数名称。
git log -p | grep -E'^(commit | @@)'| sed's /@@.*@@//'
Is there a good way to use git to identify all the modified functions in each revision in the history? I've tried using the -p switch, but it doesn't seem to work in the same way that svn's show-c-function parameter works.
My assumption is that I'll want to use "git diff HEAD~i HEAD~i-1 -p" for increasing values of i. Am I missing some parameters that will help identify diff's best guess on the functions that were modified?
Here's a quick and dirty attempt at what I think you're going for. It does a git log
to show all revisions, -p
to include the diff in the log, a grep
to only include the lines containing the commit ID and the hunk headers, and uses sed
to filter out the line numbers, leaving only the guess at the function name that Git writes after the hunk header.
git log -p | grep -E '^(commit|@@)' | sed 's/@@.*@@//'
这篇关于使用git来识别修订中的所有修改函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!