Skip to content

bug(git-read): revision fields are interpreted as paths without a separator #563

Closed

Description

@ooiuuii

Problem

git_show, git_log, and git_diff expose separate revision and path fields, but their argument builders only add Git's -- revision/path separator when an optional path is supplied.

With no path field, this causes two observable failures:

  • A valid branch with the same name as a worktree file is rejected as ambiguous.
  • A name that exists only as a file, not as a revision, can silently become a path filter and return unrelated history or a successful empty diff.

This affects structured Git inspection, including child agents using these read-only tools. It is not a request to allow additional revision syntax or path access.

Reproduction

Source checkout: f6b49ae59605b1276b8267f2886d22c03f01533c (package.json version 0.8.1). Reproduced on Windows with Node 22.22.3 and Git 2.54.0.windows.1, using a disposable repository and synthetic files only.

  1. Make two commits containing tracked a.txt and b.txt.
  2. Create branch a.txt at HEAD; do not create a b.txt branch/tag.
  3. Leave a new line in a.txt uncommitted.
  4. Execute these current production argument builders through runGit:
Input Expected Actual on main
buildShowArgs({ revision: "a.txt" }) Show branch tip and patch Ambiguous revision/path failure
buildLogArgs({ revision: "a.txt" }) History from the branch Ambiguous revision/path failure
buildDiffArgs({ from: "a.txt" }) Branch-to-worktree diff Ambiguous revision/path failure
Same calls with "b.txt" Invalid revision failure Succeeds by treating the input as a path

Six real-subprocess regression cases fail on the unchanged production implementation; the ten existing integration tests pass. Adding the revision/path separator makes all six regressions pass.

Proposed boundary

Emit command + existing options + validated revision(s) + -- + optional path in all three builders. Keep existing validators, read-only flags, tool schemas, staged/worktree behavior, and from...to comparison semantics unchanged. No extra rev-parse subprocess or new configuration is needed.

Duplicate check included open and closed git-read/revision/ambiguity reports. Open #368 concerns shared process/output implementation and does not change these argument builders. I have prepared the narrow regression-backed fix.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions