有没有什么好的方法可以用git来识别历史上每个revision中所有修改过的函数?我试过使用 -p 开关,但它的工作方式似乎与 svn 的 show-c-function 参数的工作方式不同。
我的假设是我想使用“git diff HEAD~i HEAD~i-1 -p”来增加 i 的值。我是否遗漏了一些有助于确定 diff 对已修改函数的最佳猜测的参数?
最佳答案
这是一个魔法咒语,用于在 git diff
*
git diff | \
grep -E '^(@@)' | \
grep "(" | \
sed 's/@@.*@@//' | \
sed 's/(.*//' | \
awk -F " " '{print $NF}' | \
uniq
...它的作用是...
- Picks the current diff,
- next picks only lines with "hunk-headers" ,
- next picks only lines with opening parenthesis (as potentially containing function names),
- next ignores the hunk headers,
- next ignores the text after the opening parenthesis,
- next picks only the word immediately before the opening parenthesis,
- and lastly ignores multiple occurrences of the same word in the list.
瞧!您有一个被当前 git diff
修改的函数列表。
* 在运行 bash 的 Ubuntu 16.04 上使用 git version 2.7.4
验证。
关于git - 使用 git 识别修订中所有修改的函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5721447/