Skip to content

fix: make Repository::kind() detect linked worktrees of bare repos#2699

Open
Jason Han (jason5122) wants to merge 1 commit into
GitoxideLabs:mainfrom
jason5122:fix-kind-worktree-of-natively-bare-repo
Open

fix: make Repository::kind() detect linked worktrees of bare repos#2699
Jason Han (jason5122) wants to merge 1 commit into
GitoxideLabs:mainfrom
jason5122:fix-kind-worktree-of-natively-bare-repo

Conversation

@jason5122

Copy link
Copy Markdown

Description

While bumping gix to v0.85 in tmux-sessionizer, I hit a misclassification for worktrees of bare repositories. Calling Repository::kind() returns Kind::Common, but it should be Kind::LinkedWorkTree.

Steps to Reproduce

mkdir -p /tmp/gix-bug && cd /tmp/gix-bug
git init --bare project
cd project
git worktree add ../worktree-of-project
// Move to `gix/examples/gix_bug.rs`.
// Usage: `cargo run -p gix --example gix_bug -- <path-to-worktree>`

use std::path::PathBuf;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let path = std::env::args_os()
        .nth(1)
        .map(PathBuf::from)
        .unwrap_or_else(|| ".".into());
    let repo = gix::open(&path)?;

    println!("kind(): {:?}", repo.kind());
    Ok(())
}

Before

$ cargo run -p gix --example gix_bug -- /tmp/gix-bug/worktree-of-project
kind(): Common

After

$ cargo run -p gix --example gix_bug -- /tmp/gix-bug/worktree-of-project
kind(): LinkedWorkTree

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant