feat: add git ai log command#975
Merged
svarlamov merged 3 commits intogit-ai-project:mainfrom Apr 6, 2026
Merged
Conversation
Add a new `git ai log` subcommand that proxies `git log --notes=ai`, providing a convenient way to view commit history with AI authorship notes. The command: - Passes through all standard git log options (formatting, filtering, pagination, etc.) - Correctly separates git global flags (-C, --git-dir, --no-pager, etc.) from git-log flags to ensure proper argument positioning - Handles ambiguous short flags (-p, -P, -c) by leaving them as log arguments unless the context is unambiguous (e.g., -c key.name=val) - Inherits stdin/stdout/stderr for proper pager and color support Closes git-ai-project#943
`-C` is ambiguous between git's global `-C <path>` (change directory) and `git log -C` (copy detection). Since args arrive after the `log` keyword is stripped, bare `-C` is far more likely to be copy-detection. Unconditionally extracting it as a global flag would consume the next argument as a path, breaking commands like `git ai log -C --oneline`. Now `-C` passes through to `git log` like `-p` and `-P`. Users needing the global form can use `--git-dir` or `--work-tree` instead.
- Respect `--` end-of-options separator in extract_git_global_args so pathspecs like `git ai log -- --bare` are not misclassified as global flags. - Apply the same dot-in-key heuristic to the sticky `-c<key>=<val>` form that the spaced `-c <key>=<val>` form already uses, preventing invalid config keys (e.g. `-cC=3`) from being extracted as global args. - Refactor handle_log to return ExitStatus instead of calling process::exit directly, enabling the caller to log telemetry and re-raise signals (SIGPIPE) for correct pipeline exit behavior. - Remove redundant find_repository validation that added an extra subprocess on every invocation — git log itself provides the error. - Add 22 unit tests covering all branches of extract_git_global_args.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new
git ai logsubcommand that proxiesgit log --notes=ai, providing a convenient way to view commit history with AI authorship notes.Changes
src/commands/log.rsmodule implementing thehandle_logfunctionlogsubcommand ingit_ai_handlers.rsHow it works
git [global-flags] log --notes=ai [user-args...]git logoptions are forwarded as-is (formatting, filtering, pagination)-C,--git-dir,--no-pager,-c key=val, etc.) are extracted and placed before thelogsubcommand for correct argument positioning-p,-P, bare-c) are deliberately left as log arguments to avoid misinterpretationUsage
Closes #943
Test plan
cargo fmt --checkpassescargo clippy --all-targets -- -D warningspassescargo test --libpassesgit ai logshows commits with AI authorship notes--oneline,-n,--format, etc.)--no-pager,-C) are correctly positioned