| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 589d8af commit 180b1ff
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -386,6 +386,10 @@ def __init__( | |||
| 386 | 386 | # Let's not assume the option exists, although it should. | |
| 387 | 387 | pass | |
| 388 | 388 | ||
| 389 | + # A linked worktree is not bare even when its main repository is. | ||
| 390 | + if self._bare and self._working_tree_dir and osp.isfile(osp.join(self.git_dir, "commondir")): | ||
| 391 | + self._bare = False | ||
| 392 | + | ||
| 389 | 393 | # Adjust the working directory in case we are actually bare - we didn't know | |
| 390 | 394 | # that in the first place. | |
| 391 | 395 | if self._bare: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1459,6 +1459,23 @@ def test_git_work_tree_dotgit(self, rw_dir, use_relative_paths=False): | |||
| 1459 | 1459 | ||
| 1460 | 1460 | self.assertIsInstance(repo.heads["aaaaaaaa"], Head) | |
| 1461 | 1461 | ||
| 1462 | + @with_rw_directory | ||
| 1463 | + def test_git_work_tree_from_bare_repo(self, rw_dir): | ||
| 1464 | + if Git().version_info[:3] < (2, 5, 1): | ||
| 1465 | + pytest.skip("worktree feature unsupported, needs git 2.5.1 or later") | ||
| 1466 | + | ||
| 1467 | + bare_repo = self.rorepo.clone(join_path_native(rw_dir, "bare_repo"), bare=True) | ||
| 1468 | + worktree_path = join_path_native(rw_dir, "worktree_repo") | ||
| 1469 | + if Git.is_cygwin(): | ||
| 1470 | + worktree_path = cygpath(worktree_path) | ||
| 1471 | + bare_repo.git.worktree("add", "--detach", worktree_path) | ||
| 1472 | + | ||
| 1473 | + repo = Repo(worktree_path) | ||
| 1474 | + | ||
| 1475 | + assert Git(worktree_path).rev_parse("--is-bare-repository") == "false" | ||
| 1476 | + assert not repo.bare | ||
| 1477 | + assert osp.samefile(repo.working_tree_dir, worktree_path) | ||
| 1478 | + | ||
| 1462 | 1479 | def test_git_work_tree_dotgit_relative(self): | |
| 1463 | 1480 | """Check that we find .git as a worktree file containing a relative path | |
| 1464 | 1481 | and find the worktree based on it.""" | |
| Back | FazBrowse Home | New Git URL |
0 commit comments