更容易恕我直言,将使用git怪:
git blame $ref -L'/search_pattern/,+1' filename(s)
一个全方位的例子在我的ZFS的保险丝库:
$ git for-each-ref --format='%(refname)' -- refs/heads |
while read ref;
do git blame $ref -L'/push/,+1' zfs_operations.c;
done
正如你所看到的,一半的工作是获取分支名称;如果您的使用更容易,您当然可以简单地对修订版进行硬编码。从上面的输出:
f5370a5e (Emmanuel Anne 2011-02-22 20:53:17 +0100 1492) static void push(zfsvfs_t *zfsvfs, cred_t *cred, fuse_ino_t ino, file_info_t *info, const char *buf, size_t size, off_t off)
f5370a5e (Emmanuel Anne 2011-02-22 20:53:17 +0100 1512) static void push(zfsvfs_t *zfsvfs, cred_t *cred, fuse_ino_t ino, file_info_t *info, const char *buf, size_t size, off_t off)
f5370a5e (Emmanuel Anne 2011-02-22 20:53:17 +0100 1512) static void push(zfsvfs_t *zfsvfs, cred_t *cred, fuse_ino_t ino, file_info_t *info, const char *buf, size_t size, off_t off)
注意的行号(1492 与):
f5370a5e(灵光安2011-02-22 20时53分17秒0100 )静态无效的push(zfsvfs_t * zfsvfs,cred_t * CRED,fuse_ino_t鲍,file_info_t *信息,为const char * buf中,为size_t大小,off_t关)
那些不匹配搜索模式的任何修订,将显示
fatal: -L parameter 'push': No match
你还想要看看选项:
-M (detect moved lines)
-n (show source line number)
-f (show filename, especially handy with -C)
-p/--incremental: if you want something parsed more easily in code