gitstatus-1.0.0 is not a library.
GitStatus
A fast, modern Rust tool that provides concise git repository status information. Perfect for shell prompts, scripts, and large repositories/monorepos.
Features
- Fast: Pure Rust implementation using
gix(Gitoxide) - Concise: Shows branch, upstream, and change summary in minimal format
- Modern: Built with modern Rust patterns and best practices
- Safe: Proper error handling and memory safety
- Configurable: CLI options for different use cases
Installation
From Source
Using Cargo
Usage
Basic Usage
# In any git repository
# Output: main origin/main β
# With changes
# Output: main origin/main +2~1-1
Command Line Options
# Show help
# Specify a different repository path
# Show verbose error messages
Output Format
The output consists of three parts separated by spaces:
- Current Branch: Name of the current branch (or "HEAD" if detached)
- Upstream Branch: Name of the upstream branch (if configured and different from current)
- Changes Summary: Summary of repository changes
Change Summary Symbols
β- Clean working directory+N- N added files~N- N modified files-N- N deleted filesrN- N renamed filestN- N files with type changes
Examples
# Clean repository on main branch tracking origin/main
# Repository with changes
# Detached HEAD state
# Branch without upstream
What's New in v0.3.0
This version represents a complete modernization of the codebase:
π Modern Rust Patterns
- Better Error Handling: Uses
anyhowfor context-rich error messages - CLI Arguments: Proper CLI parsing with
clapderive macros - Type Safety: Structured data types instead of string manipulation
- Memory Safety: No more potential panics from string indexing
ποΈ Improved Architecture
- Separation of Concerns: Clear separation between data collection, processing, and output
- Pure
gix: Eliminated externalgitcommand calls in favor ofgix(Gitoxide) - Structured Status: Uses
gix::statusplatform andtree_index_status()for precise, fast diffs - Extensible Design: Easy to add new features and status indicators
β‘ Performance Improvements
- Fast default: Avoid scanning untracked files by default (equivalent to
git -uno) - Parallel checks: Uses
gixparallel feature to check tracked-file modifications efficiently - Minimal I/O: No process spawning; tracked-only checks for prompt use are extremely fast
π‘οΈ Reliability
- Proper Error Propagation: No more silent failures with
process::exit(1) - Graceful Handling: Better handling of edge cases (detached HEAD, no upstream, etc.)
- Input Validation: Validates repository paths and handles invalid UTF-8
π― User Experience
- Better Symbols: More intuitive change indicators (
~for modified vs+for added) - Verbose Mode: Optional detailed error messages for debugging
- Flexible Paths: Can check status of any repository, not just current directory
- Help System: Proper help and version information
How itβs fast (with gix)
By default, gitstatus is optimized for shell prompts and large repos:
- It compares
HEAD^{tree}to the index for staged changes usingRepository::tree_index_status(). - It compares the index to the working tree using
Repository::status(...).into_index_worktree_iter(...)with untracked disabled unless requested. - Untracked mode mapping:
- default /
-u no: no untracked scan (no dirwalk) -u normal: collapsed untracked-u allor--all: full untracked listing
- default /
- Submodule checks and rename tracking are disabled by default for speed; they can be enabled later if needed.
Development
# Build
# Run tests
# Run with development features
# Check formatting and lints
Requirements
- Rust 1.70+ (specified in Cargo.toml)
- Git repository to analyze
License
GPL-3.0-only
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.