更容易恕我直言,將使用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