Skip to content

bug(git): branch names containing slashes misclassified as file paths #146

@rocketman-code

Description

@rocketman-code

Current Behavior

Running chainsaw diff feature/auth --entry src/index.ts fails with a "file not found" error because the slash in feature/auth triggers the path-like heuristic in classify_diff_arg. The function checks for / before attempting git ref resolution, so valid branch names like feature/auth, bugfix/login, or release/v2 are never tried as git refs.

Expected Behavior

Branch names with slashes should be correctly identified as git refs. The function should attempt git ref resolution before the path-like heuristic, or the heuristic should be scoped more narrowly.

Context

Slash-separated branch names are a common convention (feature/x, bugfix/y, release/z). This makes chainsaw diff unusable with these branch naming patterns.

Technical Details

Relevant Code

src/git.rs:30-37classify_diff_arg

let looks_like_path = arg.contains('/')
    || arg.contains(std::path::MAIN_SEPARATOR)
    || path.extension().is_some_and(|ext| ext.eq_ignore_ascii_case("json"));
if looks_like_path {
    return Err(crate::error::Error::DiffFileNotFound(arg.to_string()));
}

The / check fires before the git rev-parse fallback at line 40.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium prioritybugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions