Skip to main content

Git extension for reporting source code line lifetime and churn

Project description

git-hot

git-hot is a Git extension that reports how ``hot'' (often-changing) the current lines or files in a repository are. It derives line lifetime and churn information from Git history, then highlights files and lines that have changed often or recently.

Install the package and run it as either:

git hot
git-hot

The package installs two commands:

  • git-hot, the Git extension command; manual page.
  • daglp, a helper, written in Rust, used to compute the longest path through the Git commit DAG; manual page.

Command installation

As an individual user

uv tool install git-hot

or

pipx install git-hot

or (discouraged legacy method)

pip install --user git-hot

For all users

sudo pipx install --global git-hot

In an active virtual environment

uv pip install git-hot
python -m pip install git-hot

After installation, ensure the installation's script directory is on PATH so Git can find git-hot and you can invoke it as git hot.

Usage

Show hot files in the current repository:

git hot

Show hot files at a specific revision:

git hot HEAD

Show line-level churn for one file:

git hot -- src/main.py

Show line ages and birth commits for one file:

git hot -q --format '{days(age)} {hash[:7]} {line}' -- src/main.py

Reconstruct all source files with churn prefixes below a directory:

git hot --dir hot-tree HEAD

Output

Without a path, git hot prints one line per current source file, sorted by path. The default columns are:

  • maximum live-line churn in the file
  • median changed-line lifetime in days
  • median live-line age in days
  • repository path

With a path, git hot prints the reconstructed contents of that file. By default each line is preceded by its churn count.

Use --color always or --color never to control color output. Automatic coloring can rank lines by churn, age, or lifetime:

git hot --color always --color-domain age -- src/main.py

Formatting

Use --format to customize file or line output with a restricted Python f-string expression. The available fields depend on whether repository-wide file metrics or selected-path line output is being produced.

Examples:

git hot --format '{max(churn):5d} {days(median(line_age)):5d} {path}'
git hot --format '{days(age)} {hash[:7]} {line}' -- src/main.py

Common helpers include days, max, min, median, mean, quartile_rank, color, and color_reset.

For the complete list of format fields and options, see:

man git-hot

or read the git-hot manual page.

Requirements

git-hot expects to run inside a Git repository. Alternatively, the Git repository can be passed to the git command using the --git-dir option. Internally, it invokes Git commands such as git log, git show, and git diff, and uses rename and copy detection.

Binary files and deleted files are skipped in file-metric output.

Installing From Source

Building from source requires Python 3.10 or later and a Rust toolchain with rustc, because daglp is compiled during installation.

uv sync --group dev
uv pip install -e .
uv run python -m unittest discover -s . -p 'test*.py'
uv run --group dev ruff check .

Run the full Python integration test suite on Unix-like systems with:

make test-python

This rule exercises the Git history fixtures, shell scripts, daglp, and the Python command-line interface. It depends on Bash and standard Unix tools such as sort and diff, so CI runs it only on Linux.

Build a source distribution locally with:

uv build --sdist

Reinstall updated Python source code with:

pipx uninstall git-hot
pipx install .

Platform wheels are built in CI through cibuildwheel, which smoke-tests the installed git-hot and daglp commands and runs the portable Python unit tests against each wheel on Linux, Windows, and macOS.

Research Tools

This repository also contains research-oriented source tools used for fine-grained code lifetime analysis, including lifetime.py, difflog.sh, tokenize.pl, and the top-level daglp.rs. They are kept in source form for reproducibility and experimentation, but the installable package exposes only git-hot and daglp.

For historical and research context, see lifetime-tools.md.

License

git-hot is distributed under the Apache License 2.0. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

git_hot-0.10.tar.gz (31.8 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

git_hot-0.10-py3-none-win_amd64.whl (437.0 kB view details)

Uploaded Python 3Windows x86-64

git_hot-0.10-py3-none-manylinux_2_28_x86_64.whl (1.2 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

git_hot-0.10-py3-none-manylinux_2_28_aarch64.whl (996.7 kB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

git_hot-0.10-py3-none-macosx_11_0_arm64.whl (237.2 kB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

Details for the file git_hot-0.10.tar.gz.

File metadata

  • Download URL: git_hot-0.10.tar.gz
  • Upload date:
  • Size: 31.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for git_hot-0.10.tar.gz
Algorithm Hash digest
SHA256 a1096d586e9f5b62925e2551c29c953d09d17df7ee65d59a82953f368a389245
MD5 3aa2dfcf59f96be3f2c248d2adfbe9a7
BLAKE2b-256 030073ff3b8c021c408f4cc5bf521a54d363807c618fc02990d2745fbd97544e

See more details on using hashes here.

Provenance

The following attestation bundles were made for git_hot-0.10.tar.gz:

Publisher: ci.yml on dspinellis/git-hot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file git_hot-0.10-py3-none-win_amd64.whl.

File metadata

  • Download URL: git_hot-0.10-py3-none-win_amd64.whl
  • Upload date:
  • Size: 437.0 kB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for git_hot-0.10-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 e2edf1a70b9b25225fcd5be053e31b8f66f7ca1923d6c9e06fdb2e43adcb9cc3
MD5 ff00d3d8077d267c5e0a4ddd14c64313
BLAKE2b-256 f8edc9631d9e33e8adb07b4d9339da9896f30902b7b0dcbb832bdb142e90fdd6

See more details on using hashes here.

Provenance

The following attestation bundles were made for git_hot-0.10-py3-none-win_amd64.whl:

Publisher: ci.yml on dspinellis/git-hot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file git_hot-0.10-py3-none-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for git_hot-0.10-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 af05dc9c270e8667c1db161d319580be430dc0f5dca6adaced0c3e802266a697
MD5 d2e8b4565e77b5b91143ff627f5ca61b
BLAKE2b-256 4af57e7cbcd50a0f7a96c742858aad53b74bd48d2f652a0736a6623bcc720a5d

See more details on using hashes here.

Provenance

The following attestation bundles were made for git_hot-0.10-py3-none-manylinux_2_28_x86_64.whl:

Publisher: ci.yml on dspinellis/git-hot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file git_hot-0.10-py3-none-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for git_hot-0.10-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 63a4cea0593d95e2ffec674bb9d45aef1c50c74e842b64df3eea76b32fc3e312
MD5 3c59ffb26e262fbd7e14eed512184e0c
BLAKE2b-256 e6e34580f20aa1c1e7c73fc070268fea70799049dc4e9972c0ee54d583e6be4d

See more details on using hashes here.

Provenance

The following attestation bundles were made for git_hot-0.10-py3-none-manylinux_2_28_aarch64.whl:

Publisher: ci.yml on dspinellis/git-hot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file git_hot-0.10-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for git_hot-0.10-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f0eac3805fd91cd73080ae9ab2e410b1e3b1fe7a96502d7e939a9f8c3b3ce484
MD5 911eb9009d9ac5839b85a2acec65ed33
BLAKE2b-256 750f56bf03e54d33cbf9961d552ac197d9eeb76b5ef7a7bedddb98b41d7f9dc7

See more details on using hashes here.

Provenance

The following attestation bundles were made for git_hot-0.10-py3-none-macosx_11_0_arm64.whl:

Publisher: ci.yml on dspinellis/git-hot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page