Skip to content

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

@Towaiji

Description

@Towaiji

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;

  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIIssues related to the Codex CLIbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions