About this project
`git-stats` is a command-line tool written in Rust that parses `git log` information to produce aggregated commit statistics. It reads the repository directly using `gitoxide`, a pure-Rust implementation of git, avoiding the need for the git binary.
## Features
- **Aggregated stats**: Summarizes commits by author, showing the number of commits, changed files, insertions, deletions, and net line changes.
- **Revision ranges**: Supports single revisions, `A..B`, and `A...B` ranges, with endpoints specified as refs, short hashes, `@{n}`, etc.
- **Filtering**: Limit by author (regex), date range (`--since`, `--until`), and revision range.
- **Review tracking**: Optionally shows reviewers/testers based on `Acked-by`, `Tested-by`, and `Reviewed-by` git trailers.
- **Sorting**: Sort by any column (author, commits, files, insertions, deletions, net) in ascending or descending order.
- **Email display**: Optionally show author email addresses.
## Installation
Install from crates.io:
```
cargo install git-stats --locked
```
Or with `cargo-binstall` for prebuilt binaries:
```
cargo binstall git-stats
```
On Arch Linux, use the AUR packages `git-stats` (source) or `git-stats-bin` (prebuilt).
With `mise`, install a prebuilt binary with checksum and SLSA provenance verification:
```
mise use -g github:lukehsiao/git-stats
```
## Usage
```
Usage: git-stats [OPTIONS] [revision-range]
Arguments:
[revision-range] Show only commits in the specified revision range [default: HEAD]
Options:
-e, --email Show the email address of each author
-r, --reviews Show who reviewed/tested commits based on git trailers
-s, --sort <SORT> What column to sort by [default: commits] [possible values: author, commits, files, insertions, deletions, net]
--reverse Reverse the sorting order
-a, --author <AUTHOR> Limit commits to those matching a regex pattern
--since <SINCE> Limit to commits more recent than a date
--until <UNTIL> Limit to commits older than a date
-h, --help Print help
-V, --version Print version
```
Example output:
```
$ git stats -r origin..HEAD
Author Commits Changed Files Insertions Deletions Net Δ
Luke Hsiao 67 117 +2616 -1126 +1490
dependabot[bot] 31 62 +203 -267 -64
Total 98 179 +2819 -1393 +1426
Reviewer/Tester Commits
Luke Hsiao 1
```
## Notes
- **Revision ranges**: Only simple forms are supported; exotic gitrevisions(7) syntax is not interpreted.
- **Date filtering**: Accepts ISO 8601, RFC 2822, unix timestamps, and relative dates like "2 weeks ago". Filtering is on committer date.
- **Author matching**: Matches against mailmap-resolved author, unlike `git log --author` which uses raw headers.
- **Merge commits**: Count as commits but contribute no line/file changes.
- **Shallow clones**: Work, but stats may differ from full clones; a warning is printed.
- **Submodules**: Counted as single changed files, with minor divergences from git's rename handling.
- **Line counts**: From gitoxide's diff engine, may differ slightly from git's on some hunks.
- **SHA-256 repositories**: Not supported (gitoxide limitation).
- **Commit encodings**: Non-UTF-8 encodings are not converted; author names may show replacement characters.
Comments
0 Rating appears after 10 ratings
Sign in to join the discussion.