Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List of authors in git since a given commit

Tags:

I want a way to list all git authors that

  1. Is only since a given commit.
  2. Is unique.

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:

  1. Is ordered by commit date. So if John Smith committed before Aaron Meurer, his name should appear before mine (I'm Aaron Meurer).
  2. 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 with sed and friends than I am would just use that.

(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.

like image 555
asmeurer Avatar asked Jun 26 '11 06:06

asmeurer


People also ask

How can I see my git command history?

`git log` command is used to view the commit history and display the necessary information of the git repository. This command displays the latest git commits information in chronological order, and the last commit will be displayed first.

How do I see the commit history of a branch?

On GitHub.com, you can access your project history by selecting the commit button from the code tab on your project. Locally, you can use git log . The git log command enables you to display a list of all of the commits on your current branch. By default, the git log command presents a lot of information all at once.


2 Answers

Note for people who want "global stat":

git shortlog -s -n -e

Give the global stats commits by author.

like image 66
Thomas Decaux Avatar answered Sep 24 '22 07:09

Thomas Decaux


The following format specifiers will solve your second concern:

%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

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{$_}++}'
like image 44
cxreg Avatar answered Sep 22 '22 07:09

cxreg