开发者

Can gitk show all commits EXCEPT those by a given author?

开发者 https://www.devze.com 2023-03-13 04:06 出处:网络
I want to use gitk to view all commits except those by a given author. Something like the following: 开发者_如何学Pythongitk --author=!joe

I want to use gitk to view all commits except those by a given author. Something like the following:

开发者_如何学Pythongitk --author=!joe

Is this possible?


From the command line:

gitk --perl-regexp --author='^(?!joe)'

To exclude commits by several authors:

gitk --perl-regexp --author='^(?!jack|jill)'

Explanation: (?!whatever) is a (perl-style) look-ahead regular expression: it matches a position not followed by whatever. We anchor it to the beginning of the Author field by the "beginning of string" regexp ^.

Or run gitk --perl-regexp and then in the gitk menu, select View -> New View (or Shift+F4 for short) and write ^(?!joe) into the "Author" field.

If you do not want to always have to type gitk --perl-regexp, you can set up git to globally use perl regular expressions by running

git config --global grep.patternType perl


I don't think there is a terribly easy way to do it--

If you have perl or something similar, you can piece together a solution:

  1. Get the list of commits you want to exclude and put them in a hash: git rev-list [refs] --author="[author pattern]"

  2. Get the list of commits you want to show: git rev-list [refs]

  3. Subtract the items in the hash from the commits you want to show

  4. Show the commits you do want to show: gitk --no-walk [output of subtraction]

You could write something in perl/python/ruby pretty easily to do 1-3, and then just do

gitk --no-walk $(drop-author.pl [refs] [author-pattern])

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号