Skip to content

gix diff file :README.md README.md fails with Error: couldn't parse revision: "README.md" #2694

Description

Running gix diff file :README.md README.md in order to get a diff of the file at HEAD with the version on disk fails on current main with the following error message:

Error: couldn't parse revision: "README.md"

Caused by:
    The ref partially named "README.md" could not be found

To reproduce:

  • Add one line to README.md.
  • Run cargo run -- diff file :README.md README.md

Expected result:

❯ cargo run -- diff file :README.md README.md
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.17s
     Running `target/debug/gix diff file ':README.md' README.md`
@@ -1,3 +1,6 @@
+This is for testing. We want to find the correct invocation for `gix diff file
+…` to show these lines as additions.
+
 [![CI](https://github.com/GitoxideLabs/gitoxide/workflows/ci/badge.svg)](https://github.com/GitoxideLabs/gitoxide/actions)
 [![Crates.io](https://img.shields.io/crates/v/gitoxide.svg)](https://crates.io/crates/gitoxide)
 <img src="etc/msrv-badge.svg">

Actual result:

❯ cargo run -- diff file :README.md README.md
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.17s
     Running `target/debug/gix diff file ':README.md' README.md`
Error: couldn't parse revision: "README.md"

Caused by:
    The ref partially named "README.md" could not be found

I ran git bisect to find the commit that introduced the error, and it found a commit that is not related to rev-parsing at all:

499402c941e85e6cff5c3ffef8a09afac842c7ac is the first bad commit
commit 499402c941e85e6cff5c3ffef8a09afac842c7ac
Author: Sebastian Thiel <[email protected]>
Date:   Sun Jan 18 10:43:49 2026 +0100

    Make `Exn` work properly after the type was erased.

 gix-error/src/exn/impls.rs   | 17 ++++++++++++++++-
 gix-error/tests/error/exn.rs | 18 ++++++++++++++++++
 2 files changed, 34 insertions(+), 1 deletion(-)

499402c

I reverted the change on main, re-ran cargo run -- diff file :README.md README.md and the error was gone, so it actually seems related to this specific change.

This went unnoticed since we currently don’t have regression tests for gix diff file.

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