簡體   English   中英

等價於:git log --exclude-author?

[英]equivalence of: git log --exclude-author?

在工作中,我們有一個 git 存儲庫,其中大部分提交都是機器人用戶的自動提交。 有時我更喜歡從該存儲庫查看 git 日志,但沒有看到自動提交。 我猜它可以被描述為倒置的“git log --author”或“git log --exclude-author=botuser”,如果存在這樣的選項的話。

目前我執行以下操作,簡化為 bash 別名。

git log --format="%H %aE" | grep -v -F botuser@domain | while read hash email; do git log -1 $hash; echo; done | less

我的問題是,對於我想要完成的事情,是否有一個不那么駭人聽聞的解決方案?

https://coderwall.com/p/tzdzwa

git log --perl-regexp --author='^((?!excluded-author-regex).*)$'

這對我有用。

如果不想每次都指定--perl-regexp ,可以執行以下操作:

git config --global grep.patternType perl

目前沒有,但似乎已經有了一些討論關於支持-v在未來的選項,或使當前git log --not為工作--author--committer--grep

另請參閱: 如何反轉git log --grep模式

其他一些答案引用了部分內容,但是我使用此處看到的策略在回購中取得了成功

 git log --invert-grep --author=<pattern>

您可以根據需要添加任意數量的作者模式。 就我而言,最好的模式是完整的電子郵件,因為它是唯一的

警告, mateor答案將不再適用於 Git 2.35(2022 年第一季度)。

 # WRONG:
 git log --invert-grep --author=<pattern>

quodlibetor回答仍然有效:

git log --perl-regexp --author='^((?!excluded-author-regex).*)$'

但是:不再git log --invert-grep --author=<pattern>來排除作者。

" git log --invert-grep --author=<name> " ( man )用於排除給定作者編寫的提交,但現在 " --invert-grep " 僅影響由 " --grep=<pattern> " 選項。

請參閱René Scharfe ( rscharfe )提交 794c000 (2021 年 12 月 17 日)。
(由Junio C Hamano -- gitster --提交 2043ce8中合並,2022 年 1 月 5 日)

log :讓--invert-grep只反轉--grep

報告人:Dotan Cohen
簽字人:René Scharfe

記錄了選項--invert-grep以過濾掉其消息與--grep過濾器匹配的提交。
但是,它也會影響 header 匹配項( --author--committer ),這是無意的。

將該選項的處理移至grep.c ,因為只有那里的代碼可以區分 header 中的匹配項和消息正文中的匹配項。
如果--invert-grep則啟用擴展表達式(不是正則表達式類型,我們只需要' git grep ' ( man ) s --not to work),否定身體模式並檢查它們是否與小豬匹配-支持grep_source_1()collect_hits機制。

在 struct grep_opt中收集匹配項有點不確定,但是使用"last_shown"我們有一個先例,可以將 state 信息寫入該結構。


為什么? 2017 年 6 月進行初步討論后,於 2021 年 12 月再次討論

在錯誤發生之前你做了什么?

 $ git log -8 --author=Shachar --grep=Revert --invert-grep

你期望會發生什么?

我希望看到來自Shachar的最后 8 次提交,在提交消息中沒有字符串“ Revert ”。

反而發生了什么?

提交列表包括除Shachar之外的作者的提交。

你所期望的和實際發生的有什么不同?

當使用“ --author --invert-grep ”選項時,“--author”過濾器似乎被忽略了。
我還嘗試更改選項的順序,但結果保持不變。

與 Git 2.35+ 兼容的替代解決方案可在 此處找到

git log --format='%H %an' |  # get a list of all commit hashes followed by the author name
  grep -v Adam |             # match the name but return the lines that *don't* contain the name
  cut -d ' ' -f1 |           # from this extract just the first part of the line which is commit ref
  xargs -n1 git log          # call git log 

是的,它有可能。 您需要使用所需的格式更改.gitconfig文件。 請查看git log手冊頁中的“漂亮格式”部分。

另一個參考: 此處的 “自定義格式”部分。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM