Skip to content

Commit b754897

Browse files
test: cover subdirectory discovery and pathspec commands in bare-repo worktrees (#2223)
1 parent 9ebf8b6 commit b754897

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

test/test_repo.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,6 +1476,17 @@ def test_git_work_tree_from_bare_repo(self, rw_dir):
14761476
assert not repo.bare
14771477
assert osp.samefile(repo.working_tree_dir, worktree_path)
14781478

1479+
# Discovering from a subdirectory (as tools such as mkdocs plugins do) and then
1480+
# running a command with an absolute pathspec must use the worktree, not the
1481+
# bare common dir, as the working directory; 3.1.61 failed here with
1482+
# "is outside repository at '<bare_repo>/.'" (#2223).
1483+
subdir = osp.join(worktree_path, "git", "repo")
1484+
sub_repo = Repo(subdir, search_parent_directories=True)
1485+
assert not sub_repo.bare
1486+
assert osp.samefile(sub_repo.working_dir, worktree_path)
1487+
expected = repo.git.log("-n", "1", "--format=%H", "--", "git/repo")
1488+
assert sub_repo.git.log("-n", "1", "--format=%H", "--", subdir) == expected
1489+
14791490
def test_git_work_tree_dotgit_relative(self):
14801491
"""Check that we find .git as a worktree file containing a relative path
14811492
and find the worktree based on it."""

0 commit comments

Comments
 (0)