Skip to content

Commit 41c3954

Browse files
authored
Merge pull request #2228 from christianvuerings/test-bare-worktree-subdir-discovery
test: cover subdirectory discovery and pathspec commands in bare-repository worktrees
2 parents 9ebf8b6 + db47516 commit 41c3954

3 files changed

Lines changed: 26 additions & 1 deletion

File tree

AGENTS.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Commit messages
2+
3+
Every commit must have a descriptive title and a substantive body. Title-only
4+
commit messages are not acceptable.
5+
6+
The body must explain the problem or motivation, what changed, and why the
7+
chosen approach addresses it. Include relevant behavior before and after the
8+
change, design decisions, limitations, and validation results. Scale the detail
9+
to the change; do not add boilerplate or claim checks that were not run.
10+
11+
Commit messages must stand on their own. Put the information needed to understand
12+
and review the change in the commit body, even when it also appears in a pull
13+
request description. PR and issue links may provide additional context, but must
14+
not substitute for that explanation.

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.1.61
1+
3.1.62

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)