Skip to content

Commit

Permalink
fix: make repositories with worktree config work.
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Oct 16, 2023
1 parent c5a7e66 commit 8b758ea
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
12 changes: 12 additions & 0 deletions gix-discover/tests/fixtures/make_basic_repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,15 @@ git init non-bare-without-index
git commit -m "init"
rm .git/index
)

git --git-dir=repo-with-worktree-in-config-unborn-no-worktreedir --work-tree=does-not-exist-yet init
worktree=repo-with-worktree-in-config-unborn-worktree
git --git-dir=repo-with-worktree-in-config-unborn --work-tree=$worktree init && mkdir $worktree

worktree=repo-with-worktree-in-config-worktree
git --git-dir=repo-with-worktree-in-config --work-tree=$worktree init
mkdir $worktree && touch $worktree/file
(cd repo-with-worktree-in-config
git add file
git commit -m "make sure na index exists"
)
26 changes: 26 additions & 0 deletions gix-discover/tests/is_git/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,29 @@ fn missing_configuration_file_is_not_a_dealbreaker_in_nonbare_repo() -> crate::R
}
Ok(())
}

#[test]
fn unborn_with_split_worktree_by_configuration() -> crate::Result {
for name in [
"repo-with-worktree-in-config-unborn",
"repo-with-worktree-in-config-unborn-no-worktreedir",
] {
let repo = repo_path()?.join(name);
let kind = gix_discover::is_git(&repo)?;
assert_eq!(
kind,
gix_discover::repository::Kind::Bare,
"{name}: we think these are bare as we don't read the configuration in this case - \
a shortcoming to favor performance which still comes out correct in `gix`"
);
}
Ok(())
}

#[test]
fn split_worktree_as_seen_from_repo() -> crate::Result {
let repo = repo_path()?.join("repo-with-worktree-in-config");
let kind = gix_discover::is_git(&repo)?;
assert_eq!(kind, gix_discover::repository::Kind::WorkTree { linked_git_dir: None });
Ok(())
}

0 comments on commit 8b758ea

Please sign in to comment.