Skip to content

feat: add git ai log command#975

Merged
svarlamov merged 3 commits intogit-ai-project:mainfrom
Krishnachaitanyakc:feat/add-git-ai-log-command
Apr 6, 2026
Merged

feat: add git ai log command#975
svarlamov merged 3 commits intogit-ai-project:mainfrom
Krishnachaitanyakc:feat/add-git-ai-log-command

Conversation

@Krishnachaitanyakc
Copy link
Copy Markdown
Contributor

@Krishnachaitanyakc Krishnachaitanyakc commented Apr 5, 2026

Summary

Adds a new git ai log subcommand that proxies git log --notes=ai, providing a convenient way to view commit history with AI authorship notes.

Changes

  • New src/commands/log.rs module implementing the handle_log function
  • Registered log subcommand in git_ai_handlers.rs
  • Added help text for the new command

How it works

  • Runs git [global-flags] log --notes=ai [user-args...]
  • All standard git log options are forwarded as-is (formatting, filtering, pagination)
  • Git global flags (-C, --git-dir, --no-pager, -c key=val, etc.) are extracted and placed before the log subcommand for correct argument positioning
  • Ambiguous short flags (-p, -P, bare -c) are deliberately left as log arguments to avoid misinterpretation
  • Inherits stdin/stdout/stderr for proper pager and terminal color support

Usage

# Basic usage - show log with AI notes
git ai log

# With standard git log options
git ai log --oneline
git ai log --since="2 weeks ago" --author="alice"
git ai log -n 5 --format="%H %s"

# With git global flags
git ai log --no-pager
git ai log -C /path/to/repo

Closes #943

Test plan

  • cargo fmt --check passes
  • cargo clippy --all-targets -- -D warnings passes
  • cargo test --lib passes
  • Verified git ai log shows commits with AI authorship notes
  • Verified passthrough of git log options (--oneline, -n, --format, etc.)
  • Verified global flags (--no-pager, -C) are correctly positioned

Open with Devin

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
@Krishnachaitanyakc Krishnachaitanyakc marked this pull request as draft April 5, 2026 22:03
devin-ai-integration[bot]

This comment was marked as resolved.

`-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.
@Krishnachaitanyakc Krishnachaitanyakc marked this pull request as ready for review April 5, 2026 22:45
devin-ai-integration[bot]

This comment was marked as resolved.

@Krishnachaitanyakc Krishnachaitanyakc marked this pull request as draft April 6, 2026 00:13
- 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.
@Krishnachaitanyakc Krishnachaitanyakc marked this pull request as ready for review April 6, 2026 01:39
@svarlamov svarlamov merged commit 476b5a4 into git-ai-project:main Apr 6, 2026
23 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add git-ai log command

2 participants