Bug: recent_commits(limit=0) returns 1 commit instead of 0

Resolved 💬 0 comments Opened Nov 27, 2025 by Towaiji Closed Dec 1, 2025

What version of Codex is running?

codex 0.63.0

What subscription do you have?

Open-source Codex CLI usage (no subscription required)

Which model were you using?

N/A - issue is in codex-rs recent_commits logic, unrelated to model selection

What platform is your computer?

Darwin 25.0.0 arm64 arm

What issue are you seeing?

Calling recent_commits(..., 0) returns 1 commit due to limit.max(1) being applied.

This makes limit == 0 behave the same as limit == 1, which is inconsistent with the expectation that requesting 0 commits should return an empty list.

This affects downstream consumers that rely on limit == 0 to detect absence of history (e.g., determining whether a repository has any relevant commit history before performing actions).

What steps can reproduce the bug?

  1. Create or use any git repo with at least one commit
  2. Call:

let commits = recent_commits(Path::new("."), 0).await;

  1. Observe that commits.len() == 1

What is the expected behavior?

recent_commits(path, 0) -> []

Additional information

I have a small PR ready that:

  • returns an empty Vec when limit == 0
  • adds a test that fails before the change and passes afterwards

Happy to adjust if the current behavior is intentional.

View original on GitHub ↗