objective-c - Git - 如何查看方法/函数的更改历史记录?

标签 objective-c git function methods history

所以我发现了关于如何查看文件更改历史的问题,但是这个特定文件的更改历史很大,我真的只对特定方法的更改感兴趣。那么是否可以仅查看该特定方法的更改历史记录?

我知道这需要 git 来分析代码,并且不同语言的分析会有所不同,但是方法/函数声明在大多数语言中看起来非常相似,所以我想也许有人已经实现了这个功能。

我目前使用的语言是 Objective-C,我目前使用的 SCM 是 git,但我很想知道这个功能是否适用于任何 SCM/语言。

最佳答案

git log 的最新版本学习了 -L 的特殊形式参数:

-L :<funcname>:<file>

Trace the evolution of the line range given by "<start>,<end>" (or the function name regex <funcname>) within the <file>. You may not give any pathspec limiters. This is currently limited to a walk starting from a single revision, i.e., you may only give zero or one positive revision arguments. You can specify this option more than once.
...
If “:<funcname>” is given in place of <start> and <end>, it is a regular expression that denotes the range from the first funcname line that matches <funcname>, up to the next funcname line. “:<funcname>” searches from the end of the previous -L range, if any, otherwise from the start of file. “^:<funcname>” searches from the start of file.

换句话说:如果你向 Git 询问 git log -L :myfunction:path/to/myfile.c ,它现在会愉快地打印该函数的更改历史记录。

关于objective-c - Git - 如何查看方法/函数的更改历史记录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4781405/

相关文章:

javascript - 声明的 javascript 变量在 JS 函数中不起作用

ios - Facebook Messenger iPhone 应用程序如何从 Facebook iPhone 应用程序获取登录信息?

ios - Xcode 给出了注释文本 block 中特定单词的错误

iPhone 应用程序崩溃 [__NSCFString objectForKey :] unrecognized selector sent to instance

git - 当我的分支和主人没有相关历史时如何做 pull 请求?

function - 函数的返回值

c - 为什么临时 char** 参数是非法的?

objective-c - 将 cocos2d 场景添加到 UIViewController

git - 高度耦合的 git 子模块

从 VPN 内的远程存储库进行 Git Checkout