问题描述
我想要一种列出所有git作者的方法
I want a way to list all git authors that
- 仅自给定提交以来.
- 是独一无二的.
这两个很容易,我在网上看到了一些解决方案,大多数使用git log --format
.但是我发现没有一个符合其他要求:
These two are easy, and I've seen some solutions to this online, most using git log --format
. But none that I saw fits the additional requirements:
- 按提交日期排序.因此,如果约翰·史密斯(John Smith)在亚伦·梅勒(Aaron Meurer)之前犯下过罪行,那么他的名字应该出现在我的名字之前(我是亚伦·梅勒(Aaron Meurer).
- 尊重.mailmap.据我所知,只有
git shortlog
可以做到这一点,并且它提供了很多我不想要的东西.但是也许我错了.或者也许你们当中那些比我更方便使用sed
和朋友的人.
- Is ordered by commit date. So if John Smith committed before Aaron Meurer, his name should appear before mine (I'm Aaron Meurer).
- Respects .mailmap. As far as I can tell, only
git shortlog
does this, and it gives a bunch of extra stuff that I don't want. But maybe I'm wrong. Or maybe those of you who are more handy withsed
and friends than I am would just use that.
(顺便说一句,如何让Markdown not 不重新开始编号?)
(by the way, how do I make Markdown not restart the numbering?)
我还想一种按姓氏排序的方法,但这相对容易.
I also want a way to order it by last name, but this is relatively easy.
推荐答案
以下格式说明符将解决您的第二个问题:
The following format specifiers will solve your second concern:
%aN:作者姓名(尊重.mailmap)
%aE:作者电子邮件(使用.mailmap)
%cN:提交者名称(使用.mailmap)
%cE:提交者电子邮件(尊重.mailmap)
%aN: author name (respecting .mailmap)
%aE: author email (respecting .mailmap)
%cN: committer name (respecting .mailmap)
%cE: committer email (respecting .mailmap)
因此,除去重复的作者部分,您需要类似
So discounting the duplicate author part, you want something like
git log <commit>.. --format="%aN <%aE>" --reverse
我怀疑您可以通过基于哈希表的重复数据删除将其通过管道传输,而perl oneliner可能是微不足道的:
I suspect you could pipe it through something that does a hash-table based deduplication, a perl oneliner would be trivial:
git log <commit>.. --format="%aN <%aE>" --reverse | perl -e 'my %dedupe; while (<STDIN>) { print unless $dedupe{$_}++}'
这篇关于自给定提交以来git中的作者列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!