2012-07-04 34 views
0

我沒有看到任何明顯的做法,但git已經證明一次又一次比我想象的方式更加靈活,所以...根據插入/刪除的行數限制git日誌?

我想找到引入大代碼更改的提交,所以我想通過插入或刪除的行數限制它們(一起或單獨)。有沒有辦法做到這一點?

回答

3

git log --stat

commit e2b97c53727bd66c143713d13399ff4242e4ff06 
Author: John Hobbs 
Date: Thu Nov 4 17:01:14 2010 -0500 
    Switched to jQuery Mobile. It's awesome. 
application/classes/controller/item.php | 77 +++++++++++++--------------- 
application/classes/controller/project.php | 4 +- 
application/classes/controller/site.php | 2 + 
application/classes/controller/user.php | 5 +- 
application/classes/form.php    | 2 +- 
application/views/item/add.php    | 27 +++------- 
application/views/item/index.php   | 19 ++----- 
application/views/item/view.php   | 11 +++-- 
application/views/message/basic.php  | 13 +++++ 
application/views/mobile.php    | 64 ++++++++++++++++++----- 
application/views/project/add.php   | 5 +-- 
application/views/project/index.php  | 28 ++++------ 
application/views/project/view.php   | 19 ++----- 
application/views/user/index.php   | 25 +-------- 
application/views/user/login.php   | 14 +++-- 
application/views/user/register.php  | 20 ++++--- 
16 files changed, 165 insertions(+), 170 deletions(-) 

(從here輸出樣本)

然後肉眼查找長+/-標誌或使用--numstat和管到另一個命令對其進行過濾。

man git log


如果你需要對其進行過濾,而不是做它在視覺上(--shortstat所推薦的安託萬):

$ git log --pretty=oneline --shortstat 

這會給你的輸出是這樣的:

$ git log --pretty=oneline --shortstat 
19791900f886e7a5f92b7cf3536053c863bec067 fix tab title, system menu, and a focus 
2 files changed, 108 insertions(+), 65 deletions(-) 
b52941150046cdb455c38e3f9bc133d6ba8f721f give tab a wndproc, change time to be 
1 files changed, 65 insertions(+), 20 deletions(-) 
ae5c18524b4a02b264fe26319ce2c9cf7dbff6b2 Fix window style of parent window 
1 files changed, 1 insertions(+), 1 deletions(-) 
8f94ad9bbbb2fec42feccda43374b13eda55c018 Add .gitignore to ignore some MSVC file 
1 files changed, 10 insertions(+), 0 deletions(-) 

管awk,搜索'文件已更改',和p打印匹配的行和以前行,如果插入的數目大於50:

$ git log --pretty=oneline --shortstat | awk '/files changed,/&& $4 > 50 {print x; print};{x=$0}' 

19791900f886e7a5f92b7cf3536053c863bec067 fix tab title, system menu, and a focus 
2 files changed, 108 insertions(+), 65 deletions(-) 
b52941150046cdb455c38e3f9bc133d6ba8f721f give tab a wndproc, change timer 
1 files changed, 65 insertions(+), 20 deletions(-) 

來源爲一些AWK參數:http://unstableme.blogspot.com/2008/05/print-currentnextprevious-line-using.html

+0

如果這是實際的答案,我會建議'--shortstat '而不是 –

+0

我知道。現在,你是否對這個問題有了答案? –

+0

我不知道你知道該怎麼做。此外,如果我正在尋找大量更改的提交,我可能會想要手動執行過濾器,因此我不會錯過任何提交。如果過濾掉所有更改次數少於50行的提交,那麼您將錯過49次可能會讓您感興趣的更改。無論如何,我編輯我的答案使用awk過濾。 – user1493941